2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2012 Pierre Ratinaud
9 from ConfigParser import ConfigParser
10 from subprocess import Popen, call, PIPE
22 from shutil import copyfile
24 #from dialog import BugDialog
27 log = logging.getLogger('iramuteq')
30 indices_simi = [u'cooccurrence' ,'pourcentage de cooccurrence',u'Russel',u'Jaccard', 'Kulczynski1', 'Kulczynski2', 'Mountford', 'Fager', 'simple matching', 'Hamman', 'Faith', 'Tanimoto', 'Dice', 'Phi', 'Stiles', 'Michael', 'Mozley', 'Yule', 'Yule2', 'Ochiai', 'Simpson', 'Braun-Blanquet','Chi-squared', 'Phi-squared', 'Tschuprow', 'Cramer', 'Pearson', 'binomial']
33 def normpath_win32(path) :
34 if not sys.platform == 'win32' :
36 while '\\\\' in path :
37 path = path.replace('\\\\', '\\')
38 if path.startswith('\\') and not path.startswith('\\\\') :
43 def __init__(self, path = None, encoding = 'utf8'):
46 self.encoding = encoding
48 def __getitem__(self, key):
51 def read(self, path = None):
54 with codecs.open(path, 'r', self.encoding) as f :
56 tgen = [line.split('\t') for line in tgen.splitlines()]
57 tgen = dict([[line[0], line[1:]] for line in tgen])
61 def write(self, path = None):
64 with open(path, 'w') as f :
65 f.write('\n'.join(['\t'.join([val] + self.tgen[val]) for val in self.tgen]).encode(self.encoding))
67 def writetable(self, pathout, tgens, totocc):
68 etoiles = totocc.keys()
70 with open(pathout, 'w') as f :
71 line = '\t'.join([u'tgens'] + etoiles) + '\n'
72 f.write(line.encode(self.encoding))
74 line = '\t'.join([t] + [`tgens[t][et]` for et in etoiles]) + '\n'
75 f.write(line.encode(self.encoding))
78 while totname + `i` in tgens :
80 totname = totname + `i`
81 line = '\t'.join([totname] + [`totocc[et]` for et in etoiles]) + '\n'
82 f.write(line.encode(self.encoding))
85 def __init__(self, filein, syscoding = 'utf8') :
87 self.syscoding = syscoding
89 self.openedcorpus = {}
90 self.openedmatrix = {}
98 d = shelve.open(self.filein)
99 self.history = d.get('history', [])
100 self.matrix = d.get('matrix', [])
101 self.ordercorpus = dict([[corpus['uuid'], i] for i, corpus in enumerate(self.history)])
102 self.corpus = dict([[corpus['uuid'], corpus] for corpus in self.history])
103 self.analyses = dict([[analyse['uuid'], analyse] for corpus in self.history for analyse in corpus.get('analyses', [])])
104 self.matrixanalyse = dict([[mat['uuid'], mat] for mat in self.matrix])
105 self.ordermatrix = dict([[matrix['uuid'], i] for i, matrix in enumerate(self.matrix)])
109 d = shelve.open(self.filein)
110 d['history'] = self.history
111 d['matrix'] = self.matrix
114 def add(self, analyse) :
115 log.info('add to history %s' % analyse.get('corpus_name', 'pas un corpus'))
116 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type']}
117 if tosave['uuid'] in self.corpus :
118 log.info('problem : this uuid is already in history : %s' % tosave['uuid'])
120 if analyse.get('corpus', False) :
121 if analyse['uuid'] in self.analyses :
123 tosave['corpus'] = analyse['corpus']
124 tosave['name'] = analyse['name']
125 acorpus_uuid = analyse['corpus']
126 if acorpus_uuid in self.corpus :
127 if 'analyses' in self.history[self.ordercorpus[acorpus_uuid]] :
128 self.history[self.ordercorpus[acorpus_uuid]]['analyses'].append(tosave)
130 self.history[self.ordercorpus[acorpus_uuid]]['analyses'] = [tosave]
132 self.orph.append(tosave)
134 tosave['corpus_name'] = analyse['corpus_name']
135 #self.ordercorpus[tosave['uuid']] = len(history)
136 #self.corpus[tosave['uuid']] = analyse
137 self.history.append(tosave)
141 def addMatrix(self, analyse) :
143 #tosave['matrix_name'] = analyse['matrix_name']
144 tosave['analyses'] = []
145 self.matrix.append(tosave)
149 def addMatrixAnalyse(self, analyse) :
150 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type'], 'matrix' : analyse['matrix']}
151 tosave['name'] = analyse['name']
152 if tosave['matrix'] in self.ordermatrix :
153 self.matrix[self.ordermatrix[tosave['matrix']]]['analyses'].append(tosave)
157 def addmultiple(self, analyses) :
158 log.info('add multiple')
159 for analyse in analyses :
160 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type']}
161 corpus = analyse['corpus']
162 tosave['corpus'] = corpus
163 tosave['name'] = analyse['name']
164 if corpus in self.corpus :
165 if 'analyses' in self.history[self.ordercorpus[corpus]] :
166 self.history[self.ordercorpus[corpus]]['analyses'].append(tosave)
168 self.history[self.ordercorpus[corpus]]['analyses'] = [tosave]
172 def delete(self, analyse, corpus = False) :
173 log.info('delete %s' % analyse.get('name', 'noname'))
175 self.history.pop(self.ordercorpus[analyse['uuid']])
176 if analyse['uuid'] in self.openedcorpus :
177 del self.openedcorpus[analyse['uuid']]
178 log.info('delete corpus : %s' % analyse['uuid'])
179 elif analyse['uuid'] in self.analyses :
180 todel = [i for i, ana in enumerate(self.corpus[analyse['corpus']]['analyses']) if ana['uuid'] == analyse['uuid']][0]
181 self.history[self.ordercorpus[analyse['corpus']]]['analyses'].pop(todel)
182 elif analyse['uuid'] in self.matrixanalyse :
183 self.matrix = [mat for mat in self.matrix if mat['uuid'] != analyse['uuid']]
187 def addtab(self, analyse) :
188 self.opened[analyse['uuid']] = analyse
190 def rmtab(self, analyse) :
191 del self.opened[analyse['uuid']]
193 def update(self, analyse) :
194 if 'matrix_name' in analyse :
195 self.matrixanalyse[analyse['uuid']].update(analyse)
196 elif 'corpus_name' in analyse :
197 self.corpus[analyse['uuid']].update(analyse)
198 elif 'corpus' in analyse :
199 self.analyses[analyse['uuid']].update(analyse)
201 toupdate = [an for an in self.matrixanalyse[analyse['matrix']]['analyses'] if an['uuid'] == analyse['uuid']]
202 toupdate[0].update(analyse)
207 corpustodel = [corpus for corpus in self.history if not os.path.exists(corpus['ira'])]
209 for corpus in corpustodel :
210 print 'cleaning :', corpus['corpus_name']
211 self.delete(corpus, corpus = True)
212 anatodel = [analyse for corpus in self.history for analyse in corpus.get('analyses', []) if not os.path.exists(analyse.get('ira', '/'))]
213 for analyse in anatodel :
214 print 'cleaning :', analyse['name']
218 return str(self.history)
221 def __init__(self, configfile=None, diff = None, parametres = None) :
222 self.configfile = configfile
223 self.conf = ConfigParser()
225 if configfile is not None :
226 configfile = normpath_win32(configfile)
227 self.conf.readfp(codecs.open(configfile, 'r', 'utf8'))
229 if parametres is not None :
230 self.doparametres(parametres)
232 def doparametres(self, parametres) :
235 def getsections(self) :
236 return self.conf.sections()
238 def getoptions(self, section = None, diff = None):
241 section = self.conf.sections()[0]
242 for option in self.conf.options(section) :
243 if self.conf.get(section, option).isdigit() :
244 parametres[option] = int(self.conf.get(section, option))
245 elif self.conf.get(section, option) == 'False' :
246 parametres[option] = False
247 elif self.conf.get(section, option) == 'True' :
248 parametres[option] = True
249 elif self.conf.get(section, option).startswith('(') and self.conf.get(section, option).endswith(')') :
250 parametres[option] = ast.literal_eval(self.conf.get(section, option))
251 elif self.conf.get(section, option).startswith('[') and self.conf.get(section, option).endswith(']') :
252 parametres[option] = ast.literal_eval(self.conf.get(section, option))
254 parametres[option] = self.conf.get(section, option)
255 if 'type' not in parametres :
256 parametres['type'] = section
259 def makeoptions(self, sections, parametres, outfile = None) :
261 for i, section in enumerate(sections) :
262 txt += '[%s]\n' % section
263 if not self.conf.has_section(section) :
264 self.conf.add_section(section)
265 for option in parametres[i] :
266 if isinstance(parametres[i][option], int) :
267 self.conf.set(section, option, `parametres[i][option]`)
268 txt += '%s = %i\n' % (option, parametres[i][option])
269 elif isinstance(parametres[i][option], basestring) :
270 self.conf.set(section, option, parametres[i][option].encode('utf8'))
271 txt += '%s = %s\n' % (option, parametres[i][option])
272 elif isinstance(parametres[i][option], wx.Colour) :
273 self.conf.set(section, option, str(parametres[i][option]))
274 txt += '%s = %s\n' % (option, str(parametres[i][option]))
275 elif option == 'analyses' :
278 self.conf.set(section, option, `parametres[i][option]`)
279 txt += '%s = %s\n' % (option, `parametres[i][option]`)
281 outfile = self.configfile
282 outfile = normpath_win32(outfile)
283 with open(outfile, 'w') as f :
284 f.write(txt.encode('utf8'))
287 def totext(self, parametres) :
290 for val in parametres :
291 if isinstance(parametres[val], int) :
292 txt.append(' \t\t: '.join([val, `parametres[val]`]))
293 elif isinstance(parametres[val], basestring) :
294 txt.append(' \t\t: '.join([val, parametres[val]]))
295 elif val in ['listet', 'stars'] :
298 txt.append(' \t\t: '.join([val, `parametres[val]`]))
299 return '\n'.join(txt)
302 def write_tab(tab, fileout) :
303 writer = csv.writer(open(fileout, 'wb'), delimiter=';', quoting = csv.QUOTE_NONNUMERIC)
304 writer.writerows(tab)
306 class BugDialog(wx.Dialog):
307 def __init__(self, *args, **kwds):
308 # begin wxGlade: MyDialog.__init__
309 kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP
310 kwds["size"] = wx.Size(500, 200)
311 wx.Dialog.__init__(self, *args, **kwds)
312 self.SetTitle(kwds['title'])
313 self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
314 self.text_ctrl_1.SetBackgroundColour('#DDE8EB')
315 self.button_1 = wx.Button(self, wx.ID_OK, "")
317 self.__set_properties()
321 def __set_properties(self):
322 # begin wxGlade: MyDialog.__set_properties
323 self.SetMinSize(wx.Size(500, 200))
324 self.text_ctrl_1.SetMinSize(wx.Size(500, 200))
328 def __do_layout(self):
329 # begin wxGlade: MyDialog.__do_layout
330 sizer_1 = wx.BoxSizer(wx.VERTICAL)
331 sizer_1.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
332 sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
333 self.SetSizer(sizer_1)
338 def CreateIraFile(DictPathOut, clusternb, corpname='corpus_name', section = 'analyse'):
339 AnalyseConf = ConfigParser()
340 AnalyseConf.read(DictPathOut['ira'])
341 AnalyseConf.add_section(section)
342 date = datetime.datetime.now().ctime()
343 AnalyseConf.set(section, 'date', str(date))
344 AnalyseConf.set(section, 'clusternb', clusternb)
345 AnalyseConf.set(section, 'corpus_name', corpname)
347 fileout = open(DictPathOut['ira'], 'w')
348 AnalyseConf.write(fileout)
351 def sortedby(list, direct, *indices):
354 sortedby: sort a list of lists (e.g. a table) by one or more indices
355 (columns of the table) and return the sorted list
358 for list = [[2,3],[1,2],[3,1]]:
359 sortedby(list,1) will return [[3, 1], [1, 2], [2, 3]],
360 sortedby(list,0) will return [[1, 2], [2, 3], [3, 1]]
363 nlist = map(lambda x, indices=indices:
364 map(lambda i, x=x: x[i], indices) + [x],
369 nlist.sort(reverse=True)
370 return map(lambda l: l[-1], nlist)
372 def add_type(line, dictlem):
373 if line[4] in dictlem:
374 line.append(dictlem[line[4]])
379 def treat_line_alceste(i, line) :
380 if line[0] == '*' or line[0] == '*****' :
385 elif float(line[5].replace(',', '.')) < 0.0001:
387 elif float(line[5].replace(',', '.')) > 0.05:
388 line[5] = 'NS (%s)' % str(float(line[5].replace(',', '.')))[0:7]
390 line[5] = str(float(line[5].replace(',', '.')))[0:7]
391 return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]]
393 def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()):
395 print 'lecture des profiles'
396 FileReader = codecs.open(File, 'r', encoding)
397 Filecontent = FileReader.readlines()
401 #rows = [row.replace('\n', '').replace("'", '').replace('\"', '').replace(',', '.').replace('\r','').split(';') for row in Filecontent]
402 rows = [row.replace('\n', '').replace("'", '').replace('\"', '').replace('\r','').split(';') for row in Filecontent]
404 ClusterNb = rows[0][2]
406 clusters = [row[2] for row in rows if row[0] == u'**']
407 valclusters = [row[1:4] for row in rows if row[0] == u'****']
408 lp = [i for i, line in enumerate(rows) if line[0] == u'****']
409 prof = [rows[lp[i] + 1:lp[i+1] - 1] for i in range(0, len(lp)-1)] + [rows[lp[-1] + 1:len(rows)]]
411 prof = [[add_type(row, dictlem) for row in pr] for pr in prof]
412 prof = [[treat_line_alceste(i,line) for i, line in enumerate(pr)] for pr in prof]
414 prof = [[line + [''] for line in pr] for pr in prof]
415 prof = [[treat_line_alceste(i,line) for i, line in enumerate(pr)] for pr in prof]
416 for i, cluster in enumerate(clusters):
417 DictProfile[cluster] = [valclusters[i]] + prof[i]
420 def GetTxtProfile(dictprofile, cluster_size) :
422 for classe in range(0, len(dictprofile)) :
423 prof = dictprofile[str(classe + 1)]
424 clinfo = cluster_size[classe]
425 proflist.append('\n'.join([' '.join(['classe %i' % (classe + 1), '-', '%s uce sur %s - %s%%' % (clinfo[0], clinfo[1], clinfo[2])]), '\n'.join(['%5s|%5s|%6s|%6s|%8s|%8s|%20s\t%10s' % tuple([str(val) for val in line]) for line in prof if len(line)==8])]))
426 return '\n\n'.join(proflist)
428 def formatExceptionInfo(maxTBlevel=5):
429 cla, exc, trbk = sys.exc_info()
431 excName = cla.__name__
435 excArgs = exc.args[0]
437 excArgs = "<no args>"
438 excTb = traceback.format_tb(trbk, maxTBlevel)
439 return (excName, excArgs, excTb)
442 #fonction des etudiants de l'iut
443 def decoupercharact(chaine, longueur, longueurOptimale, separateurs = None) :
445 on part du dernier caractère, et on recule jusqu'au début de la chaîne.
446 Si on trouve un '$', c'est fini.
447 Sinon, on cherche le meilleur candidat. C'est-Ã -dire le rapport poids/distance le plus important.
449 separateurs = [[u'.', 60.0], [u'?', 60.0], [u'!', 60.0], [u'£$£', 60], [u':', 50.0], [u';', 40.0], [u',', 10.0], [u' ', 0.1]]
450 trouve = False # si on a trouvé un bon séparateur
451 iDecoupe = 0 # indice du caractere ou il faut decouper
453 # on découpe la chaine pour avoir au maximum 240 caractères
454 longueur = min(longueur, len(chaine) - 1)
455 chaineTravail = chaine[:longueur + 1]
457 meilleur = ['', 0, 0] # type, poids et position du meilleur separateur
459 # on vérifie si on ne trouve pas un '$'
460 indice = chaineTravail.find(u'$')
465 # si on ne trouve rien, on cherche le meilleur séparateur
468 caractere = chaineTravail[nbCar]
469 distance = abs(longueurOptimale - nbCar) + 1
470 meilleureDistance = abs(longueurOptimale - meilleur[2]) + 1
472 # on vérifie si le caractére courant est une marque de ponctuation
473 for s in separateurs:
474 if caractere == s[0]:
475 # si c'est une ponctuation
477 if s[1] / distance > float(meilleur[1]) / meilleureDistance:
485 # et on termine la recherche
488 # on passe au caractère précédant
493 fin = chaine[iDecoupe + 1:]
494 retour = chaineTravail[:iDecoupe]
495 return len(retour) > 0, retour.split(), fin
496 # si on a rien trouvé
497 return False, chaine.split(), ''
500 exceptions = {'paragrapheOT' : u"Un problème de formatage (présence d'un marqueur de paragraphe (-*) en dehors d'un texte) est survenu à la ligne ",
501 'EmptyText' : u"Texte vide (probablement un problème de formatage du corpus). Le problème est apparu à la ligne ",
502 'CorpusEncoding' : u"Problème d'encodage.",
503 'TextBeforeTextMark' : u"Problème de formatage : du texte avant le premier marqueur de texte (****). Le problème est survenu à la ligne ",
504 'MissingAnalyse' : u'Aucun fichier à cet emplacement :\n',
507 def BugReport(parent, error = None):
508 for ch in parent.GetChildren():
509 if "<class 'wx._windows.ProgressDialog'>" == str(type(ch)):
511 excName, exc, excTb = formatExceptionInfo()
512 if excName == 'Exception' :
514 if len(exc.split()) == 2 :
515 mss, linenb = exc.split()
516 if mss in exceptions :
517 txt = exceptions[mss] + linenb
521 if exc in exceptions :
522 txt = exceptions[exc]
525 title = "Information"
527 txt = u' !== BUG ==! \n'
528 txt += u'*************************************\n'
529 txt += '\n'.join(excTb).replace(' ', ' ')
530 txt += excName + '\n'
534 dial = BugDialog(parent, **{'title' : title})
535 if 'Rerror' in dir(parent) :
539 dial.text_ctrl_1.write(txt)
540 dial.CenterOnParent()
544 def PlaySound(parent):
545 if parent.pref.getboolean('iramuteq', 'sound') :
547 if "gtk2" in wx.PlatformInfo:
548 error = Popen(['aplay','-q',os.path.join(parent.AppliPath,'son_fin.wav')])
550 sound = wx.Sound(os.path.join(parent.AppliPath, 'son_fin.wav'))
551 sound.Play(wx.SOUND_SYNC)
555 def ReadDicoAsDico(dicopath):
556 with codecs.open(dicopath, 'r', 'UTF8') as f:
557 content = f.readlines()
558 lines = [line.rstrip('\n\r').replace(u'\n', '').replace('"', '').split('\t') for line in content if line != u'']
559 return dict([[line[0], line[1:]] for line in lines])
561 def ReadLexique(parent, lang = 'french', filein = None):
564 parent.lexique = ReadDicoAsDico(parent.DictPath.get(lang, 'french'))
566 parent.lexique = ReadDicoAsDico(filein)
571 parent.lexique = ReadDicoAsDico(filein)
573 def ReadList(filein, encoding = sys.getdefaultencoding(), sep = ';'):
575 with codecs.open(filein, 'r', encoding) as f :
577 content = [line.replace('\n', '').replace('\r','').replace('\"', '').replace(',', '.').split(sep) for line in content.splitlines()]
578 #file = codecs.open(filein, 'r', encoding)
579 #content = file.readlines()
581 first = content.pop(0)
582 #first = first.replace('\n', '').replace('\r','').replace('\"', '').split(sep)
586 #line = line.replace('\n', '').replace('\r','').replace('\"', '').replace(',', '.')
587 #line = line.split(';')
596 don = float('%.5f' % float(val))
602 def exec_RCMD(rpath, command) :
603 log.info('R CMD INSTALL %s' % command)
604 rpath = rpath.replace('\\','\\\\')
605 error = call(["%s" % rpath, 'CMD', 'INSTALL', "%s" % command])
608 def exec_rcode(rpath, rcode, wait = True, graph = False):
609 log.info("R Script : %s" % rcode)
611 if sys.platform == 'darwin' :
613 macversion = platform.mac_ver()[0].split('.')
614 if int(macversion[1]) < 5 :
621 rpath = rpath.replace('\\','\\\\')
622 env = os.environ.copy()
623 if sys.platform == 'darwin' and 'LC_ALL' not in env:
624 env['LC_ALL'] = 'en_US.UTF-8'
627 if sys.platform == 'win32':
628 error = call(["%s" % rpath, "--vanilla","--slave","-f", "%s" % rcode])
630 error = call([rpath, '--slave', "--vanilla", "-f %s" % rcode, "--encoding=UTF-8"], env = env)
633 if sys.platform == 'win32':
634 pid = Popen(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
636 pid = Popen([rpath, '--slave', "--vanilla", "-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
640 if sys.platform == 'win32':
641 error = call(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
642 elif sys.platform == 'darwin' and needX11:
643 os.environ['DISPLAY'] = ':0.0'
644 error = call([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], env = env)
646 error = call([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], env = env)
649 if sys.platform == 'win32':
650 pid = Popen(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
651 elif sys.platform == 'darwin' and needX11:
652 os.environ['DISPLAY'] = ':0.0'
653 pid = Popen([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
655 pid = Popen([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
658 def check_Rresult(parent, pid) :
659 if isinstance(pid, Popen) :
660 if pid.returncode != 0 :
661 error = pid.communicate()
662 error = [str(error[0]), error[1]]
663 if error[1] is None :
665 parent.Rerror = '\n'.join([str(pid.returncode), '\n'.join(error)])
667 raise Exception('\n'.join([u'Erreur R', '\n'.join(error[1:])]))
676 raise Exception(u'Erreur R')
683 def print_liste(filename,liste):
684 with open(filename,'w') as f :
686 f.write(';'.join(graph)+'\n')
688 def read_list_file(filename, encoding = sys.getdefaultencoding()):
689 with codecs.open(filename,'rU', encoding) as f :
690 content=f.readlines()
691 ncontent=[line.replace('\n','').split(';') for line in content if line.strip() != '']
697 def progressbar(self, maxi) :
698 ira = wx.GetApp().GetTopWindow()
704 prog = wx.ProgressDialog("Traitements",
705 "Veuillez patienter...",
708 style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT
710 prog.SetSize((400,150))
711 prog.SetIcon(ira._icon)
714 def treat_var_mod(variables) :
716 variables = list(set(variables))
717 varmod = [variable.split('_') for variable in variables]
718 vars = list(set([var[0] for var in varmod if len(var) >=2]))
720 mods = ['_'.join(v) for v in varmod if v[0] == var]
723 # for variable in variables :
724 # if u'_' in variable :
725 # forme = variable.split(u'_')
728 # if not var in var_mod :
729 # var_mod[var] = [variable]
731 # if not mod in var_mod[var] :
732 # var_mod[var].append(variable)
735 def doconcorde(corpus, uces, mots, uci = False) :
737 ucestxt1 = [row for row in corpus.getconcorde(uces)]
739 ucestxt1 = [row for row in corpus.getuciconcorde(uces)]
740 ucestxt1 = dict(ucestxt1)
743 listmot = [corpus.getlems()[lem].formes for lem in mots]
744 listmot = [corpus.getforme(fid).forme for lem in listmot for fid in lem]
745 mothtml = ['<font color=red><b>%s</b></font>' % mot for mot in listmot]
746 dmots = dict(zip(listmot, mothtml))
748 ucetxt = ucestxt1[uce].split()
749 ucetxt = ' '.join([dmots.get(mot, mot) for mot in ucetxt])
751 ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[corpus.getucefromid(uce).uci].etoiles) + '</b></p>')
753 ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[uce].etoiles) + '</b></p>')
754 ucestxt.append(ucetxt)
755 return ucis_txt, ucestxt
758 def getallstcarac(corpus, analyse) :
759 pathout = PathOut(analyse['ira'])
760 profils = ReadProfileAsDico(pathout['PROFILE_OUT'], Alceste, self.encoding)