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 {
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
}
}
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'] :
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
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
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/
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;')
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')
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) :
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 :
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 :
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) :
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 :
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) :
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 :
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()
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) :
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) :
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]
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]))
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()
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 )
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 )
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):
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))
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 :
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)
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):
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()
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 = {}
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])
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)
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
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):
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 :
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) :
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 :
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]))
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()
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)])
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
def flush(self):
pass
-sys.stderr = writer()
-sys.stdout = printer()
+#sys.stderr = writer()
+#sys.stdout = printer()
images_analyses = {
'textroot' : 'textroot.png',
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:
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
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):
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):
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()
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_)
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 :
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 :
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)
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)
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'])
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()
#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)
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 :
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)
# 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 :
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) :
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
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]
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)
#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)
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...')
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 :
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))
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]))
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 :
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'])
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))
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]
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()
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)
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)
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) :
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)
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)
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()