Merge branch '3.0' of http://www.iramuteq.org/git/iramuteq into 3.0
authorpierre <ratinaud@univ-tlse2.fr>
Sun, 4 Feb 2024 21:58:33 +0000 (22:58 +0100)
committerpierre <ratinaud@univ-tlse2.fr>
Sun, 4 Feb 2024 21:58:33 +0000 (22:58 +0100)
20 files changed:
PrintRScript.py
Rscripts/CHD.R
checkinstall.py
configparser.py
configuration/global.cfg
configuration/iramuteq.cfg
corpus.py
dialog.py
functions.py
guifunct.py
iramuteq.py
layout.py
profile_segment.py
search_list.py
search_tools.py
textaslexico.py
textsimi.py
textstat.py
textwordcloud.py
tree.py

index 0699b3f..ca88660 100755 (executable)
@@ -1172,7 +1172,7 @@ class PrintSimiScript(PrintRScript):
         if (!is.null(graph.simi$com)) {
             com <- graph.simi$com
             colm <- rainbow(length(com))
-            if (vertex.size != 0 || graph.simi$halo) {
+            if (sum(vertex.size) != 0 || graph.simi$halo) {
                 vertex.label.color <- 'black'
                 vertex.col <- colm[membership(com)]
             } else {
index a480df9..4e64b01 100644 (file)
@@ -230,7 +230,7 @@ CHD<-function(data.in, x=9, mode.patate = FALSE, svd.method, libsvdc.path=NULL){
                        print('longueur < 0')
                        malcl<-length(vdelta)
                        if ((it>1)&&(!is.logical(listsub[[it]]))&&(!is.logical(listsub[[it-1]]))){
-                               if (listsub[[it]]==listsub[[(it-1)]]){
+                               if (all(listsub[[it]]==listsub[[(it-1)]])){
                                        malcl<-0
                                }
                        }
index 79b7c45..7b8e51b 100644 (file)
@@ -135,7 +135,7 @@ def FindRPAthWin32():
         for progpath in progpaths :
             rpath = os.path.join(progpath, "R")
             if os.path.exists(rpath) :
-                for maj in range(2,4) :
+                for maj in range(3,5) :
                     for i in range(0,30):
                         for j in range(0,20):
                             for poss in ['', 'i386', 'x64'] :
index 5a52260..11baaaf 100644 (file)
@@ -713,7 +713,7 @@ class RawConfigParser(MutableMapping):
         read_ok = []
         for filename in filenames:
             try:
-                with open(filename, encoding=encoding) as fp:
+                with open(filename, encoding='utf8') as fp:
                     self._read(fp, filename)
             except IOError:
                 continue
index bfa07bd..8f28997 100644 (file)
@@ -7,6 +7,6 @@ author = Pierre Ratinaud
 gpl-fr = gpl-2.0-fr.txt
 dev = Pierre Ratinaud (Université de Toulouse - Laboratoire LERASS - ratinaud@univ-tlse2.fr);Sébastien Déjean (Université de Toulouse);David Skalinder (Mash Strategy - davids@mash.uk.com);
 translators = Italian : Emanuele Fino;Portuguese : Brigido Vizeu Camargo;Spanish : Mariola Moreno;English : Pierre Ratinaud;French : Pierre Ratinaud
-version = 0.8 alpha 1
+version = 0.8 alpha 2
 licence = GNU GPL (v2)
-version_nb = 0.8.a1
+version_nb = 0.8.a2
index 263dbdd..7d24336 100644 (file)
@@ -5,8 +5,8 @@ language=french
 guilanguage=french
 R_mem = false
 R_max_mem = 1535
-version_nb = 0.8.a1
+version_nb = 0.8.a2
 rlibs = false
 libsvdc = false
 libsvdc_path = /usr/bin/svd
-rmirror = http://cran.rstudio.com/
\ No newline at end of file
+rmirror = http://cran.rstudio.com/
index e6b0bf2..489d4f1 100644 (file)
--- a/corpus.py
+++ b/corpus.py
@@ -144,7 +144,7 @@ class Corpus :
 
     def read_corpus(self) :
         log.info('read corpus')
-        self.parametres['syscoding'] = sys.getdefaultencoding()
+        self.parametres['syscoding'] = 'utf8'
         if self.conncorpus is None :
             self.conn_all()
         res = self.ccorpus.execute('SELECT * FROM etoiles;')
@@ -566,7 +566,7 @@ class Corpus :
         self.make_iduces()
         actuci = ''
         actpara = False
-        with open(outf,'w') as f :
+        with open(outf,'w', encoding='utf8') as f :
             for uce in res :
                 if self.iduces[uce[0]].uci == actuci and self.iduces[uce[0]].para == actpara :
                     f.write(uce[1] + '\n')
@@ -589,7 +589,7 @@ class Corpus :
         longueur_max = max([len(val) for val in metas])
         first = ['column_%i' % i for i in range(longueur_max)]
         metas.insert(0, first)
-        with open(outf, 'w') as f :
+        with open(outf, 'w', encoding='utf8') as f :
             f.write('\n'.join(['\t'.join(line) for line in metas]))
 
     def export_corpus_classes(self, outf, alc = True, lem = False, uci = False) :
@@ -604,7 +604,7 @@ class Corpus :
             self.make_iduces()
         else :
             res = self.getallucis()
-        with open(outf, 'w') as f :
+        with open(outf, 'w', encoding='utf8') as f :
             for uce in res :
                 guce = uce[1]
                 if not uci :
@@ -627,7 +627,7 @@ class Corpus :
             self.make_iduces()
         else :
             res = self.getuciconcorde(sts)
-        with open(outf, 'w') as f :
+        with open(outf, 'w', encoding='utf8') as f :
             for uce in res :
                 guce = uce[1]
                 if not uci :
@@ -652,7 +652,7 @@ class Corpus :
             outf = os.path.join(rep, outf)
             if lem :
                 guce = ' '.join([self.formes[forme].lem for forme in guce.split()])
-            with open(outf, 'w') as f :
+            with open(outf, 'w', encoding='utf8') as f :
                 f.write(guce) #.encode('cp1252', errors = 'replace'))
 
     def export_tropes(self, fileout, classe, lem = False, uci = False) :
@@ -662,7 +662,7 @@ class Corpus :
             self.make_iduces()
         else :
             res = self.getuciconcorde(sts)
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             for uce in res :
                 guce = uce[1]
                 if lem :
@@ -803,7 +803,7 @@ class Corpus :
         else :
             tab = [[lem] + [len(set(self.getlemuces(lem)).intersection(classe)) for classe in ucecl] for lem in actives]
         tab = [[line[0]] + [repr(val) for val in line[1:]] for line in tab if sum(line[1:]) >= 3]
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write('\n'.join([';'.join(line) for line in tab]))
 
     def make_etoiles(self) :
@@ -879,7 +879,7 @@ class Corpus :
         else :
             etoileuces = self.getetoileucis()
         etoileuces = dict([[et, etoileuces[et]] for et in etoileuces if len(etoileuces[et]) > 1])
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write('\n'.join([';'.join([et] + [repr(len(set(etoileuces[et]).intersection(classe))) for classe in ucecl]) for et in etoileuces])) #.encode(self.parametres['syscoding'])
         #etoiles = self.make_etoiles()
         #with open(fileout, 'w') as f :
@@ -894,9 +894,9 @@ class Corpus :
             ucecl[uce] = 0
         color = ['black'] + colors[len(self.lc) - 1]
         txt = '''<html>
-        <meta http-equiv="content-Type" content="text/html; charset=%s" />
+        <meta http-equiv="content-Type" content="text/html; charset=utf8" />
         <body>
-''' % sys.getdefaultencoding()
+'''
         if not uci :
             res = self.getalluces()
             self.make_iduces()
@@ -1002,7 +1002,7 @@ class Corpus :
                 for taille_segment in range(lenmin,lenmax) :
                     d =self.count_from_list_cl([' '.join(uce[i:i+taille_segment]) for i in range(len(uce)-(taille_segment - 1))], d, b, len(self.lc))
         result = [[seg] + [str(val) for val in d[seg]] for seg in d if sum(d[seg]) >= effmin]
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write('\n'.join([';'.join(line) for line in result]))
 
     def make_proftype(self, outf) :
@@ -1017,7 +1017,7 @@ class Corpus :
                 res[gram][i] += sum([lemuceeff[uce] for uce in concern])
         res = [[gram] + [repr(val) for val in res[gram]] for gram in res]
         res.sort()
-        with open(outf, 'w') as f :
+        with open(outf, 'w', encoding='utf8') as f :
             f.write('\n'.join([';'.join(line) for line in res]))
 
     def make_ucecl_from_R(self, filein) :
@@ -1057,7 +1057,7 @@ class Corpus :
         log.info('%f' % (time() - t1))
         if outf is not None :
             toprint = '\n'.join([';'.join([repr(i), repr(occurrences[i]), repr(formescl[i]), repr(hapaxcl[i]), repr(lenclasses[i]), repr(float(hapaxcl[i])/float(formescl[i]))]) for i in occurrences])
-            with open(outf, 'w') as f :
+            with open(outf, 'w', encoding='utf8') as f :
                 f.write(toprint)
         else :
             return [[repr(occurrences[i]), repr(formescl[i]), repr(hapaxcl[i]), repr(lenclasses[i]), repr(float(hapaxcl[i])/float(formescl[i]))] for i in occurrences]
@@ -1121,21 +1121,21 @@ class Corpus :
         txt += """
         </body></html>
         """
-        with open('/tmp/testhapxuce.html','w') as f :
+        with open('/tmp/testhapxuce.html','w', encoding='utf8') as f :
             f.write(txt)
 
     def export_dictionary(self, fileout, syscoding) :
         listformes = [[self.formes[forme].freq, forme, self.formes[forme].lem, self.formes[forme].gram] for forme in self.formes]
         listformes.sort(reverse = True)
         listformes = [forme[1:] + [repr(forme[0])] for forme in listformes]
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write('\n'.join(['\t'.join(forme) for forme in listformes]))
 
     def export_lems(self, fileout, syscoding) :
         self.make_idformes()
         listlem = [[lem, '\t'.join(['\t'.join([self.idformes[forme].forme, repr(self.lems[lem].formes[forme])]) for forme in self.lems[lem].formes])] for lem in self.lems]
         listlem.sort()
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write('\n'.join(['\t'.join(lem) for lem in listlem]))
 
 
index 93fd3e4..4143526 100755 (executable)
--- a/dialog.py
+++ b/dialog.py
@@ -559,11 +559,11 @@ memory for R""")
             parent.pref.set('iramuteq', 'libsvdc', 'false')
         parent.pref.set('iramuteq', 'libsvdc_path', self.fbb.GetValue())
         self.parent.pref.set('iramuteq', 'rmirror', self.mirror_value.GetValue())
-        file = open(parent.ConfigPath['preferences'], 'w')
+        file = open(parent.ConfigPath['preferences'], 'w', encoding='utf8')
         parent.pref.write(file)
         file.close()
         self.parent.PathPath.set('PATHS', 'rpath', self.Rpath_value.GetValue())
-        with open(self.parent.ConfigPath['path'], 'w') as f:
+        with open(self.parent.ConfigPath['path'], 'w', encoding='utf8') as f:
             self.parent.PathPath.write(f)
         self.Close()
 
@@ -1231,7 +1231,7 @@ class PrefSegProf(wx.Dialog) :
         bSizer1 = wx.BoxSizer( wx.VERTICAL )
         txt = _("Be carefull : computation of repeated segments profiles can be very long on large corpus")
         self.label = wx.StaticText( self, wx.ID_ANY, txt, wx.DefaultPosition, wx.DefaultSize, 0 )
-        bSizer1.Add( self.label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
+        bSizer1.Add( self.label, 0, wx.ALL, 5 )
         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
         fgSizer1.SetFlexibleDirection( wx.BOTH )
         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
@@ -1269,7 +1269,7 @@ class PrefSegProf(wx.Dialog) :
         btn_ok.SetDefault()
         btnsizer.AddButton(btn_ok)
         btnsizer.Realize()
-        bSizer1.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
+        bSizer1.Add(btnsizer, 0, wx.ALIGN_RIGHT, 5)
         self.SetSizer( bSizer1 )
         self.Layout()
         bSizer1.Fit( self )
@@ -2499,7 +2499,7 @@ class message(wx.Frame):
         self.html = '<br>'.join([self.items[i] for i in range(0,len(self.items))])
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
-            with open(path, 'w') as f :
+            with open(path, 'w', encoding='utf8') as f :
                 f.write(self.html)
 
     def OnLink(self, evt):
@@ -3024,7 +3024,7 @@ class BarFrame :
                 parametres['tree'] = tree
             txt = barplot(table, parametres)
             tmpscript = tempfile.mktemp(dir=ira.TEMPDIR)
-            with open(tmpscript,'w') as f :
+            with open(tmpscript,'w', encoding='utf8') as f :
                 f.write(txt)
             exec_rcode(ira.RPath, tmpscript, wait = True)
             win = ImageViewer(ira, parametres, _("Graphic"), size=(700, 500))
index da8fbae..3472b77 100755 (executable)
@@ -83,13 +83,13 @@ class TGen :
     def write(self, path = None):
         if path is None :
             path = self.path
-        with open(path, 'w') as f :
+        with open(path, 'w', encoding='utf8') as f :
             f.write('\n'.join(['\t'.join([val] + self.tgen[val]) for val in self.tgen]))
 
     def writetable(self, pathout, tgens, totocc):
         etoiles = list(totocc.keys())
         etoiles.sort()
-        with open(pathout, 'w') as f :
+        with open(pathout, 'w', encoding='utf8') as f :
             line = '\t'.join(['tgens'] + etoiles) + '\n'
             f.write(line)
             for t in tgens :
@@ -369,7 +369,7 @@ class DoConf :
         if outfile is None :
             outfile = self.configfile
         outfile = normpath_win32(outfile)
-        with open(outfile, 'w') as f :
+        with open(outfile, 'w', encoding="utf-8") as f :
             f.write(txt)
             #self.conf.write(f)
 
@@ -389,7 +389,7 @@ class DoConf :
 
 
 def write_tab(tab, fileout) :
-        csvWriter = csv.writer(open(fileout, 'w'), delimiter=';', quoting = csv.QUOTE_NONNUMERIC)
+        csvWriter = csv.writer(open(fileout, 'w', newline='', encoding='utf8'), delimiter=';', quoting = csv.QUOTE_NONNUMERIC)
         csvWriter.writerows(tab)
 
 class BugDialog(wx.Dialog):
@@ -433,7 +433,7 @@ def CreateIraFile(DictPathOut, clusternb, corpname='corpus_name', section = 'ana
     AnalyseConf.set(section, 'clusternb', clusternb)
     AnalyseConf.set(section, 'corpus_name', corpname)
 
-    fileout = open(DictPathOut['ira'], 'w')
+    fileout = open(DictPathOut['ira'], 'w', encoding='utf8')
     AnalyseConf.write(fileout)
     fileout.close()
 
@@ -516,10 +516,10 @@ def treat_line_alceste(i, line) :
         line[5] = str(float(line[5].replace(',', '.')))[0:7]
     return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]]
 
-def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()):
+def ReadProfileAsDico(File, Alceste=False, encoding = 'utf8'):
     dictlem = {}
     print('lecture des profiles')
-    FileReader = codecs.open(File, 'r', encoding)
+    FileReader = open(File, 'r', encoding='utf8')
     Filecontent = FileReader.readlines()
     FileReader.close()
     DictProfile = {}
@@ -679,7 +679,7 @@ def PlaySound(parent):
             print('pas de son')
 
 def ReadDicoAsDico(dicopath):
-    with codecs.open(dicopath, 'r', 'UTF8') as f:
+    with open(dicopath, 'r', encoding='UTF8') as f:
         content = f.readlines()
     lines = [line.rstrip('\n\r').replace('\n', '').replace('"', '').split('\t') for line in content if line != '']
     return dict([[line[0], line[1:]] for line in lines])
@@ -696,9 +696,9 @@ def ReadLexique(parent, lang = 'french', filein = None):
         else :
             parent.lexique = ReadDicoAsDico(filein)
 
-def ReadList(filein, encoding = sys.getdefaultencoding(), sep = ';'):
+def ReadList(filein, encoding = 'utf8', sep = ';'):
     #file = open(filein)
-    with codecs.open(filein, 'r', encoding) as f :
+    with open(filein, 'r', encoding='utf8') as f :
         content = f.read()
     content = [line.replace('\n', '').replace('\r','').replace('\"', '').replace(',', '.').split(sep) for line in content.splitlines()]
     #file = codecs.open(filein, 'r', encoding)
@@ -810,11 +810,12 @@ def launchcommand(mycommand):
     Popen(mycommand)
 
 def print_liste(filename,liste):
-    with open(filename,'w') as f :
+    with open(filename,'w', encoding='utf8') as f :
         for graph in liste :
             f.write(';'.join(graph) +'\n')
-def read_list_file(filename, encoding = sys.getdefaultencoding()):
-    with codecs.open(filename,'r', encoding) as f:
+
+def read_list_file(filename, encoding = 'utf8'):
+    with open(filename,'r', encoding='utf8') as f:
         content=f.readlines()
         ncontent=[line.replace('\n','').split(';') for line in content if line.strip() != '']
     return ncontent
@@ -885,7 +886,7 @@ def doconcorde(corpus, uces, mots, uci = False) :
 
 def getallstcarac(corpus, analyse) :
    pathout = PathOut(analyse['ira'])
-   profils =  ReadProfileAsDico(pathout['PROFILE_OUT'], Alceste, self.encoding)
+   profils =  ReadProfileAsDico(pathout['PROFILE_OUT'], Alceste, 'utf8')
    print(profils)
 
 def read_chd(filein, fileout):
@@ -1021,7 +1022,7 @@ def translateprofile(corpus, dictprofile, lf='it', lt='fr', maxword = 50) :
 
 def write_translation_profile(prof, lems, language, dictpathout) :
     if os.path.exists(dictpathout['translations.txt']) :
-        with codecs.open(dictpathout['translations.txt'], 'r', 'utf8') as f :
+        with open(dictpathout['translations.txt'], 'r', encoding='utf8') as f :
             translist = f.read()
         translist = [line.split('\t') for line in translist.splitlines()]
     else :
@@ -1039,13 +1040,13 @@ def write_translation_profile(prof, lems, language, dictpathout) :
             elif line[0] == '*****' :
                 rest[i] = ['*****','*','*', '*', '*', '*']
         toprint += rest
-    with open(dictpathout['translation_profile_%s.csv' % language], 'w') as f :
+    with open(dictpathout['translation_profile_%s.csv' % language], 'w', encoding='utf8') as f :
         f.write('\n'.join([';'.join(line) for line in toprint]))
-    with open(dictpathout['translation_words_%s.csv' % language], 'w') as f :
+    with open(dictpathout['translation_words_%s.csv' % language], 'w', encoding='utf8') as f :
         f.write('\n'.join(['\t'.join([val, lems[val]]) for val in lems]))
     if 'translation_profile_%s.csv' % language not in [val[0] for val in translist] :
         translist.append(['translation_profile_%s.csv' % language, 'translation_words_%s.csv' % language])
-        with open(dictpathout['translations.txt'], 'w') as f :
+        with open(dictpathout['translations.txt'], 'w', encoding='utf8') as f :
             f.write('\n'.join(['\t'.join(line) for line in translist]))
 
 def makesentidict(infile, language) :
index 2b6afe7..2612792 100644 (file)
@@ -163,7 +163,7 @@ class SelectColumn :
                 dial.Destroy()
                 column = [actives.index(val) for val in indexes]
                 column.sort()
-                with open(pathout, 'w') as f :
+                with open(pathout, 'w' ,encoding='utf8') as f :
                     f.write('\n'.join([repr(val) for val in column]))
                 self.ok = True
             else :
@@ -172,7 +172,7 @@ class SelectColumn :
             self.ok = True
             if selected is None :
                 selected = [i for i in range(0, len(actives))]
-            with open(pathout, 'w') as f :
+            with open(pathout, 'w', encoding='utf8') as f :
                 f.write('\n'.join([repr(i) for i in selected]))
 
 
@@ -950,7 +950,7 @@ class PrepSimi :
                     indexes.append(self.dial.listcol.getColumnText(last,0))
                 column = [actives.index(val) for val in indexes]
                 column.sort()
-                with open(pathout, 'w') as f :
+                with open(pathout, 'w', encoding='utf8') as f :
                     f.write('\n'.join([repr(val) for val in column]))
                 self.make_param()
                 self.dial.Destroy()
@@ -1288,15 +1288,15 @@ class ExportMetaTable :
 
 
 def redosimi(self, evt) :
-    with open(self.pathout['selected.csv'],'r') as f :
+    with open(self.pathout['selected.csv'],'r', encoding='utf8') as f :
         selected = f.read()
     selected = [int(val) for val in selected.splitlines()]
     if self.actives is None :
-        with codecs.open(self.pathout['actives.csv'], 'r') as f :
+        with open(self.pathout['actives.csv'], 'r', encoding='utf8') as f :
             self.actives = f.read()
         self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
     if os.path.exists(self.pathout['actives_nb.csv']) :
-        with open(self.pathout['actives_nb.csv'], 'r') as f :
+        with open(self.pathout['actives_nb.csv'], 'r', encoding='utf8') as f :
             act_nb = f.read()
             act_nb = act_nb.splitlines()
         dictcol = dict([[i, [self.actives[i], int(act_nb[i])]] for i, val in enumerate(self.actives)])
@@ -1313,7 +1313,7 @@ def redosimi(self, evt) :
         prep.parametres = self.parametres
         order_actives = [[i, act, self.corpus.getlemeff(act)] for i, act in enumerate(self.actives)]
         order_actives = sorted(order_actives, key=itemgetter(2), reverse = True)
-        with open(self.pathout['selected.csv'], 'w') as f :
+        with open(self.pathout['selected.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join([repr(order_actives[val][0]) for val in self.parametres['selected']]))
     if prep.val == wx.ID_OK or evt is None:
         self.parametres = prep.parametres
index 2bec72a..d0bfb72 100755 (executable)
@@ -184,8 +184,8 @@ class printer(object) :
     def flush(self):
         pass
 
-sys.stderr = writer()
-sys.stdout = printer()
+#sys.stderr = writer()
+#sys.stdout = printer()
 
 images_analyses = {
         'textroot' : 'textroot.png',
@@ -707,7 +707,10 @@ class IraFrame(wx.Frame):
         BestRPath = False
         if not CheckRPath(self.PathPath) :
             if sys.platform == 'win32':
-                BestRPath = FindRPAthWin32()
+                if os.path.exists(self.AppliPath + '\\R\\R') :
+                    BestRPath = self.AppliPath + '\\R\\R\\bin\\x64\\R.exe'
+                else :
+                    BestRPath = FindRPAthWin32()
             else:
                 BestRPath = FindRPathNix()
             if BestRPath:
@@ -763,7 +766,7 @@ class IraFrame(wx.Frame):
         if not menu_pos is None :
             self.mb.EnableTop(menu_pos, Show)
             self.mb.Refresh()
-        self._mgr.Update()
+        #self._mgr.Update()
 
     #--------------------------------------------------------------------
     # fin de __init__ du wx.Frame
@@ -917,13 +920,16 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
         if isinstance(parent, IraFrame) :
             npage = self.nb.GetPage(new)
             if 'parametres' in dir(npage) :
-                self.tree.GiveFocus(uuid=npage.parametres['uuid'])
+                #self.tree.GiveFocus(uuid=npage.parametres['uuid'])
                 if npage.parametres.get('matrix', False) :
                     self.ShowMenu('text', False)
                     self.ShowMenu('matrix', True)
                 elif npage.parametres.get('corpus', False) :
                     self.ShowMenu('text')
                     self.ShowMenu('matrix', False)
+        #self._mgr.Update()
+        #wx.CallAfter(self.nb.SendSizeEvent)
+        #self.Refresh()
 
     # action ou évènement ?
     def OnCloseTab(self, evt):
@@ -965,6 +971,9 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
                 pane.Hide()
         self._mgr.GetPane(panel).Show()
         self._mgr.Update()
+        print('show a pane refresh')
+        wx.CallAfter(self.nb.SendSizeEvent)
+        self.Refresh()
 
     # action ou évènement ?
     def OnAcceuil(self, event):
@@ -1430,7 +1439,7 @@ class MySplashScreen(wx.adv.SplashScreen):
         displaySize = wx.DisplaySize()
         w = displaySize[0]/1.2
         h = displaySize[1]/1.2
-        frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(w, h))
+        frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(int(w), int(h)))
         frame.Show()
         frame.finish_init()
         frame.Upgrade()
index 19a53af..7c7edd9 100644 (file)
--- a/layout.py
+++ b/layout.py
@@ -420,7 +420,7 @@ class OpenCHDS():
         for i in range(0, clnb) :
             clusternames[i] = ' '.join(['%i' % (i + 1), _('Cluster'),  '%i' % (i + 1)])
         if os.path.exists(self.pathout['classes_names.txt']) :
-            with codecs.open(self.pathout['classes_names.txt'], 'r', self.parent.syscoding) as f :
+            with open(self.pathout['classes_names.txt'], 'r', encoding='utf8') as f :
                 clusternames_ = f.read()
             clusternames_ =  dict([[i, ' '.join([repr(i + 1), line])] for i, line in enumerate(clusternames_.splitlines())])
             clusternames.update(clusternames_)
@@ -431,7 +431,7 @@ class OpenCHDS():
         panel = wx.Panel(parent, -1)
         sizer1 = wx.BoxSizer(wx.VERTICAL)
         if os.path.exists(DictPathOut['pre_rapport']):
-            with codecs.open(DictPathOut['pre_rapport'], 'r') as f :
+            with open(DictPathOut['pre_rapport'], 'r', encoding='utf8') as f :
                 txt = f.read()
             self.debtext = txt
         else :
@@ -544,7 +544,7 @@ class OpenCHDS():
             self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenchi2.csv')
             TgenLayout(panel)
         if os.path.exists(self.dictpathout['translations.txt']) :
-            with codecs.open(self.dictpathout['translations.txt'], 'r', 'utf8') as f:
+            with open(self.dictpathout['translations.txt'], 'r', encoding='utf8') as f:
                 translist = f.read()
             translist = [line.split('\t') for line in translist.splitlines()]
             for line in translist :
@@ -563,7 +563,7 @@ class OpenCHDS():
 
     def opentrans(self, trans) :
         prof = ReadProfileAsDico(self.dictpathout[trans[0]], False)
-        with codecs.open(self.dictpathout[trans[1]], 'r') as f :
+        with open(self.dictpathout[trans[1]], 'r', encoding='utf8') as f :
             lems = f.read()
         lems = [line.split('\t') for line in lems.splitlines()]
         lems = dict(lems)
@@ -634,7 +634,7 @@ def PrintRapport(self, corpus, parametres, istxt = True):
 
     txt += ''.join([sep, '###########################', sep, _('time'), ' : %s' % parametres.get('time', ''), sep, '###########################', sep])
     # ecriture du resultat dans le fichier
-    with open(self.pathout['pre_rapport'], 'w') as f :
+    with open(self.pathout['pre_rapport'], 'w', encoding='utf8') as f :
         f.write(txt)
 
 
@@ -736,6 +736,7 @@ class dolexlayout :
         self.dictpathout = StatTxtPathOut(parametres['pathout'])
         #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
         self.parent = ira
+        self.corpus.parametres['syscoding'] = 'UTF8'
         self.encoding = self.corpus.parametres['syscoding']
         self.parametres = parametres
         self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding'])
@@ -824,10 +825,10 @@ class StatLayout:
         lcle = {'total' :'total.csv', 'formes_actives':'formes_actives.csv', 'formes_supplémentaires':'formes_supplémentaires.csv', 'hapax': 'hapax.csv'}
         self.result = {}
         for key in lcle :
-            with codecs.open(self.pathout[lcle[key]], 'r', sys.getdefaultencoding()) as f :
+            with open(self.pathout[lcle[key]], 'r', encoding='utf-8') as f :
                 self.result[key] = [line.split(';') for line in f.read().splitlines()]
                 self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])])
-        with open(self.pathout['glob.txt'], 'r') as f :
+        with open(self.pathout['glob.txt'], 'r', encoding='utf-8') as f :
             self.result['glob'] = f.read()
 
 
@@ -1325,7 +1326,7 @@ class SimiLayout(DefaultTextLayout) :
         #saveAsGEXF(graph, filepath = fileout)
         """ % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout)
         filetmp = tempfile.mktemp()
-        with open(filetmp, 'w') as f :
+        with open(filetmp, 'w', encoding='utf8') as f :
             f.write(txt)
         exec_rcode(self.ira.RPath, filetmp)
         mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK)
index 932a2d6..e432d96 100644 (file)
@@ -68,7 +68,7 @@ class ProfileSegment() :
         PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
         """ % (ffr(self.corpus.dictpathout['segments_classes']), ffr(self.dictpathout['prof_seg']), ffr(self.dictpathout['antiprof_seg']))
         fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
-        with open(fo, 'w') as f :
+        with open(fo, 'w', encoding='utf8') as f :
             f.write(txt)
         pid = exec_rcode(self.parent.RPath, fo, wait=False)
         while pid.poll() == None :
@@ -79,7 +79,7 @@ class ProfileSegment() :
     def do_layout(self) :
         SelectTab = self.parent.nb.GetSelection()
         page = self.parent.nb.GetPage(SelectTab).TabChdSim
-        prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding)
+        prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, 'utf8')
         prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
         for i in range(0, len(self.corpus.lc)) :
             ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
@@ -142,7 +142,7 @@ class ProfilType() :
             # write.csv2(to[[3]], file = "%s")
             # % (self.outprof)
         fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
-        with open(fo, 'w') as f :
+        with open(fo, 'w', encoding='utf8') as f :
             f.write(txt)
         pid = exec_rcode(self.parent.RPath, fo, wait=False)
         while pid.poll() == None :
index 4fd031f..6aff98b 100644 (file)
@@ -73,10 +73,7 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
         self.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
         # for wxGTK
         self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
-        self.itemDataMap = dlist
-        self.itemIndexMap = list(dlist.keys())
-        self.SetItemCount(len(dlist))
-        listmix.ColumnSorterMixin.__init__(self, len(first)+2)
+
         #-----------------------------------------------------------
         first = ['id','formes']+first
         for i, name in enumerate(first) :
@@ -84,6 +81,10 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
         self.SetColumnWidth(0, wx.LIST_AUTOSIZE)
         for i in range(1,len(first)-1):
             self.SetColumnWidth(i, 130)
+        self.itemDataMap = dlist
+        self.itemIndexMap = list(dlist.keys())
+        self.SetItemCount(len(dlist))
+        listmix.ColumnSorterMixin.__init__(self, len(first)+2)
         self.SortListItems(0, True)
 
     # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
@@ -115,7 +116,10 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
     def OnGetItemText(self, item, col):
         index=self.itemIndexMap[item]
         s = self.itemDataMap[index][col]
-        return s
+        if isinstance(s, (int,float)):
+            return str(s)
+        else :
+            return s
 
     def OnGetItemData(self, item) :
         index = self.itemIndexMap[item]
index 5dd03a0..bddaa5f 100644 (file)
@@ -38,7 +38,7 @@ class SearchFrame(wx.Frame):
         dlg = wx.ProgressDialog("Traitements", "lecture du tableau...", maximum = 4, parent=self, style = wx.PD_APP_MODAL|wx.PD_AUTO_HIDE|wx.PD_ELAPSED_TIME)
         dlg.Center()
         dlg.Update(1)
-        with codecs.open(corpus.dictpathout['chisqtable'], 'r', parent.SysEncoding) as f :
+        with open(corpus.dictpathout['chisqtable'], 'r', encoding='utf8') as f :
             chisqtable = [line.replace('\n','').replace('"','').replace(',','.').split(';') for line in f]
         first = chisqtable[0]
         first.pop(0)
@@ -49,9 +49,9 @@ class SearchFrame(wx.Frame):
         #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
         #nbactives = len(self.corpus.actives)
         dlg.Update(3)
-        with open(corpus.dictpathout['ContEtOut'], 'r') as f :
+        with open(corpus.dictpathout['ContEtOut'], 'r', encoding='utf8') as f :
             nbetoiles = len(f.readlines())
-        with open(corpus.dictpathout['Contout'], 'r') as f :
+        with open(corpus.dictpathout['Contout'], 'r', encoding='utf8') as f :
             nbactives = len(f.readlines())
         dlg.Update(4, "Ouverture...")
         self.liste = SearchList(self, parent, self.dchisqtable, first, nbactives, nbetoiles) 
index ff1bc49..14f054b 100644 (file)
@@ -148,7 +148,7 @@ class Lexico(AnalyseText) :
         save.image("%s")
         """ % ffr(self.dictpathout['RData'])
         tmpfile = tempfile.mktemp(dir=self.parent.TEMPDIR)
-        tmpscript = open(tmpfile, 'w')
+        tmpscript = open(tmpfile, 'w' ,encoding='utf8')
         tmpscript.write(txt)
         tmpscript.close()
         self.doR(tmpfile, dlg = self.dlg, message = 'R...')
index 2a0ea52..08c9f63 100644 (file)
@@ -59,7 +59,7 @@ class SimiTxt(AnalyseText):
         else :
             order_actives = [[i, act, self.corpus.getlemeff(act)] for i, act in enumerate(self.actives)]
             order_actives = sorted(order_actives, key=itemgetter(2), reverse = True)
-            with open(self.pathout['selected.csv'], 'w') as f :
+            with open(self.pathout['selected.csv'], 'w', encoding='utf8') as f :
                 f.write('\n'.join([repr(order_actives[val][0]) for val in self.parametres['selected']]))
             continu = True
         if continu :
@@ -129,7 +129,7 @@ class SimiTxt(AnalyseText):
         self.parametres['nbactives'] = len(self.actives)
         self.parametres['fromprof'] = False
         self.corpus.make_and_write_sparse_matrix_from_uces(self.actives, self.pathout['mat01.csv'], self.pathout['listeuce1.csv'])
-        with open(self.pathout['actives.csv'], 'w') as f :
+        with open(self.pathout['actives.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join(self.actives))
 
 
@@ -197,9 +197,9 @@ class SimiFromCluster(SimiTxt) :
         self.parametres['nbactives'] = len(self.actives)
         self.parametres['fromprof'] = True
         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 :
+        with open(self.pathout['actives.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join(self.actives))
-        with open(self.pathout['actives_nb.csv'], 'w') as f :
+        with open(self.pathout['actives_nb.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join([repr(val) for val in self.lfreq]))
-        with open(self.pathout['actives_chi.csv'], 'w') as f :
+        with open(self.pathout['actives_chi.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join([repr(val) for val in self.lchi]))
index 1effd2a..56e0942 100755 (executable)
@@ -88,9 +88,9 @@ class Stat(AnalyseText) :
         open_file_graph("%s", width = 400, height = 400)
         barplot(table(stsize[,1]))
         dev.off()
-        """ % (self.pathout['stsize.csv'], self.pathout['segments_size.png'])
+        """ % (ffr(self.pathout['stsize.csv']), ffr(self.pathout['segments_size.png']))
         tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
-        with open(tmpscript, 'w') as f :
+        with open(tmpscript, 'w', encoding='utf8') as f :
             f.write(txt)
         pid = exec_rcode(self.parent.RPath, tmpscript, wait = False)
         while pid.poll() == None :
@@ -104,8 +104,8 @@ class Stat(AnalyseText) :
             if key != 'glob' :
                 dico = self.result[key]
                 toprint = [[dico[val][0],repr(dico[val][1]), dico[val][2]] for val in dico]
-                with open(self.pathout['%s.csv' % key], 'w') as f :
+                with open(self.pathout['%s.csv' % key], 'w',  encoding='utf8') as f :
                     f.write('\n'.join([';'.join([val for val in ligne]) for ligne in toprint]))
             else :
-                with open(self.pathout['%s.txt' % 'glob'], 'w') as f :
+                with open(self.pathout['%s.txt' % 'glob'], 'w',  encoding='utf8') as f :
                     f.write(self.result['glob'])
index d8b6ada..aa669eb 100644 (file)
@@ -95,7 +95,7 @@ class WordCloud(AnalyseText):
 
     def make_wordcloud(self) :
         act = ['\t'.join([act, repr(self.corpus.getlemeff(act))]) for act in self.actives]
-        with open(self.pathout['actives_eff.csv'], 'w') as f :
+        with open(self.pathout['actives_eff.csv'], 'w', encoding='utf8') as f :
             f.write('\n'.join(act))
 
 
@@ -115,7 +115,7 @@ class ClusterCloud(WordCloud):
             else: 
                 tokeep = 2
             prof = [[val[0], int(round(val[tokeep]))] for val in prof]
-            with open(self.pathout['actives_eff.csv'], 'w') as f :
+            with open(self.pathout['actives_eff.csv'], 'w', encoding='utf8') as f :
                 f.write('\n'.join(['\t'.join([val[0], repr(val[1])]) for val in prof]))
             dictcol = dict([[i, val] for i, val in enumerate(prof)])
             self.actives = [val[0] for val in prof]
diff --git a/tree.py b/tree.py
index 70e5d7b..4b61d84 100755 (executable)
--- a/tree.py
+++ b/tree.py
@@ -568,7 +568,7 @@ class LeftTree(CT.CustomTreeCtrl):
                 ucis_txt, ucestxt = doconcorde(corpus, nuces, page.la, uci = uci)
                 items = ['<br>'.join([ucis_txt[j], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table><br>' % ntab2[j][0], ucestxt[j]]) for j, uce in enumerate(nuces)]
                 filename = self.page.pathout['st_caract_cl_%i.html' % (rcl+1)]
-                with open(filename, 'w') as f :
+                with open(filename, 'w', encoding='utf8') as f :
                     f.write('\n'.join(items))
             dlg.Destroy()
 
@@ -598,7 +598,7 @@ class LeftTree(CT.CustomTreeCtrl):
         uci = False
         fileout = os.path.join(os.path.dirname(self.page.pathout['ira']), 'segmented_corpus.txt')
         txt = self.page.corpus.make_cut_corpus(uci = uci)
-        with open(fileout, 'w') as f :
+        with open(fileout, 'w', encoding='utf8') as f :
             f.write(txt)
         msg = '\n'.join([_("Done !"), fileout])
         dlg = wx.MessageDialog(self.parent, msg, _("Segmented corpus"), wx.OK | wx.ICON_INFORMATION)
@@ -619,7 +619,7 @@ class LeftTree(CT.CustomTreeCtrl):
             else :
                 uci = True
             txt = self.page.corpus.make_colored_corpus(uci = uci)
-            with open(fileout, 'w') as f :
+            with open(fileout, 'w', encoding='utf8') as f :
                 f.write(txt)
             msg = ' !\n'.join([_("Done"), _("Open in a web browser ?")])
             dlg = wx.MessageDialog(self.parent, msg, "Corpus en couleur", wx.NO | wx.YES | wx.ICON_QUESTION)
@@ -657,7 +657,7 @@ class LeftTree(CT.CustomTreeCtrl):
                 find = True
                 break
         if not find :
-            open_antiprofil(self.page, self.page.dictpathout['ANTIPRO_OUT'], self.parent.syscoding)
+            open_antiprofil(self.page, self.page.dictpathout['ANTIPRO_OUT'], 'utf8')
             self.page.TabChdSim.SetSelection(self.page.TabChdSim.GetPageCount() - 1)
 
     def OnTranslate(self, evt) :
@@ -687,7 +687,7 @@ class LeftTree(CT.CustomTreeCtrl):
         if res == wx.ID_OK :
             fileout = dial.fbb.GetValue()
             dial.Destroy()
-            with open(fileout, 'w') as f :
+            with open(fileout, 'w', encoding='utf8') as f :
                 f.write(self.page.debtext + '\n' + GetTxtProfile(self.page.DictProfile, self.page.cluster_size))
             msg = "Fini !"
             dlg = wx.MessageDialog(self.parent, msg, _("Report"), wx.OK | wx.ICON_INFORMATION)
@@ -1099,6 +1099,7 @@ class LeftTree(CT.CustomTreeCtrl):
         if event is not None :
             item = event.GetItem()
             pydata = self.GetPyData(item)
+        print('selchange',pydata)
         if pydata is not None :
             if 'corpus_name' in pydata or 'corpus' in pydata :
                 self.ira.ShowMenu('matrix', False)
@@ -1118,8 +1119,11 @@ class LeftTree(CT.CustomTreeCtrl):
                         if self.page.parametres['uuid'] == pydata['uuid'] :
                             self.parent.nb.SetSelection(i)
                             break
-        if event is not None :
-            event.Skip()
+        #self.parent._mgr.Update()
+        #wx.CallAfter(self.parent.nb.SendSizeEvent)
+        self.parent.Refresh()
+        #if event is not None :
+        #    event.Skip()
 
     def OnSelChanging(self, event):
         item = event.GetItem()