1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2009 Pierre Ratinaud
6 from chemins import ConstructPathOut, ConstructAfcUciPath
7 from layout import GraphPanel
8 #from PrintRScript import RAfcUci
9 from corpus import Corpus
11 from functions import ReadList, progressbar, exec_rcode, check_Rresult
14 from ConfigParser import RawConfigParser
15 from time import time, sleep
18 def __init__(self, parent, cmd = False):
19 ####################################################################
24 self.corpus = Corpus(parent)
25 self.corpus.parametre['encodage'] = parent.corpus_encodage
26 self.corpus.parametre['filename'] = parent.filename
27 self.corpus.parametre['lang'] = parent.corpus_lang
28 self.corpus.content = self.parent.content
29 self.ConfigPath = parent.ConfigPath
30 self.DictPath = parent.DictPath
31 self.AlcesteConf = RawConfigParser()
32 self.AlcesteConf.read(self.ConfigPath['alceste'])
33 self.KeyConf = RawConfigParser()
34 self.KeyConf.read(self.ConfigPath['key'])
35 pathout = ConstructPathOut(self.corpus.parametre['filename'], 'afcuci')
36 self.corpus.dictpathout = ConstructAfcUciPath(pathout)
37 self.corpus.supplementaires = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "2"]
38 self.corpus.typeactive = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "1"]
40 self.read_alceste_parametre()
41 ################################
43 self.dlg = progressbar(self, 6)
46 ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = self.dlg, cmd = self.cmd)
47 self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = False)
48 uces, orderuces = self.corpus.make_forms_and_uces()
49 self.corpus.make_lems(self.parent.lexique)
50 self.corpus.min_eff_formes()
52 self.corpus.make_var_actives()
53 self.corpus.make_var_supp()
54 print self.corpus.supp
56 self.corpus.make_pondtable_with_uci(self.corpus.actives, self.corpus.dictpathout['TableCont'])
57 self.corpus.make_pondtable_with_uci(self.corpus.supp, self.corpus.dictpathout['TableSup'])
60 self.corpus.parametre['para'] = False
61 self.corpus.make_etoiles([])
62 self.corpus.make_tableet_with_uci(self.corpus.dictpathout['TableEt'])
63 RAfcUci(self.corpus.dictpathout, nd=3, RscriptsPath=self.parent.RscriptsPath, PARCEX='0.5')
64 pid = exec_rcode(self.parent.RPath,self.corpus.dictpathout['Rafcuci'], wait = False)
65 while pid.poll() == None :
67 self.dlg.Pulse(u'CHD...')
71 check_Rresult(self.parent, pid)
74 self.dlg.Update(6, 'Affichage')
75 self.DoLayout(parent, self.corpus.dictpathout)
78 def read_alceste_parametre(self) :
79 self.conf = RawConfigParser()
80 self.conf.read(self.parent.ConfigPath['alceste'])
81 for option in self.conf.options('ALCESTE') :
82 if self.conf.get('ALCESTE', option).isdigit() :
83 self.corpus.parametre[option] = int(self.conf.get('ALCESTE', option))
85 self.corpus.parametre[option] = self.conf.get('ALCESTE', option)
87 list_bool = ['lem', 'expressions']
88 for val in list_bool :
89 if self.corpus.parametre[val] == 'True' :
90 self.corpus.parametre[val] = True
92 self.corpus.parametre[val] = False
94 def DoLayout(self, parent, DictAfcUciOut):
95 self.TabAfcUci = wx.aui.AuiNotebook(parent.nb, -1, wx.DefaultPosition)
96 #self.TabAfcTot = wx.html.HtmlWindow(self.TabAfcUci, -1)
97 #txtafctot = MakeAfcUciPages(DictAfcUciOut, parent.encode)
98 list_graph = [[os.path.basename(DictAfcUciOut['AfcColAct']),''],
99 [os.path.basename(DictAfcUciOut['AfcColSup']),''],
100 [os.path.basename(DictAfcUciOut['AfcColEt']),''],
101 [os.path.basename(DictAfcUciOut['AfcRow']),'']]
102 self.TabAfcTot = GraphPanel(self.TabAfcUci, DictAfcUciOut, list_graph, txt = '')
104 #self.TabAfcSplit = wx.html.HtmlWindow(self.TabAfcUci, -1)
105 #txtafcsplit = MakeAfcSplitPage(1, 2, DictAfcUciOut, self.pathout, parent.encode)
106 #if "gtk2" in wx.PlatformInfo:
107 # self.TabAfcSplit.SetStandardFonts()
108 #self.TabAfcSplit.SetPage(txtafcsplit)
110 dictrow, first = ReadList(self.corpus.dictpathout['afc_row'])
111 panel_list = ListForSpec(parent, self, dictrow, first)
115 self.TabAfcUci.AddPage(self.TabAfcTot, 'Graph Afc totale')
116 #self.TabAfcUci.AddPage(self.TabAfcSplit, 'Graph AFC Split')
117 self.TabAfcUci.AddPage(panel_list, 'Colonnes')
118 parent.nb.AddPage(self.TabAfcUci, 'AFC Sur UCI')
120 parent.nb.SetSelection(parent.nb.GetPageCount() - 1)