...
[iramuteq] / layout.py
index 91d5f83..bee04ee 100644 (file)
--- a/layout.py
+++ b/layout.py
@@ -65,8 +65,10 @@ class GraphPanelAfc(wx.Panel):
               'qui' : 0,
               'do_select_nb' : 0,
               'do_select_chi' : 0,
+              'do_select_chi_classe' : 0,
               'select_nb' : 50,
               'select_chi' : 4,
+              'nbchic' : 30,
               'over' : 0, 
               'cex_txt' : 0,
               'txt_min' : 5,
@@ -116,8 +118,10 @@ class GraphPanelAfc(wx.Panel):
                           'qui' : dial.choice2.GetSelection(),
                           'do_select_nb' : dial.check1.GetValue(),
                           'do_select_chi' : dial.check2.GetValue(),
+                          'do_select_chi_classe' : dial.check_chic.GetValue(),
                           'select_nb' : dial.spin_nb.GetValue(),
                           'select_chi' : dial.spin_chi.GetValue(),
+                          'nbchic' : dial.spin_nbchic.GetValue(),
                           'over' : dial.check3.GetValue(), 
                           'cex_txt' : dial.check4.GetValue(),
                           'txt_min' : dial.spin_min.GetValue(),
@@ -142,6 +146,12 @@ class GraphPanelAfc(wx.Panel):
                 afc <- afcf
                 afc_table <- afcf_table
                 chistabletot <- specfp
+                infp <- which(is.infinite(chistabletot) & chistabletot > 0)
+                infm <- which(is.infinite(chistabletot) & chistabletot < 0)
+                chistabletot[infp] <- 0
+                chistabletot[infm] <- 0
+                chistabletot[infp] <- max(chistabletot) + 1
+                chistabletot[infm] <- min(chistabletot) - 1
                 """ 
             elif self.itempath == 'liste_graph_afct' :
                 txt +="""
@@ -227,6 +237,7 @@ class OpenCHDS():
        self.pathout.basefiles(ChdTxtPathOut)
        DictPathOut = self.pathout 
        self.DictPathOut = DictPathOut
+       self.dictpathout = DictPathOut
        self.parent = parent
 
        Profile = DictPathOut['PROFILE_OUT']
@@ -341,7 +352,7 @@ class OpenCHDS():
        panel.ProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
        panel.ProfNB.SetArtProvider(aui.ChromeTabArt())
        #self.ProfNB.SetTabCtrlHeight(100)
-       panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
+       #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
        if os.path.exists(DictPathOut['prof_seg']) :
             prof_seg = ReadProfileAsDico(self, DictPathOut['prof_seg'], False, self.encoding)
             self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
@@ -351,9 +362,9 @@ class OpenCHDS():
             indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]])
             print 'construction liste classe %i' % i
             self.tabprofile = ProfListctrlPanel(self.parent, self, DictProfile[str(i + 1)], Alceste, i + 1)
-            self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
+            #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
             panel.ProfNB.AddPage(self.tabprofile, 'classe %s %s(%s%%)' % (str(i + 1), sep, indpour))
-            panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
+            #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
             if os.path.exists(DictPathOut['prof_seg']) :
                 self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
                 self.prof_seg_nb.AddPage(self.tab_prof_seg, 'classe %i' % (i + 1))
@@ -368,13 +379,13 @@ class OpenCHDS():
            if os.path.exists(self.DictPathOut['afc_facteur']) :
                dictrow, first = ReadList(self.DictPathOut['afc_facteur'], self.encoding)
                self.TabAFC_facteur = ListForSpec(self.parent, parametres, dictrow, first)
-               dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
-               self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
-               dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
-               self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
+               #dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
+               #self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
+               #dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
+               #self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
                self.TabAFC.AddPage(self.TabAFC_facteur, 'Facteurs')
-               self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
-               self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
+               #self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
+               #self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
            
            sizer_3 = wx.BoxSizer(wx.VERTICAL)
            self.parent.nb_panel_2 = wx.Panel(panel.TabChdSim, -1)
@@ -387,7 +398,7 @@ class OpenCHDS():
            self.parent.Bind(wx.EVT_BUTTON, self.onsimi, self.parent.button_simi)
        
        panel.TabChdSim.AddPage(panel.ProfNB, 'Profils')
-       panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
+       #panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
        dlg.Update(4 + self.clnb, 'Affichage...')
        if clnb > 2 :
            panel.TabChdSim.AddPage(self.TabAFC, 'AFC')
@@ -456,11 +467,13 @@ class OpenCHDS():
             dlg.Destroy()
 
     def onprofseg(self, event):
-        try :
+        #try :
+            print 'plus de bug profseg'
+            print self.parametres
             corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
-            ProfileSegment(self.parent,corpus)
-        except :
-            BugReport(self.parent)
+            ProfileSegment(self.parent, self.dictpathout, self.parametres, corpus)
+        #except :
+        #    BugReport(self.parent)
 
     def onproftype(self, event):
         try :
@@ -949,29 +962,32 @@ class SimiLayout(DefaultTextLayout) :
         if self.actives is None :
             with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
                 self.actives = f.read()
-            self.actives = [act for act in self.actives.splitlines()]
+            self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
         dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
-        SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected) 
-        prep = PrepSimi(self.ira, self.parametres, indices_simi)
-        self.parametres = prep.parametres
-        script = PrintSimiScript(self)
-        script.make_script()
-        pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
-        check_Rresult(self.ira, pid)
-        if self.parametres['type_graph'] == 1:
-            if os.path.exists(self.pathout['liste_graph']):
-                graph_simi = read_list_file(self.pathout['liste_graph'])
-                graph_simi.append([os.path.basename(script.filename), script.txtgraph])
-            else :
-                graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
-            print_liste(self.pathout['liste_graph'], graph_simi)
-        DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
-        if self.parametres['type_graph'] == 1:
-            self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
-            self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
-            self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
-            self.graphpan.Layout()
-            self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
+        #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True) 
+        #if res.ok :
+        prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
+        if prep.val == wx.ID_OK :
+            self.parametres = prep.parametres
+
+            script = PrintSimiScript(self)
+            script.make_script()
+            pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
+            check_Rresult(self.ira, pid)
+            if self.parametres['type_graph'] == 1:
+                if os.path.exists(self.pathout['liste_graph']):
+                    graph_simi = read_list_file(self.pathout['liste_graph'])
+                    graph_simi.append([os.path.basename(script.filename), script.txtgraph])
+                else :
+                    graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
+                print_liste(self.pathout['liste_graph'], graph_simi)
+            DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
+            if self.parametres['type_graph'] == 1:
+                self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+                self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+                self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
+                self.graphpan.Layout()
+                self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
 
     def export(self, evt) :
         pass