3 #path = '/home/pierre/workspace/iramuteq'
6 from functions import DoConf, read_chd, ReadProfileAsDico
7 #from export_html import DoHTML
8 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
9 from layout import SimiLayout
10 from textsimi import *
11 from analyse_merge import AnalyseMerge
13 #corpusin = '/home/pierre/fac/lerass/formation_iramuteq/giletsjaunes-2018-12-01/giletsjaunes-2018-12-01_corpus_1/Corpus.cira'
14 #corpusin = "/home/pierre/fac/lerass/giletsjaunes/corpus_vrdb_vi_ss_et_corpus_1/Corpus.cira"
15 #corpusin ="/home/pierre/fac/lerass/giletsjaunes/corpus_vrdb_vi_ss_et_pascal/Corpus.cira"
16 #corpusin = '/home/pierre/fac/lerass/granddebat/20190321-LE-GRAND-DEBAT_corpus_1/Corpus.cira'
17 #corpusin ='/home/pierre/fac/etudiant/grumet/M2/Corpus_focus_GRUMET_corpus_2/Corpus.cira'
19 #cmd = iracmd.CmdLine(args=['-r',corpusin], AppliPath = path)
21 #analysein = "/home/pierre/fac/lerass/formation_iramuteq/giletsjaunes-2018-12-01/giletsjaunes-2018-12-01_corpus_1/giletsjaunes-2018-12-01_alceste_2/Analyse.ira"
22 #analysein = "/home/pierre/fac/lerass/giletsjaunes/corpus_vrdb_vi_ss_et_corpus_1/corpus_vrdb_vi_ss_et_alceste_1/Analyse.ira"
23 #analysein ="/home/pierre/fac/lerass/giletsjaunes/corpus_vrdb_vi_ss_et_pascal/corpus_vrdb_vi_ss_et_alceste_1/Analyse.ira"
24 #analysein = "/home/pierre/fac/lerass/granddebat/20190321-LE-GRAND-DEBAT_corpus_1/20190321-LE-GRAND-DEBAT_alceste_1/Analyse.ira"
25 #analysein = "/home/pierre/fac/etudiant/grumet/M2/Corpus_focus_GRUMET_corpus_2/Corpus_focus_GRUMET[5682]_alceste_3/Analyse.ira"
26 #parametres = DoConf(analysein).getoptions()
28 #actives = cmd.corpus.make_actives_nb(10000, 1)[0]
29 #actives = dict(zip(actives,actives))
34 class MergeClusterGraph :
35 def __init__(self, ira, corpus, parametres) :
38 self.parametres = parametres
39 self.pathout = PathOut(parametres['ira'])
40 self.pathout.basefiles(ChdTxtPathOut)
41 self.corpus.make_ucecl_from_R(self.pathout['uce'])
42 self.encoding = self.parametres['encoding']
43 self.clnb = parametres['clnb']
44 dictprofile = ReadProfileAsDico(self.pathout['PROFILE_OUT'], True, self.encoding)
45 self.dograph(dictprofile)
47 def dograph(self, dictprofile) :
49 #OUTCH!!First cluster removed !!
50 #print 'ELMINATION CLUSTER 1'
51 for i in range(0, self.clnb):
52 self.pathout = PathOut(self.parametres['ira'])
53 simiparam = DoConf(self.ira.ConfigPath['simitxt']).getoptions()
54 simiparam['coeff'] = 3
55 simiparam['cexfromchi'] = True
56 profclasse = dictprofile[`i+1`]
57 line1 = profclasse.pop(0)
58 classen = [line for line in profclasse if line[0] != '*' and line[0] != '*****']
60 self.lenact = profclasse.index([u'*****', u'*', u'*', u'*', u'*', u'*', '', ''])
61 profclasse.pop(self.lenact)
64 self.lenact = profclasse.index([u'*', u'*', u'*', u'*', u'*', u'*', '', ''])
65 profclasse.pop(self.lenact)
67 self.lenact = len(profclasse)
69 self.lensup = profclasse.index([u'*', u'*', u'*', u'*', u'*', u'*', '', ''])
70 self.lensup = self.lensup - self.lenact
71 profclasse.pop(self.lensup)
73 self.lensup = len(profclasse) - self.lenact
74 self.lenet = len(profclasse) - (self.lenact + self.lensup)
75 # print self.lenact, self.lensup, self.lenet
76 for l, line in enumerate(classen) :
78 dictdata = dict(zip([l for l in range(0,len(classen))], classen))
81 self.la = [dictdata[l][6] for l in range(0, self.lenact)]
82 self.lchi = [dictdata[l][4] for l in range(0, self.lenact)]
83 self.lfreq = [dictdata[l][1] for l in range(0, self.lenact)]
89 simi = SimiFromCluster(self.ira, self.corpus, self.la, self.lfreq,
90 self.lchi, i, parametres = simiparam, limit=100)
91 tomerge.append(simi.parametres['ira'])
93 newparam = {'type': 'merge', 'fileout' : '/tmp/test.txt'}
94 newparam['graphs'] = tomerge
95 AnalyseMerge(self.ira, newparam, dlg=None)
98 #MergeClusterGraph(cmd, cmd.corpus, parametres)