1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
6 #------------------------------------
7 # import des modules python
8 #------------------------------------
10 from time import time, sleep
12 #------------------------------------
13 # import des modules wx
14 #------------------------------------
17 #------------------------------------
18 # import des fichiers du projet
19 #------------------------------------
20 from chemins import ConstructPathOut, ConstructAfcUciPath
21 from layout import GraphPanel
22 #from PrintRScript import RAfcUci
23 from corpus import Corpus
25 from functions import ReadList, progressbar, exec_rcode, check_Rresult
26 from configparser import RawConfigParser
31 def __init__(self, parent, cmd = False):
32 ####################################################################
37 self.corpus = Corpus(parent)
38 self.corpus.parametre['encodage'] = parent.corpus_encodage
39 self.corpus.parametre['filename'] = parent.filename
40 self.corpus.parametre['lang'] = parent.corpus_lang
41 self.corpus.content = self.parent.content
42 self.ConfigPath = parent.ConfigPath
43 self.DictPath = parent.DictPath
44 self.AlcesteConf = RawConfigParser()
45 self.AlcesteConf.read(self.ConfigPath['alceste'])
46 self.KeyConf = RawConfigParser()
47 self.KeyConf.read(self.ConfigPath['key'])
48 pathout = ConstructPathOut(self.corpus.parametre['filename'], 'afcuci')
49 self.corpus.dictpathout = ConstructAfcUciPath(pathout)
50 self.corpus.supplementaires = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "2"]
51 self.corpus.typeactive = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "1"]
52 self.read_alceste_parametre()
53 ################################
55 self.dlg = progressbar(self, 6)
58 ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = self.dlg, cmd = self.cmd)
59 self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = False)
60 uces, orderuces = self.corpus.make_forms_and_uces()
61 self.corpus.make_lems(self.parent.lexique)
62 self.corpus.min_eff_formes()
63 self.corpus.make_var_actives()
64 self.corpus.make_var_supp()
65 print(self.corpus.supp)
66 self.corpus.make_pondtable_with_uci(self.corpus.actives, self.corpus.dictpathout['TableCont'])
67 self.corpus.make_pondtable_with_uci(self.corpus.supp, self.corpus.dictpathout['TableSup'])
68 self.corpus.parametre['para'] = False
69 self.corpus.make_etoiles([])
70 self.corpus.make_tableet_with_uci(self.corpus.dictpathout['TableEt'])
71 RAfcUci(self.corpus.dictpathout, nd=3, RscriptsPath=self.parent.RscriptsPath, PARCEX='0.5')
72 pid = exec_rcode(self.parent.RPath,self.corpus.dictpathout['Rafcuci'], wait = False)
73 while pid.poll() == None :
75 self.dlg.Pulse('CHD...')
79 check_Rresult(self.parent, pid)
81 self.dlg.Update(6, 'Affichage')
82 self.DoLayout(parent, self.corpus.dictpathout)
85 def read_alceste_parametre(self) :
86 self.conf = RawConfigParser()
87 self.conf.read(self.parent.ConfigPath['alceste'])
88 for option in self.conf.options('ALCESTE') :
89 if self.conf.get('ALCESTE', option).isdigit() :
90 self.corpus.parametre[option] = int(self.conf.get('ALCESTE', option))
92 self.corpus.parametre[option] = self.conf.get('ALCESTE', option)
93 list_bool = ['lem', 'expressions']
94 for val in list_bool :
95 if self.corpus.parametre[val] == 'True' :
96 self.corpus.parametre[val] = True
98 self.corpus.parametre[val] = False
100 def DoLayout(self, parent, DictAfcUciOut):
101 self.TabAfcUci = wx.aui.AuiNotebook(parent.nb, -1, wx.DefaultPosition)
102 #self.TabAfcTot = wx.html.HtmlWindow(self.TabAfcUci, -1)
103 #txtafctot = MakeAfcUciPages(DictAfcUciOut, parent.encode)
104 list_graph = [[os.path.basename(DictAfcUciOut['AfcColAct']),''],
105 [os.path.basename(DictAfcUciOut['AfcColSup']),''],
106 [os.path.basename(DictAfcUciOut['AfcColEt']),''],
107 [os.path.basename(DictAfcUciOut['AfcRow']),'']]
108 self.TabAfcTot = GraphPanel(self.TabAfcUci, DictAfcUciOut, list_graph, txt = '')
109 #self.TabAfcSplit = wx.html.HtmlWindow(self.TabAfcUci, -1)
110 #txtafcsplit = MakeAfcSplitPage(1, 2, DictAfcUciOut, self.pathout, parent.encode)
111 #if "gtk2" in wx.PlatformInfo:
112 # self.TabAfcSplit.SetStandardFonts()
113 #self.TabAfcSplit.SetPage(txtafcsplit)
114 dictrow, first = ReadList(self.corpus.dictpathout['afc_row'])
115 panel_list = ListForSpec(parent, self, dictrow, first[1:])
116 self.TabAfcUci.AddPage(self.TabAfcTot, 'Graph Afc totale')
117 #self.TabAfcUci.AddPage(self.TabAfcSplit, 'Graph AFC Split')
118 self.TabAfcUci.AddPage(panel_list, 'Colonnes')
119 parent.nb.AddPage(self.TabAfcUci, 'AFC Sur UCI')
120 parent.nb.SetSelection(parent.nb.GetPageCount() - 1)