...
[iramuteq] / textsimi.py
index acb85a3..228598a 100644 (file)
@@ -52,31 +52,20 @@ class SimiTxt(AnalyseText):
                 log.info('Problem')
                 return False
             if self.parametres['type_graph'] == 1:
+                if self.parametres['svg'] :
+                    filename, ext = os.path.splitext(script.filename)
+                    fileout = filename + '.svg'                    
+                else :
+                    fileout = script.filename
                 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])
+                    graph_simi.append([os.path.basename(fileout), script.txtgraph])
                 else :
-                    graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
+                    graph_simi = [[os.path.basename(fileout), script.txtgraph]]
                 print_liste(self.pathout['liste_graph'], graph_simi)
         else : 
             return False
 
-#    def preferences(self) :
-#        dial = StatDialog(self, self.parent)
-#        dial.CenterOnParent()
-#        val = dial.ShowModal()
-#        if val == 5100 :
-#            if dial.radio_lem.GetSelection() == 0 :
-#                lem = 1
-#            else :
-#                lem = 0            
-#            self.parametres['lem'] = lem
-#            dial.Destroy()
-#            return self.parametres
-#        else :
-#            dial.Destroy()
-#            return None
-
     def makesimiparam(self) :
         self.paramsimi = {'coeff' : 0,
                           'layout' : 2,
@@ -126,9 +115,11 @@ class SimiTxt(AnalyseText):
             f.write('\n'.join(self.actives).encode(self.ira.syscoding))
 
 class SimiFromCluster(SimiTxt) :
-    def __init__(self, ira, corpus, actives, numcluster, parametres = None, dlg = False) :
+    def __init__(self, ira, corpus, actives, lfreq, lchi, numcluster, parametres = None, dlg = False) :
         self.actives = actives
         self.numcluster = numcluster
+        self.lfreq = lfreq
+        self.lchi = lchi
         parametres['name'] = 'simi_classe_%i' % (numcluster + 1)
         SimiTxt.__init__(self, ira, corpus, parametres, dlg, lemdial = False)
     
@@ -167,7 +158,7 @@ class SimiFromCluster(SimiTxt) :
                     filename, ext = os.path.splitext(script.filename)
                     fileout = filename + '.svg'                    
                 else :
-                    fileout = self.script.filename
+                    fileout = script.filename
                 if os.path.exists(self.pathout['liste_graph']):
                     graph_simi = read_list_file(self.pathout['liste_graph'])
                     graph_simi.append([os.path.basename(fileout), script.txtgraph])
@@ -184,3 +175,8 @@ class SimiFromCluster(SimiTxt) :
         self.corpus.make_and_write_sparse_matrix_from_classe(self.actives, self.corpus.lc[self.numcluster], self.pathout['mat01.csv'])
         with open(self.pathout['actives.csv'], 'w') as f :
             f.write('\n'.join(self.actives).encode(self.ira.syscoding))        
+        with open(self.pathout['actives_nb.csv'], 'w') as f :
+            f.write('\n'.join([`val` for val in self.lfreq]))
+        with open(self.pathout['actives_chi.csv'], 'w') as f :
+            f.write('\n'.join([`val` for val in self.lchi]))
+