X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=analysetxt.py;h=544362c4234fb9a5862b9b9e51a163b894aa253d;hp=3edf0a914c3bbbeabd161075d0a5883ee2e52feb;hb=7539792168d42f09763ab021a9e0e0f8afa3bf07;hpb=d1d24d86422c9e9805516190ea17a379201f9300 diff --git a/analysetxt.py b/analysetxt.py index 3edf0a9..544362c 100644 --- a/analysetxt.py +++ b/analysetxt.py @@ -13,32 +13,34 @@ from PrintRScript import RchdTxt, AlcesteTxtProf from OptionAlceste import OptionAlc from layout import PrintRapport from openanalyse import OpenAnalyse +from dialog import StatDialog from time import time log = logging.getLogger('iramuteq.analyse') class AnalyseText : - def __init__(self, ira, corpus, parametres = None, dlg = False) : + def __init__(self, ira, corpus, parametres = None, dlg = False, lemdial = True) : self.corpus = corpus self.ira = ira self.parent = ira self.dlg = dlg self.dialok = True self.parametres = parametres + self.lemdial = lemdial self.val = False + self.keys = DoConf(self.ira.ConfigPath['key']).getoptions() if not 'pathout' in self.parametres : self.pathout = PathOut(corpus.parametres['originalpath'], analyse_type = parametres['type'], dirout = corpus.parametres['pathout']) else : - self.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['name']) - self.parametres = self.make_config(parametres) + self.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['type']) + self.parametres = self.lemparam() + if self.parametres is not None : + self.parametres = self.make_config(parametres) log.info(self.pathout.dirout) if self.parametres is not None : self.keys = DoConf(self.ira.ConfigPath['key']).getoptions() - gramact = [k for k in keys if keys[k] == 1] - gramsup = [k for k in keys if keys[k] == 2] - #FIXME - if not 'lem' in self.parametres : - self.parametres['lem'] = 1 + gramact = [k for k in self.keys if self.keys[k] == 1] + gramsup = [k for k in self.keys if self.keys[k] == 2] self.parametres['pathout'] = self.pathout.mkdirout() self.pathout = PathOut(dirout = self.parametres['pathout']) self.pathout.createdir(self.parametres['pathout']) @@ -49,7 +51,7 @@ class AnalyseText : self.parametres['encoding'] = self.ira.syscoding self.t1 = time() self.corpus.make_lems(lem = self.parametres['lem']) - corpus.parse_active(gramact, gramsup) + self.corpus.parse_active(gramact, gramsup) result_analyse = self.doanalyse() if result_analyse is None : self.time = time() - self.t1 @@ -76,18 +78,39 @@ class AnalyseText : def doanalyse(self) : pass + def lemparam(self) : + if self.dlg and self.lemdial: + dial = StatDialog(self, self.parent) + dial.CenterOnParent() + val = dial.ShowModal() + if val == 5100 : + if dial.radio_lem.GetSelection() == 0 : + lem = 1 + else : + lem = 0 + self.parametres['lem'] = lem + dial.Destroy() + return self.parametres + else : + dial.Destroy() + return None + else : + return self.parametres + def make_config(self, config) : if config is not None : if not self.dlg : return config else : return self.preferences() + else : + return None def readconfig(self, config) : return config def preferences(self) : - return {} + return self.parametres def printRscript(self) : pass @@ -96,7 +119,7 @@ class AnalyseText : log.info('R code...') pid = exec_rcode(self.ira.RPath, Rscript, wait = wait) while pid.poll() is None : - if dlg is not None : + if dlg : self.dlg.Pulse(message) sleep(0.2) else : @@ -122,6 +145,7 @@ class Alceste(AnalyseText) : self.corpus.make_and_write_sparse_matrix_from_uci(self.actives, self.pathout['TableUc1'], self.pathout['listeuce1']) Rscript = self.printRscript() self.doR(Rscript, dlg = self.dlg, message = 'CHD...') + self.corpus.make_ucecl_from_R(self.pathout['uce']) self.corpus.make_and_write_profile(self.actives, self.corpus.lc, self.pathout['Contout']) self.sup, lim = self.corpus.make_actives_nb(self.parametres['max_actives'], 2) @@ -145,11 +169,6 @@ class Alceste(AnalyseText) : self.dial.CenterOnParent() self.dialok = self.dial.ShowModal() if self.dialok == 5100 : - if self.dial.radio_1.GetSelection() == 0 : - lem = 1 - else : - lem = 0 - parametres['lem'] = lem parametres['classif_mode'] = self.dial.radio_box_2.GetSelection() parametres['tailleuc1'] = self.dial.spin_ctrl_1.GetValue() parametres['tailleuc2'] = self.dial.spin_ctrl_2.GetValue() @@ -158,18 +177,19 @@ class Alceste(AnalyseText) : parametres['nbcl_p1'] = self.dial.spin_nbcl.GetValue() parametres['max_actives'] = self.dial.spin_max_actives.GetValue() parametres['corpus'] = '' + parametres['svdmethod'] = self.dial.svdmethod[self.dial.choicesvd.GetSelection()] parametres['pathout'] = self.pathout.dirout - for val in parametres : - print val, parametres[val] + parametres['mode.patate'] = self.dial.check_patate.GetValue() DoConf(self.parent.ConfigPath['alceste']).makeoptions(['ALCESTE'], [parametres]) self.dial.Destroy() + print parametres return parametres else : self.dial.Destroy() return None def printRscript(self) : - RchdTxt(self.pathout, self.parent.RscriptsPath, self.parametres['mincl'], self.parametres['classif_mode'], nbt = self.parametres['nbcl_p1'] - 1, libsvdc = self.parent.pref.getboolean('iramuteq','libsvdc'), libsvdc_path = self.parent.pref.get('iramuteq','libsvdc_path'), R_max_mem = False) + RchdTxt(self.pathout, self.parent.RscriptsPath, self.parametres['mincl'], self.parametres['classif_mode'], nbt = self.parametres['nbcl_p1'] - 1, svdmethod = self.parametres['svdmethod'], libsvdc = self.parent.pref.getboolean('iramuteq','libsvdc'), libsvdc_path = self.parent.pref.get('iramuteq','libsvdc_path'), R_max_mem = False, mode_patate = self.parametres['mode.patate']) return self.pathout['Rchdtxt'] def printRscript2(self) : @@ -193,34 +213,34 @@ class Alceste(AnalyseText) : PrintRapport(self, self.corpus, self.parametres) -keys = {'art_def' : 2, - 'pre' : 2, - 'adj_dem' : 2, - 'ono' : 2, - 'pro_per' : 2, - 'ver_sup' : 2, - 'adv' : 1, - 'ver' : 1, - 'adj_ind' : 2, - 'adj_pos' : 2, - 'aux' : 2, - 'adj_int' : 2, - 'pro_ind' : 2, - 'adj' : 1, - 'pro_dem' : 2, - 'nom' : 1, - 'art_ind' : 2, - 'pro_pos' : 2, - 'nom_sup' : 2, - 'adv_sup' : 2, - 'adj_sup' : 2, - 'adj_num' : 2, - 'pro_rel' : 2, - 'con' : 2, - 'num' : 2, - 'nr' : 1, - 'sw' : 2, -} - -gramact = [k for k in keys if keys[k] == 1] -gramsup = [k for k in keys if keys[k] == 2] +#keys = {'art_def' : 2, +# 'pre' : 2, +# 'adj_dem' : 2, +# 'ono' : 2, +# 'pro_per' : 2, +# 'ver_sup' : 2, +# 'adv' : 1, +# 'ver' : 1, +# 'adj_ind' : 2, +# 'adj_pos' : 2, +# 'aux' : 2, +# 'adj_int' : 2, +# 'pro_ind' : 2, +# 'adj' : 1, +# 'pro_dem' : 2, +# 'nom' : 1, +# 'art_ind' : 2, +# 'pro_pos' : 2, +# 'nom_sup' : 2, +# 'adv_sup' : 2, +# 'adj_sup' : 2, +# 'adj_num' : 2, +# 'pro_rel' : 2, +# 'con' : 2, +# 'num' : 2, +# 'nr' : 1, +# 'sw' : 2, +#} +# +#gramact = [k for k in keys if keys[k] == 1] +#gramsup = [k for k in keys if keys[k] == 2]