Merge branch 'master' of http://www.netdig.org/git/iramuteq
[iramuteq] / textstat.py
index 4d67879..2618c51 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/env python
 # -*- coding: utf-8 -*-
 #Author: Pierre Ratinaud
 #!/bin/env python
 # -*- coding: utf-8 -*-
 #Author: Pierre Ratinaud
-#Copyright (c) 2008-2009 Pierre Ratinaud
+#Copyright (c) 2008-2012 Pierre Ratinaud
 #Lisense: GNU/GPL
 
 #from chemins import ConstructPathOut, StatTxtPathOut, ffr
 #Lisense: GNU/GPL
 
 #from chemins import ConstructPathOut, StatTxtPathOut, ffr
@@ -31,20 +31,7 @@ class Stat(AnalyseText) :
         self.make_stats()
 
     def preferences(self) :
         self.make_stats()
 
     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
+        return self.parametres
 
     def make_stats(self):
         if self.dlg :
 
     def make_stats(self):
         if self.dlg :
@@ -67,6 +54,8 @@ class Stat(AnalyseText) :
         supp = [[forme, formes[forme].freq, formes[forme].gram] for forme in formes if formes[forme].act == 2]        
         supp = sortedby(supp, 2, 1)
 
         supp = [[forme, formes[forme].freq, formes[forme].gram] for forme in formes if formes[forme].act == 2]        
         supp = sortedby(supp, 2, 1)
 
+        #print self.corpus.gethapaxbyuci()
+
         supp = [[i, val] for i, val in enumerate(supp)]
         #self.corpus.pathout = self.dictpathout
         #self.corpus.make_type_tot()
         supp = [[i, val] for i, val in enumerate(supp)]
         #self.corpus.pathout = self.dictpathout
         #self.corpus.make_type_tot()
@@ -92,12 +81,17 @@ class Stat(AnalyseText) :
         txt = """
         source("%s")
         tot <- read.csv2("%s", header = FALSE, row.names = 1)
         txt = """
         source("%s")
         tot <- read.csv2("%s", header = FALSE, row.names = 1)
-        hapax <- read.csv2("%s", header = FALSE, row.names = 1)
-        tot <- rbind(tot, hapax)
+        """ % (self.parent.RscriptsPath['Rgraph'], self.pathout['total.csv'])
+        if len(hapax) :
+            txt += """
+            hapax <- read.csv2("%s", header = FALSE, row.names = 1)
+            tot <- rbind(tot, hapax)
+            """ % self.pathout['hapax.csv']
+        txt += """
         open_file_graph("%s", width = 400, height = 400)
         plot(log(tot[,1]), log = 'x', xlab='log(rangs)', ylab = 'log(frequences)', col = 'red', pch=16)
         dev.off()
         open_file_graph("%s", width = 400, height = 400)
         plot(log(tot[,1]), log = 'x', xlab='log(rangs)', ylab = 'log(frequences)', col = 'red', pch=16)
         dev.off()
-        """ % (self.parent.RscriptsPath['Rgraph'], self.pathout['total.csv'], self.pathout['hapax.csv'], self.pathout['zipf.png'])
+        """ % (self.pathout['zipf.png'])
         tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
         with open(tmpscript, 'w') as f :
             f.write(txt)
         tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
         with open(tmpscript, 'w') as f :
             f.write(txt)
@@ -122,8 +116,8 @@ class Stat(AnalyseText) :
             else :
                 with open(self.pathout['%s.txt' % 'glob'], 'w') as f :
                     f.write(self.result['glob'].encode(self.parent.syscoding))
             else :
                 with open(self.pathout['%s.txt' % 'glob'], 'w') as f :
                     f.write(self.result['glob'].encode(self.parent.syscoding))
-            self.parametres['pathout'] = self.pathout['Analyse.ira']
-            DoConf().makeoptions(['stat'],[self.parametres], self.pathout['Analyse.ira'])
+            #self.parametres['pathout'] = self.pathout['Analyse.ira']
+            #DoConf().makeoptions(['stat'],[self.parametres], self.pathout['Analyse.ira'])
 
 
 #class Stat():
 
 
 #class Stat():