+
+def doconcorde(corpus, uces, mots, uci = False) :
+ if not uci :
+ ucestxt1 = [row for row in corpus.getconcorde(uces)]
+ else :
+ ucestxt1 = [row for row in corpus.getuciconcorde(uces)]
+ ucestxt1 = dict(ucestxt1)
+ ucestxt = []
+ ucis_txt = []
+ listmot = [corpus.getlems()[lem].formes for lem in mots]
+ listmot = [corpus.getforme(fid).forme for lem in listmot for fid in lem]
+ mothtml = ['<font color=red><b>%s</b></font>' % mot for mot in listmot]
+ dmots = dict(zip(listmot, mothtml))
+ for uce in uces :
+ ucetxt = ucestxt1[uce].split()
+ ucetxt = ' '.join([dmots.get(mot, mot) for mot in ucetxt])
+ if not uci :
+ ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[corpus.getucefromid(uce).uci].etoiles) + '</b></p>')
+ else :
+ ucis_txt.append('<p><b>' + ' '.join(corpus.ucis[uce].etoiles) + '</b></p>')
+ ucestxt.append(ucetxt)
+ return ucis_txt, ucestxt
+
+
+def getallstcarac(corpus, analyse) :
+ pathout = PathOut(analyse['ira'])
+ profils = ReadProfileAsDico(pathout['PROFILE_OUT'], Alceste, self.encoding)
+ print profils
+
+def read_chd(filein, fileout):
+ with open(filein, 'r') as f :
+ content = f.read()
+ #content = [line[3:].replace('"',"").replace(' ','') for line in content.splitlines()]
+ content = [line.split('\t') for line in content.splitlines()]
+ print content
+ chd = {'name':1, 'children':[]}
+ mere={}
+ for i, line in enumerate(content) :
+ if i == 0 :
+ chd['children'] = [{'name': line[1],'size' : content[i+1][0]}, {'name':line[2], 'size': content[i+1][1]}]
+ mere[line[1]] = chd['children'][0]
+ mere[line[2]] = chd['children'][1]
+ elif not i % 2 :
+ if 'children' in mere[line[0]]:
+ mere[line[0]]['children'].append({'name': line[1],'size' : content[i+1][0]})
+ mere[line[1]] = mere[line[0]]['children'][-1]
+ mere[line[0]]['children'].append({'name': line[2],'size' : content[i+1][1]})
+ mere[line[2]] = mere[line[0]]['children'][-1]
+ else :
+ mere[line[0]]['children'] = [{'name': line[1],'size' : content[i+1][0]}, {'name':line[2], 'size': content[i+1][1]}]
+ mere[line[1]] = mere[line[0]]['children'][-2]
+ mere[line[2]] = mere[line[0]]['children'][-1]
+ with open(fileout, 'w') as f :
+ f.write(json.dumps(chd))
+
\ No newline at end of file