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']
34 def open_folder(folder):
35 if sys.platform == "win32":
38 opener ="open" if sys.platform == "darwin" else "xdg-open"
39 call([opener, folder])
41 def normpath_win32(path) :
42 if not sys.platform == 'win32' :
44 while '\\\\' in path :
45 path = path.replace('\\\\', '\\')
46 if path.startswith('\\') and not path.startswith('\\\\') :
51 def __init__(self, path = None, encoding = 'utf8'):
54 self.encoding = encoding
56 def __getitem__(self, key):
59 def read(self, path = None):
62 with codecs.open(path, 'r', self.encoding) as f :
64 tgen = [line.split('\t') for line in tgen.splitlines()]
65 tgen = dict([[line[0], line[1:]] for line in tgen])
69 def write(self, path = None):
72 with open(path, 'w') as f :
73 f.write('\n'.join(['\t'.join([val] + self.tgen[val]) for val in self.tgen]).encode(self.encoding))
75 def writetable(self, pathout, tgens, totocc):
76 etoiles = totocc.keys()
78 with open(pathout, 'w') as f :
79 line = '\t'.join([u'tgens'] + etoiles) + '\n'
80 f.write(line.encode(self.encoding))
82 line = '\t'.join([t] + [`tgens[t][et]` for et in etoiles]) + '\n'
83 f.write(line.encode(self.encoding))
86 while totname + `i` in tgens :
88 totname = totname + `i`
89 line = '\t'.join([totname] + [`totocc[et]` for et in etoiles]) + '\n'
90 f.write(line.encode(self.encoding))
93 def __init__(self, filein, syscoding = 'utf8') :
95 self.syscoding = syscoding
97 self.openedcorpus = {}
98 self.openedmatrix = {}
106 d = shelve.open(self.filein)
107 self.history = d.get('history', [])
108 self.matrix = d.get('matrix', [])
109 self.ordercorpus = dict([[corpus['uuid'], i] for i, corpus in enumerate(self.history)])
110 self.corpus = dict([[corpus['uuid'], corpus] for corpus in self.history])
111 self.analyses = dict([[analyse['uuid'], analyse] for corpus in self.history for analyse in corpus.get('analyses', [])])
112 self.matrixanalyse = dict([[mat['uuid'], mat] for mat in self.matrix])
113 self.ordermatrix = dict([[matrix['uuid'], i] for i, matrix in enumerate(self.matrix)])
117 d = shelve.open(self.filein)
118 d['history'] = self.history
119 d['matrix'] = self.matrix
122 def add(self, analyse) :
123 log.info('add to history %s' % analyse.get('corpus_name', 'pas un corpus'))
124 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type']}
125 if tosave['uuid'] in self.corpus :
126 log.info('problem : this uuid is already in history : %s' % tosave['uuid'])
128 if analyse.get('corpus', False) :
129 if analyse['uuid'] in self.analyses :
131 tosave['corpus'] = analyse['corpus']
132 tosave['name'] = analyse['name']
133 acorpus_uuid = analyse['corpus']
134 if acorpus_uuid in self.corpus :
135 if 'analyses' in self.history[self.ordercorpus[acorpus_uuid]] :
136 self.history[self.ordercorpus[acorpus_uuid]]['analyses'].append(tosave)
138 self.history[self.ordercorpus[acorpus_uuid]]['analyses'] = [tosave]
140 self.orph.append(tosave)
142 tosave['corpus_name'] = analyse['corpus_name']
143 #self.ordercorpus[tosave['uuid']] = len(history)
144 #self.corpus[tosave['uuid']] = analyse
145 self.history.append(tosave)
149 def addMatrix(self, analyse) :
151 #tosave['matrix_name'] = analyse['matrix_name']
152 tosave['analyses'] = []
153 self.matrix.append(tosave)
157 def addMatrixAnalyse(self, analyse) :
158 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type'], 'matrix' : analyse['matrix']}
159 tosave['name'] = analyse['name']
160 if tosave['matrix'] in self.ordermatrix :
161 self.matrix[self.ordermatrix[tosave['matrix']]]['analyses'].append(tosave)
165 def addmultiple(self, analyses) :
166 log.info('add multiple')
167 for analyse in analyses :
168 tosave = {'uuid' : analyse['uuid'], 'ira': analyse['ira'], 'type' : analyse['type']}
169 corpus = analyse['corpus']
170 tosave['corpus'] = corpus
171 tosave['name'] = analyse['name']
172 if corpus in self.corpus :
173 if 'analyses' in self.history[self.ordercorpus[corpus]] :
174 self.history[self.ordercorpus[corpus]]['analyses'].append(tosave)
176 self.history[self.ordercorpus[corpus]]['analyses'] = [tosave]
180 def delete(self, analyse, corpus = False) :
181 log.info('delete %s' % analyse.get('name', 'noname'))
183 self.history.pop(self.ordercorpus[analyse['uuid']])
184 if analyse['uuid'] in self.openedcorpus :
185 del self.openedcorpus[analyse['uuid']]
186 log.info('delete corpus : %s' % analyse['uuid'])
187 elif analyse['uuid'] in self.analyses :
188 todel = [i for i, ana in enumerate(self.corpus[analyse['corpus']]['analyses']) if ana['uuid'] == analyse['uuid']][0]
189 self.history[self.ordercorpus[analyse['corpus']]]['analyses'].pop(todel)
190 elif analyse['uuid'] in self.matrixanalyse :
191 self.matrix = [mat for mat in self.matrix if mat['uuid'] != analyse['uuid']]
195 def addtab(self, analyse) :
196 self.opened[analyse['uuid']] = analyse
198 def rmtab(self, analyse) :
199 del self.opened[analyse['uuid']]
201 def update(self, analyse) :
202 if 'matrix_name' in analyse :
203 self.matrixanalyse[analyse['uuid']].update(analyse)
204 elif 'corpus_name' in analyse :
205 self.corpus[analyse['uuid']].update(analyse)
206 elif 'corpus' in analyse :
207 self.analyses[analyse['uuid']].update(analyse)
209 toupdate = [an for an in self.matrixanalyse[analyse['matrix']]['analyses'] if an['uuid'] == analyse['uuid']]
210 toupdate[0].update(analyse)
215 corpustodel = [corpus for corpus in self.history if not os.path.exists(corpus['ira'])]
217 for corpus in corpustodel :
218 print 'cleaning :', corpus['corpus_name']
219 self.delete(corpus, corpus = True)
220 anatodel = [analyse for corpus in self.history for analyse in corpus.get('analyses', []) if not os.path.exists(analyse.get('ira', '/'))]
221 for analyse in anatodel :
222 print 'cleaning :', analyse['name']
226 return str(self.history)
229 def __init__(self, configfile=None, diff = None, parametres = None) :
230 self.configfile = configfile
231 self.conf = ConfigParser()
233 if configfile is not None :
234 configfile = normpath_win32(configfile)
235 self.conf.readfp(codecs.open(configfile, 'r', 'utf8'))
237 if parametres is not None :
238 self.doparametres(parametres)
240 def doparametres(self, parametres) :
243 def getsections(self) :
244 return self.conf.sections()
246 def getoptions(self, section = None, diff = None):
249 section = self.conf.sections()[0]
250 for option in self.conf.options(section) :
251 if self.conf.get(section, option).isdigit() :
252 parametres[option] = int(self.conf.get(section, option))
253 elif self.conf.get(section, option) == 'False' :
254 parametres[option] = False
255 elif self.conf.get(section, option) == 'True' :
256 parametres[option] = True
257 elif self.conf.get(section, option).startswith('(') and self.conf.get(section, option).endswith(')') :
258 parametres[option] = ast.literal_eval(self.conf.get(section, option))
259 elif self.conf.get(section, option).startswith('[') and self.conf.get(section, option).endswith(']') :
260 parametres[option] = ast.literal_eval(self.conf.get(section, option))
262 parametres[option] = self.conf.get(section, option)
263 if 'type' not in parametres :
264 parametres['type'] = section
267 def makeoptions(self, sections, parametres, outfile = None) :
269 for i, section in enumerate(sections) :
270 txt += '[%s]\n' % section
271 if not self.conf.has_section(section) :
272 self.conf.add_section(section)
273 for option in parametres[i] :
274 if isinstance(parametres[i][option], int) :
275 self.conf.set(section, option, `parametres[i][option]`)
276 txt += '%s = %i\n' % (option, parametres[i][option])
277 elif isinstance(parametres[i][option], basestring) :
278 self.conf.set(section, option, parametres[i][option].encode('utf8'))
279 txt += '%s = %s\n' % (option, parametres[i][option])
280 elif isinstance(parametres[i][option], wx.Colour) :
281 self.conf.set(section, option, str(parametres[i][option]))
282 txt += '%s = %s\n' % (option, str(parametres[i][option]))
283 elif option == 'analyses' :
286 self.conf.set(section, option, `parametres[i][option]`)
287 txt += '%s = %s\n' % (option, `parametres[i][option]`)
289 outfile = self.configfile
290 outfile = normpath_win32(outfile)
291 with open(outfile, 'w') as f :
292 f.write(txt.encode('utf8'))
295 def totext(self, parametres) :
298 for val in parametres :
299 if isinstance(parametres[val], int) :
300 txt.append(' \t\t: '.join([val, `parametres[val]`]))
301 elif isinstance(parametres[val], basestring) :
302 txt.append(' \t\t: '.join([val, parametres[val]]))
303 elif val in ['listet', 'stars'] :
306 txt.append(' \t\t: '.join([val, `parametres[val]`]))
307 return '\n'.join(txt)
310 def write_tab(tab, fileout) :
311 writer = csv.writer(open(fileout, 'wb'), delimiter=';', quoting = csv.QUOTE_NONNUMERIC)
312 writer.writerows(tab)
314 class BugDialog(wx.Dialog):
315 def __init__(self, *args, **kwds):
316 # begin wxGlade: MyDialog.__init__
317 kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP
318 kwds["size"] = wx.Size(500, 200)
319 wx.Dialog.__init__(self, *args, **kwds)
320 self.SetTitle(kwds['title'])
321 self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
322 self.text_ctrl_1.SetBackgroundColour('#DDE8EB')
323 self.button_1 = wx.Button(self, wx.ID_OK, "")
325 self.__set_properties()
329 def __set_properties(self):
330 # begin wxGlade: MyDialog.__set_properties
331 self.SetMinSize(wx.Size(500, 200))
332 self.text_ctrl_1.SetMinSize(wx.Size(500, 200))
336 def __do_layout(self):
337 # begin wxGlade: MyDialog.__do_layout
338 sizer_1 = wx.BoxSizer(wx.VERTICAL)
339 sizer_1.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
340 sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
341 self.SetSizer(sizer_1)
346 def CreateIraFile(DictPathOut, clusternb, corpname='corpus_name', section = 'analyse'):
347 AnalyseConf = ConfigParser()
348 AnalyseConf.read(DictPathOut['ira'])
349 AnalyseConf.add_section(section)
350 date = datetime.datetime.now().ctime()
351 AnalyseConf.set(section, 'date', str(date))
352 AnalyseConf.set(section, 'clusternb', clusternb)
353 AnalyseConf.set(section, 'corpus_name', corpname)
355 fileout = open(DictPathOut['ira'], 'w')
356 AnalyseConf.write(fileout)
359 def sortedby(list, direct, *indices):
362 sortedby: sort a list of lists (e.g. a table) by one or more indices
363 (columns of the table) and return the sorted list
366 for list = [[2,3],[1,2],[3,1]]:
367 sortedby(list,1) will return [[3, 1], [1, 2], [2, 3]],
368 sortedby(list,0) will return [[1, 2], [2, 3], [3, 1]]
371 nlist = map(lambda x, indices=indices:
372 map(lambda i, x=x: x[i], indices) + [x],
377 nlist.sort(reverse=True)
378 return map(lambda l: l[-1], nlist)
380 def add_type(line, dictlem):
381 if line[4] in dictlem:
382 line.append(dictlem[line[4]])
387 def treat_line_alceste(i, line) :
388 if line[0] == '*' or line[0] == '*****' :
393 elif float(line[5].replace(',', '.')) < 0.0001:
395 elif float(line[5].replace(',', '.')) > 0.05:
396 line[5] = 'NS (%s)' % str(float(line[5].replace(',', '.')))[0:7]
398 line[5] = str(float(line[5].replace(',', '.')))[0:7]
399 return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]]
401 def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()):
403 print 'lecture des profiles'
404 FileReader = codecs.open(File, 'r', encoding)
405 Filecontent = FileReader.readlines()
409 #rows = [row.replace('\n', '').replace("'", '').replace('\"', '').replace(',', '.').replace('\r','').split(';') for row in Filecontent]
410 rows = [row.replace('\n', '').replace("'", '').replace('\"', '').replace('\r','').split(';') for row in Filecontent]
412 ClusterNb = rows[0][2]
414 clusters = [row[2] for row in rows if row[0] == u'**']
415 valclusters = [row[1:4] for row in rows if row[0] == u'****']
416 lp = [i for i, line in enumerate(rows) if line[0] == u'****']
417 prof = [rows[lp[i] + 1:lp[i+1] - 1] for i in range(0, len(lp)-1)] + [rows[lp[-1] + 1:len(rows)]]
419 prof = [[add_type(row, dictlem) for row in pr] for pr in prof]
420 prof = [[treat_line_alceste(i,line) for i, line in enumerate(pr)] for pr in prof]
422 prof = [[line + [''] for line in pr] for pr in prof]
423 prof = [[treat_line_alceste(i,line) for i, line in enumerate(pr)] for pr in prof]
424 for i, cluster in enumerate(clusters):
425 DictProfile[cluster] = [valclusters[i]] + prof[i]
428 def GetTxtProfile(dictprofile, cluster_size) :
430 for classe in range(0, len(dictprofile)) :
431 prof = dictprofile[str(classe + 1)]
432 clinfo = cluster_size[classe]
433 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])]))
434 return '\n\n'.join(proflist)
436 def formatExceptionInfo(maxTBlevel=5):
437 cla, exc, trbk = sys.exc_info()
439 excName = cla.__name__
443 excArgs = exc.args[0]
445 excArgs = "<no args>"
446 excTb = traceback.format_tb(trbk, maxTBlevel)
447 return (excName, excArgs, excTb)
450 #fonction des etudiants de l'iut
451 def decoupercharact(chaine, longueur, longueurOptimale, separateurs = None) :
453 on part du dernier caractère, et on recule jusqu'au début de la chaîne.
454 Si on trouve un '$', c'est fini.
455 Sinon, on cherche le meilleur candidat. C'est-Ã -dire le rapport poids/distance le plus important.
457 separateurs = [[u'.', 60.0], [u'?', 60.0], [u'!', 60.0], [u'£$£', 60], [u':', 50.0], [u';', 40.0], [u',', 10.0], [u' ', 0.1]]
458 trouve = False # si on a trouvé un bon séparateur
459 iDecoupe = 0 # indice du caractere ou il faut decouper
461 # on découpe la chaine pour avoir au maximum 240 caractères
462 longueur = min(longueur, len(chaine) - 1)
463 chaineTravail = chaine[:longueur + 1]
465 meilleur = ['', 0, 0] # type, poids et position du meilleur separateur
467 # on vérifie si on ne trouve pas un '$'
468 indice = chaineTravail.find(u'$')
473 # si on ne trouve rien, on cherche le meilleur séparateur
476 caractere = chaineTravail[nbCar]
477 distance = abs(longueurOptimale - nbCar) + 1
478 meilleureDistance = abs(longueurOptimale - meilleur[2]) + 1
480 # on vérifie si le caractére courant est une marque de ponctuation
481 for s in separateurs:
482 if caractere == s[0]:
483 # si c'est une ponctuation
485 if s[1] / distance > float(meilleur[1]) / meilleureDistance:
493 # et on termine la recherche
496 # on passe au caractère précédant
501 fin = chaine[iDecoupe + 1:]
502 retour = chaineTravail[:iDecoupe]
503 return len(retour) > 0, retour.split(), fin
504 # si on a rien trouvé
505 return False, chaine.split(), ''
508 exceptions = {'paragrapheOT' : u"Un problème de formatage (présence d'un marqueur de paragraphe (-*) en dehors d'un texte) est survenu à la ligne ",
509 'EmptyText' : u"Texte vide (probablement un problème de formatage du corpus). Le problème est apparu à la ligne ",
510 'CorpusEncoding' : u"Problème d'encodage.",
511 'TextBeforeTextMark' : u"Problème de formatage : du texte avant le premier marqueur de texte (****). Le problème est survenu à la ligne ",
512 'MissingAnalyse' : u'Aucun fichier à cet emplacement :\n',
515 def BugReport(parent, error = None):
516 for ch in parent.GetChildren():
517 if "<class 'wx._windows.ProgressDialog'>" == str(type(ch)):
519 excName, exc, excTb = formatExceptionInfo()
520 if excName == 'Exception' :
522 if len(exc.split()) == 2 :
523 mss, linenb = exc.split()
524 if mss in exceptions :
525 txt = exceptions[mss] + linenb
529 if exc in exceptions :
530 txt = exceptions[exc]
533 title = "Information"
535 txt = u' !== BUG ==! \n'
536 txt += u'*************************************\n'
537 txt += '\n'.join(excTb).replace(' ', ' ')
538 txt += excName + '\n'
542 dial = BugDialog(parent, **{'title' : title})
543 if 'Rerror' in dir(parent) :
547 dial.text_ctrl_1.write(txt)
548 dial.CenterOnParent()
552 def PlaySound(parent):
553 if parent.pref.getboolean('iramuteq', 'sound') :
555 if "gtk2" in wx.PlatformInfo:
556 error = Popen(['aplay','-q',os.path.join(parent.AppliPath,'son_fin.wav')])
558 sound = wx.Sound(os.path.join(parent.AppliPath, 'son_fin.wav'))
559 sound.Play(wx.SOUND_SYNC)
563 def ReadDicoAsDico(dicopath):
564 with codecs.open(dicopath, 'r', 'UTF8') as f:
565 content = f.readlines()
566 lines = [line.rstrip('\n\r').replace(u'\n', '').replace('"', '').split('\t') for line in content if line != u'']
567 return dict([[line[0], line[1:]] for line in lines])
569 def ReadLexique(parent, lang = 'french', filein = None):
572 parent.lexique = ReadDicoAsDico(parent.DictPath.get(lang, 'french'))
574 parent.lexique = ReadDicoAsDico(filein)
579 parent.lexique = ReadDicoAsDico(filein)
581 def ReadList(filein, encoding = sys.getdefaultencoding(), sep = ';'):
583 with codecs.open(filein, 'r', encoding) as f :
585 content = [line.replace('\n', '').replace('\r','').replace('\"', '').replace(',', '.').split(sep) for line in content.splitlines()]
586 #file = codecs.open(filein, 'r', encoding)
587 #content = file.readlines()
589 first = content.pop(0)
590 #first = first.replace('\n', '').replace('\r','').replace('\"', '').split(sep)
594 #line = line.replace('\n', '').replace('\r','').replace('\"', '').replace(',', '.')
595 #line = line.split(';')
604 don = float('%.5f' % float(val))
610 def exec_RCMD(rpath, command) :
611 log.info('R CMD INSTALL %s' % command)
612 rpath = rpath.replace('\\','\\\\')
613 error = call(["%s" % rpath, 'CMD', 'INSTALL', "%s" % command])
616 def exec_rcode(rpath, rcode, wait = True, graph = False):
617 log.info("R Script : %s" % rcode)
619 if sys.platform == 'darwin' :
621 macversion = platform.mac_ver()[0].split('.')
622 if int(macversion[1]) < 5 :
629 rpath = rpath.replace('\\','\\\\')
630 env = os.environ.copy()
631 if sys.platform == 'darwin' and 'LC_ALL' not in env:
632 env['LC_ALL'] = 'en_US.UTF-8'
635 if sys.platform == 'win32':
636 error = call(["%s" % rpath, "--vanilla","--slave","-f", "%s" % rcode])
638 error = call([rpath, '--slave', "--vanilla", "-f %s" % rcode, "--encoding=UTF-8"], env = env)
641 if sys.platform == 'win32':
642 pid = Popen(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
644 pid = Popen([rpath, '--slave', "--vanilla", "-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
648 if sys.platform == 'win32':
649 error = call(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
650 elif sys.platform == 'darwin' and needX11:
651 os.environ['DISPLAY'] = ':0.0'
652 error = call([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], env = env)
654 error = call([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], env = env)
657 if sys.platform == 'win32':
658 pid = Popen(["%s" % rpath, '--vanilla','--slave','-f', "%s" % rcode])
659 elif sys.platform == 'darwin' and needX11:
660 os.environ['DISPLAY'] = ':0.0'
661 pid = Popen([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
663 pid = Popen([rpath, '--vanilla','--slave',"-f %s" % rcode, "--encoding=UTF-8"], stderr = PIPE, env = env)
666 def check_Rresult(parent, pid) :
667 if isinstance(pid, Popen) :
668 if pid.returncode != 0 :
669 error = pid.communicate()
670 error = [str(error[0]), error[1]]
671 if error[1] is None :
673 parent.Rerror = '\n'.join([str(pid.returncode), '\n'.join(error)])
675 raise Exception('\n'.join([u'Erreur R', '\n'.join(error[1:])]))
684 raise Exception(u'Erreur R')
691 def print_liste(filename,liste):
692 with open(filename,'w') as f :
694 f.write(';'.join(graph)+'\n')
696 def read_list_file(filename, encoding = sys.getdefaultencoding()):
697 with codecs.open(filename,'rU', encoding) as f :
698 content=f.readlines()
699 ncontent=[line.replace('\n','').split(';') for line in content if line.strip() != '']
705 def progressbar(self, maxi) :
706 ira = wx.GetApp().GetTopWindow()
712 prog = wx.ProgressDialog("Traitements",
713 "Veuillez patienter...",
716 style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT
718 prog.SetSize((400,150))
719 prog.SetIcon(ira._icon)
722 def treat_var_mod(variables) :
724 variables = list(set(variables))
725 varmod = [variable.split('_') for variable in variables]
726 vars = list(set([var[0] for var in varmod if len(var) >=2]))
728 mods = ['_'.join(v) for v in varmod if v[0] == var]
731 # for variable in variables :
732 # if u'_' in variable :
733 # forme = variable.split(u'_')
736 # if not var in var_mod :
737 # var_mod[var] = [variable]
739 # if not mod in var_mod[var] :
740 # var_mod[var].append(variable)
743 def doconcorde(corpus, uces, mots, uci = False) :
745 ucestxt1 = [row for row in corpus.getconcorde(uces)]
747 ucestxt1 = [row for row in corpus.getuciconcorde(uces)]
748 ucestxt1 = dict(ucestxt1)
751 listmot = [corpus.getlems()[lem].formes for lem in mots]
752 listmot = [corpus.getforme(fid).forme for lem in listmot for fid in lem]
753 mothtml = ['<font color=red><b>%s</b></font>' % mot for mot in listmot]
754 dmots = dict(zip(listmot, mothtml))
756 ucetxt = ucestxt1[uce].split()
757 ucetxt = ' '.join([dmots.get(mot, mot) for mot in ucetxt])
759 ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[corpus.getucefromid(uce).uci].etoiles) + '</b></p>')
761 ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[uce].etoiles) + '</b></p>')
762 ucestxt.append(ucetxt)
763 return ucis_txt, ucestxt
766 def getallstcarac(corpus, analyse) :
767 pathout = PathOut(analyse['ira'])
768 profils = ReadProfileAsDico(pathout['PROFILE_OUT'], Alceste, self.encoding)