2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009 Pierre Ratinaud
9 #import wx.lib.agw.aui as aui
11 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
12 from ConfigParser import ConfigParser
13 from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi
14 from ProfList import *
15 from guiparam3d import param3d, simi3d
16 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
17 from profile_segment import *
18 from functions import ReadList
21 from search_tools import SearchFrame
22 from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro
23 from guifunct import SelectColumn, PrepSimi
24 from corpusNG import Corpus
33 log = logging.getLogger('iramuteq.layout')
36 class GraphPanelAfc(wx.Panel):
37 def __init__(self, parent, dico, list_graph, clnb, itempath = 'liste_graph_afc', coding = sys.getdefaultencoding()):
38 wx.Panel.__init__(self,parent)
43 self.itempath = itempath
44 self.parent = self.GetParent()#parent
45 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
49 self.list_graph = list_graph
50 self.TabCHD = self.parent.GetParent()
51 self.nb = self.TabCHD.GetParent()
52 self.ira = self.nb.GetParent()
53 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
54 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_afc.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
55 self.butafc = wx.BitmapButton(self, -1, afc_img)
56 self.Bind(wx.EVT_BUTTON, self.afc_graph, self.butafc)
57 self.dirout = os.path.dirname(self.Dict['ira'])
60 for i in range(0,len(list_graph)):
61 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
62 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
63 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
64 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `i - b`))
68 self.list_graph = [graph for i, graph in enumerate(self.list_graph) if i not in todel]
70 self.param = { 'typegraph' : 0,
77 'do_select_chi_classe' : 0,
94 self.__set_properties()
97 def __set_properties(self):
98 self.panel_1.EnableScrolling(True,True)
99 #self.panel_1.SetSize((1000,1000))
100 self.panel_1.SetScrollRate(20, 20)
102 def __do_layout(self):
103 log.info('do layout')
104 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
105 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
106 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
107 self.sizer_2.Add(self.butafc, 0, 0, 0)
108 for i in range(0, len(self.listimg)):
109 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
110 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
111 self.sizer_3.Add(self.buts[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
112 self.Bind(wx.EVT_BUTTON, self.on_delete_image, self.buts[i])
113 self.panel_1.SetSizer(self.sizer_3)
114 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
115 self.SetSizer(self.sizer_2)
117 def on_delete_image(self, event) :
118 image_id = int(event.GetEventObject().GetName())
119 image_path = self.list_graph[image_id][0]
120 message = 'This file will be delete : %s.\nAre you sure ?' % os.path.join(self.dirout, image_path)
121 dial = wx.MessageDialog(self, message, style = wx.YES_NO)
122 res = dial.ShowModal()
123 if res == wx.ID_YES :
125 log.info('delete image %i' % image_id)
126 oldimg = self.listimg.pop(image_id)
128 oldlab = self.labels.pop(image_id)
130 No = [but.Destroy() for but in self.buts]
131 self.buts = [wx.Button(self.panel_1, wx.ID_DELETE, name = `i`) for i, img in enumerate(self.listimg)]
132 todel = self.list_graph.pop(image_id)
133 os.remove(os.path.join(self.dirout, todel[0]))
134 print_liste(self.Dict[self.itempath], self.list_graph)
136 self.sizer_3.Fit(self.panel_1)
142 def afc_graph(self,event):
143 #dirout = os.path.dirname(self.Dict['ira'])
144 while os.path.exists(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+'.png')):
146 self.fileout = ffr(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+'.png'))
147 dial = PrefGraph(self.parent,-1,self.param,'')
148 dial.CenterOnParent()
149 val = dial.ShowModal()
151 self.param = {'typegraph' : dial.choicetype.GetSelection(),
152 'width' : dial.spin1.GetValue(),
153 'height' : dial.spin2.GetValue(),
154 'what' : dial.choice1.GetSelection(),
155 'qui' : dial.choice2.GetSelection(),
156 'do_select_nb' : dial.check1.GetValue(),
157 'do_select_chi' : dial.check2.GetValue(),
158 'do_select_chi_classe' : dial.check_chic.GetValue(),
159 'select_nb' : dial.spin_nb.GetValue(),
160 'select_chi' : dial.spin_chi.GetValue(),
161 'nbchic' : dial.spin_nbchic.GetValue(),
162 'over' : dial.check3.GetValue(),
163 'cex_txt' : dial.check4.GetValue(),
164 'txt_min' : dial.spin_min.GetValue(),
165 'txt_max' : dial.spin_max.GetValue(),
166 'tchi' : dial.check_tchi.GetValue(),
167 'tchi_min' : dial.spin_min_tchi.GetValue(),
168 'tchi_max' : dial.spin_max_tchi.GetValue(),
169 'taillecar' : dial.spin3.GetValue(),
170 'facteur' : [dial.spin_f1.GetValue(),dial.spin_f2.GetValue(), dial.spin_f3.GetValue()],
172 'film' : str(dial.film.GetValue()).upper(),
173 'alpha' : dial.slider_sphere.GetValue()
175 self.nb.parent = self.ira
176 self.DictPathOut = self.Dict
177 self.RscriptsPath = self.ira.RscriptsPath
180 """ % self.DictPathOut['RData']
181 if self.itempath == 'liste_graph_afcf' :
184 afc_table <- afcf_table
185 chistabletot <- specfp
186 infp <- which(is.infinite(chistabletot) & chistabletot > 0)
187 infm <- which(is.infinite(chistabletot) & chistabletot < 0)
188 chistabletot[infp] <- 0
189 chistabletot[infm] <- 0
190 chistabletot[infp] <- max(chistabletot) + 1
191 chistabletot[infm] <- min(chistabletot) - 1
193 elif self.itempath == 'liste_graph_afct' :
196 afc_table <- afct_table
197 chistabletot <- spectp
199 txt += write_afc_graph(self)
200 filetmp = tempfile.mktemp()
201 file = open(filetmp,'w')
204 pid = exec_rcode(self.ira.RPath, filetmp)
205 check_Rresult(self.ira, pid)
206 if self.param['typegraph'] == 0 :
208 if self.param['qui'] == 0 : value = u'actives'
209 if self.param['qui'] == 1 : value = u'supplémentaires'
210 if self.param['qui'] == 2 : value = u'étoilées'
211 if self.param['qui'] == 3 : value = u'classes'
213 if self.param['what'] == 0 : value = u'Coordonnées'
214 if self.param['what'] == 1 : value = u'Corrélations'
215 txt += value + u' - facteur %i / %i' % (self.param['facteur'][0], self.param['facteur'][1])
216 if self.param['do_select_nb'] : txt += u' - sélection de %i variables' % self.param['select_nb']
217 if self.param['do_select_chi'] : txt += u' - sélection des variables avec chi2 > %i ' % self.param['select_chi']
218 if self.param['over'] : txt += u' - Eviter les recouvrements'
219 if self.param['cex_txt'] : txt += u' - taille du texte proportionnel à la masse'
220 if self.param['tchi'] : txt += u' - taille du texte proportionnel au chi2 d\'association'
221 #list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding)
222 self.list_graph.append([self.fileout, txt])
223 print_liste(self.DictPathOut[self.itempath], self.list_graph)
224 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY)))
225 self.sizer_3.Add( self.listimg[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
226 self.labels.append(wx.StaticText(self.panel_1,-1, txt))
227 self.sizer_3.Add(self.labels[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
228 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `len(self.list_graph) - 1`))
229 self.sizer_3.Add(self.buts[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
230 self.sizer_3.Fit(self.panel_1)
233 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
236 class GraphPanel(wx.ScrolledWindow):
237 def __init__(self, parent, dico, list_graph, txt = '', style = wx.TAB_TRAVERSAL):
238 wx.ScrolledWindow.__init__(self, parent, style = style)
242 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
245 self.dirout = os.path.dirname(self.Dict['ira'])
246 self.deb = wx.StaticText(self, -1, txt)
247 for i in range(0,len(list_graph)):
248 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
249 self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
250 self.labels.append(wx.StaticText(self, -1, list_graph[i][1]))
252 self.__set_properties()
255 def __set_properties(self):
256 self.SetScrollRate(20, 20)
258 def __do_layout(self):
259 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
260 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
261 self.sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
262 self.sizer_1.Add(self.deb)
263 for i in range(0, len(self.listimg)):
264 self.sizer_1.Add(self.listimg[i], 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
265 self.sizer_1.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
266 self.sizer_2.Add(self.sizer_1, 1, wx.EXPAND, 0)
267 self.SetSizer(self.sizer_1)
268 self.sizer_1.Fit(self)
271 def __init__(self, parent, corpus, parametres, Alceste=False):
276 self.parametres = parametres
277 self.pathout = PathOut(parametres['ira'])
278 self.pathout.basefiles(ChdTxtPathOut)
279 DictPathOut = self.pathout
280 self.DictPathOut = DictPathOut
281 self.dictpathout = DictPathOut
284 Profile = DictPathOut['PROFILE_OUT']
285 AntiProfile = DictPathOut['ANTIPRO_OUT']
286 if isinstance(self.corpus, Corpus) :
287 self.encoding = self.corpus.parametres['syscoding']
288 self.corpus.make_ucecl_from_R(self.pathout['uce'])
289 elif 'tableau' in dir(gparent) :
290 self.encoding = gparent.tableau.parametres['syscoding']
292 #AnalyseConf = ConfigParser()
293 #AnalyseConf.readfp(codecs.open(filename,'r', self.encoding))
294 #AnalyseConf.read(filename)
295 #if 'analyse' in AnalyseConf.sections() :
296 # section = 'analyse'
297 #elif 'questionnaire' in AnalyseConf.sections() :
298 # section = 'questionnaire'
299 #elif 'chd_dist_quest' in AnalyseConf.sections() :
300 # section = 'chd_dist_quest'
301 #self.section = section
302 #clnb = AnalyseConf.get(section, 'clusternb')
304 clnb = parametres['clnb']
305 dlg = progressbar(self, maxi = 4 + clnb)
307 corpname = self.corpus.parametres['corpus_name']
308 print 'lecture des profils'
309 dlg.Update(2, u'lecture des profils')
311 DictProfile = ReadProfileAsDico(self, Profile, Alceste, self.encoding)
312 self.DictProfile = DictProfile
313 #print 'lecture des antiprofils'
314 #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding)
316 panel = wx.Panel(parent, -1)
317 sizer1 = wx.BoxSizer(wx.VERTICAL)
319 panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
320 panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16))
322 if isinstance(self.corpus, Corpus) :
323 panel.corpus = self.corpus
324 self.ID_sg = wx.NewId()
325 butsg = wx.Button(panel.chd_toolbar, self.ID_sg, u"Profils des segments répétés ")
326 panel.chd_toolbar.AddControl(butsg)
327 panel.chd_toolbar.AddSeparator()
328 self.ID_export = wx.NewId()
329 butexp = wx.Button(panel.chd_toolbar, self.ID_export, u"Exporter le corpus ")
330 panel.chd_toolbar.AddControl(butexp)
331 panel.chd_toolbar.AddSeparator()
332 self.ID_colored = wx.NewId()
333 butcol = wx.Button(panel.chd_toolbar, self.ID_colored, u"Corpus en couleur ")
334 panel.chd_toolbar.AddControl(butcol)
335 panel.chd_toolbar.AddSeparator()
336 self.ID_searchf = wx.NewId()
337 butsearchf = wx.Button(panel.chd_toolbar, self.ID_searchf, u"Outil de navigation ")
338 panel.chd_toolbar.AddControl(butsearchf)
339 panel.chd_toolbar.AddSeparator()
341 self.ID_proftype =wx.NewId()
342 butpt = wx.Button(panel.chd_toolbar, self.ID_proftype, u"Profils des types ")
343 panel.chd_toolbar.AddControl(butpt)
344 panel.chd_toolbar.AddSeparator()
346 self.ID_clusterstat =wx.NewId()
347 butclusterstat = wx.Button(panel.chd_toolbar, self.ID_clusterstat, u"Stat par classe ")
348 panel.chd_toolbar.AddControl(butclusterstat)
349 panel.chd_toolbar.AddSeparator()
352 self.ID_rapport = wx.NewId()
353 #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
354 #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple")
355 butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ")
356 panel.chd_toolbar.AddControl(butrap)
358 panel.chd_toolbar.Realize()
359 sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5)
361 #self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
362 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER
363 panel.TabChdSim = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
364 panel.TabChdSim.SetAGWWindowStyleFlag(notebook_flags)
365 panel.TabChdSim.SetArtProvider(aui.ChromeTabArt())
366 sizer1.Add(panel.TabChdSim,10, wx.EXPAND, 5)
367 panel.SetSizer(sizer1)
371 if isinstance(self.corpus, Corpus) :
372 panel.TabChdSim.corpus = corpus
373 panel.TabChdSim.corpus.dictpathout = self.DictPathOut
374 panel.parametres = self.parametres
376 self.notenb = self.parent.nb.GetPageCount()
377 if os.path.exists(DictPathOut['pre_rapport']):
378 #self.tabRap = wx.TextCtrl(self.TabChdSim, -1, "", style=wx.TE_MULTILINE | wx.TE_RICH2)
379 #self.tabRap.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
380 with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f :
382 #self.tabRap.write(txt)
383 #self.tabRap.ShowPosition(0)
388 if os.path.exists(self.DictPathOut['liste_graph_chd']) :
389 list_graph = read_list_file(self.DictPathOut['liste_graph_chd'], self.encoding)
390 CHD = GraphPanelDendro(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
391 panel.TabChdSim.AddPage(CHD,'CHD')
393 panel.ProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
394 panel.ProfNB.SetArtProvider(aui.ChromeTabArt())
395 #self.ProfNB.SetTabCtrlHeight(100)
396 #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
397 if os.path.exists(DictPathOut['prof_seg']) :
398 prof_seg = ReadProfileAsDico(self, DictPathOut['prof_seg'], False, self.encoding)
399 self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
400 for i in range(0, clnb):
401 dlg.Update(3+i, 'Classe %i' %(i+1))
402 ind = '/'.join(DictProfile[str(i + 1)][0][0:2])
403 indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]])
404 self.tabprofile = ProfListctrlPanel(self.parent, self, DictProfile[str(i + 1)], Alceste, i + 1)
405 #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
406 panel.ProfNB.AddPage(self.tabprofile, 'classe %s %s(%s%%)' % (str(i + 1), sep, indpour))
407 #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
408 if os.path.exists(DictPathOut['prof_seg']) :
409 self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
410 self.prof_seg_nb.AddPage(self.tab_prof_seg, 'classe %i' % (i + 1))
413 self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition)
415 list_graph=read_list_file(DictPathOut['liste_graph_afc'], self.encoding)
416 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, DictPathOut, list_graph, self.clnb, coding=self.encoding)
417 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC')
419 if os.path.exists(self.DictPathOut['afc_facteur']) :
420 dictrow, first = ReadList(self.DictPathOut['afc_facteur'], self.encoding)
421 self.TabAFC_facteur = ListForSpec(self.parent, parametres, dictrow, first)
422 #dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
423 #self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
424 #dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
425 #self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
426 self.TabAFC.AddPage(self.TabAFC_facteur, 'Facteurs')
427 #self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
428 #self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
430 sizer_3 = wx.BoxSizer(wx.VERTICAL)
431 self.parent.nb_panel_2 = wx.Panel(panel.TabChdSim, -1)
432 self.parent.button_simi = wx.Button(self.parent.nb_panel_2, -1, "Voyager")
433 self.parent.simi3dpanel = simi3d(self.parent.nb_panel_2, -1)
434 sizer_3.Add(self.parent.simi3dpanel, 1, wx.EXPAND, 0)
435 sizer_3.Add(self.parent.button_simi, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
436 self.parent.nb_panel_2.SetSizer(sizer_3)
437 self.TabAFC.AddPage(self.parent.nb_panel_2, "graph 3D")
438 self.parent.Bind(wx.EVT_BUTTON, self.onsimi, self.parent.button_simi)
440 panel.TabChdSim.AddPage(panel.ProfNB, 'Profils')
441 #panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
442 dlg.Update(4 + self.clnb, 'Affichage...')
444 panel.TabChdSim.AddPage(self.TabAFC, 'AFC')
445 if os.path.exists(DictPathOut['prof_seg']) :
446 panel.TabChdSim.AddPage(self.prof_seg_nb, u'Profils des segments répétés')
448 if isinstance(self.corpus, Corpus) :
449 panel.Bind(wx.EVT_BUTTON, self.on_export_classes, id = self.ID_export)
450 panel.Bind(wx.EVT_BUTTON, self.onprofseg, id = self.ID_sg)
451 panel.Bind(wx.EVT_BUTTON, self.oncolored, id = self.ID_colored)
452 panel.Bind(wx.EVT_BUTTON, self.onsearchf, id = self.ID_searchf)
453 panel.Bind(wx.EVT_BUTTON, self.onproftype, id = self.ID_proftype)
454 panel.Bind(wx.EVT_BUTTON, self.onclusterstat, id = self.ID_clusterstat)
456 panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport)
457 self.parent.nb.AddPage(panel, 'Classification - %s' % corpname)
458 self.parent.ShowTab(True)
459 self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
460 #for pane in self.parent._mgr.GetAllPanes() :
461 # if isinstance(pane.window, aui.AuiNotebook):
463 # nb.SetAGWWindowStyleFlag(notebook_flags)
464 # nb.SetArtProvider(aui.ChromeTabArt())
466 self.parent._mgr.Update()
468 def onsimi(self,event):
469 outfile = print_simi3d(self)
470 error = exec_rcode(self.parent.RPath, outfile, wait = True)
472 def ongetrapport(self, event) :
473 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'})
474 dial.fbb.SetValue(self.DictPathOut['rapport'])
475 dial.CenterOnParent()
476 res = dial.ShowModal()
478 fileout = dial.fbb.GetValue()
480 with open(fileout, 'w') as f :
481 f.write(self.debtext + '\n' + GetTxtProfile(self.DictProfile))
483 dlg = wx.MessageDialog(self.parent, msg, u"Rapport", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
490 def on_export_classes(self, event) :
491 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
492 dial = PrefExport(self, self.parent)
493 dial.fbb.SetValue(os.path.join(os.path.dirname(corpus.dictpathout['ira']), 'export_corpus.txt'))
494 dial.CenterOnParent()
495 res = dial.ShowModal()
497 if dial.radio_type.GetSelection() == 0 : alc = True
499 if dial.radio_lem.GetSelection() == 0 : lem = True
501 self.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem)
504 dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
509 def onprofseg(self, event):
511 print 'plus de bug profseg'
512 print self.parametres
513 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
514 ProfileSegment(self.parent, self.dictpathout, self.parametres, corpus)
516 # BugReport(self.parent)
518 def onproftype(self, event):
520 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
521 ProfilType(self.parent, corpus)
523 BugReport(self.parent)
525 def oncolored(self,evt) :
526 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': 'Corpus en couleur'})
527 dial.fbb.SetValue(os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'corpus_couleur.html'))
528 dial.CenterOnParent()
529 res = dial.ShowModal()
531 fileout = dial.fbb.GetValue()
533 txt = self.corpus.make_colored_corpus()
534 with open(fileout, 'w') as f :
536 msg = u"Fini !\nVoulez-vous ouvrir le corpus dans votre navigateur ?"
537 dlg = wx.MessageDialog(self.parent, msg, u"Corpus en couleur", wx.NO | wx.YES | wx.NO_DEFAULT | wx.ICON_QUESTION)
539 if dlg.ShowModal() == wx.ID_YES :
540 webbrowser.open(fileout)
543 def onclusterstat(self, evt) :
544 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'})
545 dial.fbb.SetValue( os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'stat_par_classe.csv'))
546 dial.CenterOnParent()
547 res = dial.ShowModal()
549 fileout = dial.fbb.GetValue()
552 self.corpus.get_stat_by_cluster(fileout)
554 dlg = wx.MessageDialog(self.parent, msg, u"Stat par classe", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
556 if dlg.ShowModal() == wx.ID_OK :
559 def onsearchf(self, evt) :
560 if 'FrameSearch' not in dir(self.parent) :
561 self.parent.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus)
562 self.parent.FrameSearch.Show()
566 def PrintRapport(self, corpus, parametres, txt = True):
567 #if sys.platform == 'win32':
573 |i|R|a|M|u|T|e|Q| - %s
577 """ % datetime.datetime.now().ctime()
578 totocc = corpus.gettotocc()
580 txt += u'nombre d\'uci: %i%s' % (corpus.getucinb(), sep)
581 txt += u'nombre d\'uce: %i%s' % (corpus.getucenb(), sep)
582 txt += u'nombre de formes: %i%s' % (len(corpus.formes), sep)
583 txt += u'nombre d\'occurrences: %i%s' % (totocc, sep)
584 txt += u'moyenne d\'occurrences par forme: %f%s' % (float(totocc) / float(len(self.corpus.formes)), sep)
585 txt += u'nombre de lemmes: %i%s' % (len(corpus.lems), sep)
586 txt += u'nombre de formes actives: %i%s' % (corpus.getactivesnb(1), sep)
587 txt += u'nombre de formes supplémentaires: %i%s' % (corpus.getactivesnb(2), sep)
588 txt += u'nombre de formes actives de fréquence >= %i: %i%s' % (parametres['eff_min_forme'], parametres['nbactives'], sep)
589 txt += u'moyenne d\'occurrences par uce :%f%s' % (float(totocc) / float(corpus.getucenb()), sep)
590 if 'tailleuc1' in parametres :
591 if parametres['classif_mode'] != 0 :
592 txt += u'taille uc1 : %i\n' % parametres['tailleuc1']
594 txt += u'taille uc1 / uc2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
596 self.Ucenb = self.nbind
597 txt += u'nombre d\'individus : %i%s' % (self.nbind, sep)
598 txt += u'nombre de classes : %i%s' % (self.clnb, sep)
600 txt += u'nombre de classes : %i%s' % (parametres['clnb'], sep)
601 if parametres['classif_mode'] == 0 or parametres['classif_mode'] == 1 :
602 txt += u'%i uce classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucenb(), (float(sum([len(cl) for cl in corpus.lc])) / float(corpus.getucenb())) * 100, sep)
603 elif self.parametres['classif_mode'] == 2 :
604 txt += u'%i uci classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucinb(), (float(sum([len(cl) for cl in corpus.lc]))) / float(corpus.getucinb()) * 100, sep)
605 elif analyse == 'quest' :
606 txt += u'%i uce classées sur %i (%.2f%%)%s' % (self.ucecla, self.Ucenb, (float(self.ucecla) / float(self.Ucenb)) * 100, sep)
609 ###########################
611 ###########################
612 """ % parametres['time']
613 file = open(self.pathout['pre_rapport'], 'w')
618 def __init__(self, ira, corpus, parametres):
619 self.pathout = PathOut(dirout = parametres['pathout'])
621 self.dictpathout = StatTxtPathOut(parametres['pathout'])
622 #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
624 self.encoding = self.corpus.parametres['syscoding']
625 self.parametres = parametres
627 self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding'])
628 self.DictType, firstt = ReadList(self.dictpathout['tablespect'], self.corpus.parametres['syscoding'])
629 self.DictEff, firsteff = ReadList(self.dictpathout['tableafcm'], self.corpus.parametres['syscoding'])
630 self.DictEffType, firstefft = ReadList(self.dictpathout['tabletypem'], self.corpus.parametres['syscoding'])
631 self.DictEffRelForme, firsteffrelf = ReadList(self.dictpathout['eff_relatif_forme'], self.corpus.parametres['syscoding'])
632 self.DictEffRelType, firsteffrelt = ReadList(self.dictpathout['eff_relatif_type'], self.corpus.parametres['syscoding'])
634 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
635 self.TabStat.parametres = parametres
636 self.ListPan = ListForSpec(ira, self.parent, self.DictSpec, first)
637 self.ListPant = ListForSpec(ira, self.parent, self.DictType, firstt)
638 self.ListPanEff = ListForSpec(ira, self.parent, self.DictEff, firsteff)
639 self.ListPanEffType = ListForSpec(ira, self.parent, self.DictEffType, firstefft)
640 self.ListPanEffRelForme = ListForSpec(ira, self.parent, self.DictEffRelForme, firsteffrelf)
641 self.ListPanEffRelType = ListForSpec(ira, self.parent, self.DictEffRelType, firsteffrelt)
643 self.TabStat.AddPage(self.ListPan, u'formes')
644 self.TabStat.AddPage(self.ListPant, u'Types')
645 self.TabStat.AddPage(self.ListPanEff, u'Effectifs formes')
646 self.TabStat.AddPage(self.ListPanEffType, u'Effectifs Type')
647 self.TabStat.AddPage(self.ListPanEffRelForme, u'Effectifs relatifs formes')
648 self.TabStat.AddPage(self.ListPanEffRelType, u'Effectifs relatifs Type')
649 if self.parametres['clnb'] > 2 :
650 self.TabAFC = aui.AuiNotebook(self.TabStat, -1, wx.DefaultPosition)
651 list_graph=read_list_file(self.dictpathout['liste_graph_afcf'], encoding = self.encoding)
652 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afcf', coding = self.encoding)
653 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC formes')
654 list_graph=read_list_file(self.dictpathout['liste_graph_afct'], encoding = self.encoding)
655 self.tabAFCTGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afct', coding=self.encoding)
656 self.TabAFC.AddPage(self.tabAFCTGraph, 'AFC type')
657 self.TabStat.AddPage(self.TabAFC, 'AFC')
660 ira.nb.AddPage(self.TabStat, u'Spécificités')
662 self.TabStat.corpus = self.corpus
663 ira.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
664 ira.ShowAPane("Tab_content")
667 def __init__(self, ira, corpus, parametres):
668 self.pathout = PathOut(dirout = parametres['pathout'])
672 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
673 self.TabStat.parametres = parametres
674 # CHD = GraphPanel(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
675 # panel.TabChdSim.AddPage(CHD,'CHD')
677 #self.TabStatTot = wx.TextCtrl(self.TabStat, -1, style=wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2)
678 list_graph = [['zipf.png', 'zipf']]
679 self.TabStatTot = GraphPanel(ira.nb, self.pathout, list_graph, self.result['glob'])
680 #self.TabStatTot.write(self.result['glob'])
681 self.TabStat.AddPage(self.TabStatTot, 'global')
682 for item in self.result:
684 datam = [['forme', 'nb']]
685 self.ListPan = ListPanel(ira, self, self.result[item])
686 self.TabStat.AddPage(self.ListPan, item)
687 ira.nb.AddPage(self.TabStat, 'Stat')
688 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
689 ira.ShowAPane("Tab_content")
691 def read_result(self) :
692 lcle = {'total' :u'total.csv', u'formes_actives':u'formes_actives.csv', u'formes_supplémentaires':u'formes_supplémentaires.csv', u'hapax': u'hapax.csv'}
695 with open(self.pathout[lcle[key]], 'r') as f :
696 self.result[key] = [line.split(';') for line in f.read().splitlines()]
697 self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])])
698 with open(self.pathout['glob.txt'], 'r') as f :
699 self.result['glob'] = f.read()
701 class GraphPanelDendro(wx.Panel):
702 def __init__(self,parent, dico, list_graph, txt=False):
703 wx.Panel.__init__(self,parent)
705 self.dictpathout = dico
706 self.dirout = os.path.dirname(self.dictpathout['ira'])
707 self.list_graph = list_graph
708 self.parent = self.GetParent()#parent
709 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
712 self.tabchd = self.parent.GetParent()
713 self.ira = self.tabchd.GetParent()
714 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
715 self.deb = wx.StaticText(self.panel_1, -1, txt)
716 dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
717 self.butdendro = wx.BitmapButton(self, -1, dendro_img)
719 for i in range(0,len(list_graph)):
720 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
721 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
722 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
724 self.__set_properties()
727 def __set_properties(self):
728 self.panel_1.EnableScrolling(True,True)
729 #self.panel_1.SetSize((1000,1000))
730 self.panel_1.SetScrollRate(20, 20)
731 self.Bind(wx.EVT_BUTTON, self.ondendro, self.butdendro)
732 self.param = {'width' : 700,
736 'taille_classe' : True,
739 self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
741 def __do_layout(self):
742 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
743 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
744 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
745 self.sizer_3.Add(self.deb)
746 self.sizer_2.Add(self.butdendro, 0, 0, 0)
747 for i in range(0, len(self.listimg)):
748 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
749 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
750 self.panel_1.SetSizer(self.sizer_3)
751 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
752 self.SetSizer(self.sizer_2)
754 def make_param(self, dial):
755 self.param['width'] = dial.m_spinCtrl2.GetValue()
756 self.param['height'] = dial.m_spinCtrl1.GetValue()
757 self.param['type_dendro'] = dial.m_choice1.GetSelection()
758 self.param['color_nb'] = dial.m_radioBox1.GetSelection()
759 self.param['taille_classe'] = dial.m_checkBox1.GetValue()
760 self.param['type_tclasse'] = dial.m_radioBox2.GetSelection()
762 def make_dendro(self) :
763 while os.path.exists(os.path.join(self.dirout, 'dendrogamme_' + str(self.graphnb)+'.png')) :
765 fileout = ffr(os.path.join(self.dirout,'dendrogamme_' + str(self.graphnb)+'.png'))
766 width = self.param['width']
767 height = self.param['height']
768 type_dendro = self.type_dendro[self.param['type_dendro']]
769 if self.param['taille_classe'] :
773 if self.param['color_nb'] == 0 :
777 if self.param['type_tclasse'] == 0 :
781 dendro_path = self.dictpathout['Rdendro']
782 classe_path = self.dictpathout['uce']
787 classes <- read.csv2("%s", row.names=1)
788 classes <- classes[,1]
789 open_file_graph("%s", width=%i, height=%i)
790 plot.dendropr(tree.cut1$tree.cl, classes, type.dendro="%s", histo=%s, bw=%s, lab=NULL, tclasse=%s)
791 """ % (ffr(dendro_path), ffr(self.ira.RscriptsPath['Rgraph']), ffr(classe_path), ffr(fileout), width, height, type_dendro, histo, bw, tclasse)
793 tmpfile = tempfile.mktemp()
794 with open(tmpfile, 'w') as f :
796 error = exec_rcode(self.ira.RPath, tmpfile, wait=True)
797 check_Rresult(self.ira, error)
798 self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
799 print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
800 self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
801 self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
802 self.sizer_3.Fit(self.panel_1)
804 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
807 def ondendro(self, evt):
808 dial = PrefDendro(self.ira, self.param)
809 val = dial.ShowModal()
811 self.make_param(dial)
817 def __init__(self, ira, parametres) :
818 #self.text = wx.TextCtrl(ira, -1, "", wx.Point(0, 0), wx.Size(200, 200), wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY)
819 self.panel = CopusPanel(ira, parametres)
820 ira.nb.AddPage(self.panel, 'Description %s' % parametres['corpus_name'])
821 #self.text.write(DoConf().totext(parametres))
822 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
823 ira.ShowAPane("Tab_content")
825 class CopusPanel(wx.Panel) :
826 def __init__(self, parent, parametres) :
827 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
828 self.parametres = parametres
829 fgSizer5 = wx.FlexGridSizer( 0, 2, 0, 0 )
830 fgSizer5.SetFlexibleDirection( wx.BOTH )
831 fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
832 self.fgSizer5 = fgSizer5
834 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Description du corpus", wx.DefaultPosition, wx.DefaultSize, 0 )
836 self.m_staticText18.Wrap( -1 )
837 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
839 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
840 self.m_staticText19.Wrap( -1 )
841 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
843 self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"Nom", wx.DefaultPosition, wx.DefaultSize, 0 )
844 self.m_staticText20.Wrap( -1 )
845 fgSizer5.Add( self.m_staticText20, 0, wx.ALL, 5 )
847 self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.DefaultSize, 0 )
848 self.m_staticText21.Wrap( -1 )
849 fgSizer5.Add( self.m_staticText21, 0, wx.ALL, 5 )
851 description = {'lang' : u'langue',
852 'encoding' : u'encodage'}
854 keys = ['lang', 'encoding', 'originalpath', 'pathout', 'date', 'time']
856 self.addkeys(keys, description)
858 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Paramètres", wx.DefaultPosition, wx.DefaultSize, 0 )
859 self.m_staticText18.Wrap( -1 )
860 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
862 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
863 self.m_staticText19.Wrap( -1 )
864 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
866 keys = ['ucemethod', 'ucesize', 'keep_caract', 'expressions']
867 self.addkeys(keys, description)
869 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Statistiques", wx.DefaultPosition, wx.DefaultSize, 0 )
870 self.m_staticText18.Wrap( -1 )
871 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
873 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
874 self.m_staticText19.Wrap( -1 )
875 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
877 keys = ['ucinb', 'ucenb', 'occurrences', 'formesnb', 'hapax']
878 self.addkeys(keys, description)
880 self.SetSizer( fgSizer5 )
883 def addkeys(self, keys, description) :
885 option = self.parametres.get(key,u'non défnini')
886 if isinstance(option, int) :
888 text = wx.StaticText( self, wx.ID_ANY, description.get(key, key), wx.DefaultPosition, wx.DefaultSize, 0 )
890 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
892 text = wx.StaticText( self, wx.ID_ANY, option, wx.DefaultPosition, wx.DefaultSize, 0 )
894 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
896 class GraphPanelSimi(wx.Panel):
897 def __init__(self, parent, dico, list_graph):
898 wx.Panel.__init__(self,parent)
901 self.dirout = os.path.dirname(self.Dict['ira'])
902 self.parent = self.GetParent()#parent
903 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
906 self.tabsimi = self.parent.GetParent()
907 self.ira = self.tabsimi.GetParent()
908 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
909 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
910 self.butafc = wx.BitmapButton(self, -1, afc_img)
911 export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
912 self.butexport = wx.BitmapButton(self, -1, export_img)
914 for i in range(0,len(list_graph)):
915 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) and list_graph[i][0] != '' :
916 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
917 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
919 self.__set_properties()
922 def __set_properties(self):
923 self.panel_1.EnableScrolling(True,True)
924 #self.panel_1.SetSize((1000,1000))
925 self.panel_1.SetScrollRate(20, 20)
927 def __do_layout(self):
928 self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
929 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
930 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
931 self.sizer_2.Add(self.butafc, 0, 0, 0)
932 self.sizer_2.Add(self.butexport, 0, 0, 0)
933 for i in range(0, len(self.listimg)):
934 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
935 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
936 self.panel_1.SetSizer(self.sizer_3)
937 self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0)
938 self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
939 self.SetSizer(self.sizer_1)
941 class DefaultTextLayout :
942 def __init__(self, ira, corpus, parametres) :
943 self.pathout = PathOut(dirout = parametres['pathout'])
946 self.parametres = parametres
951 log.info('no layout yet')
953 class WordCloudLayout(DefaultTextLayout):
955 #self.dictpathout = parent.corpus.dictpathout
956 #self.pathout = os.path.dirname(filename)
957 #self.corpus = parent.corpus
959 self.pathout.basefiles(simipath)
960 self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
961 # if os.path.exists(self.pathout['liste_graph']) :
962 # list_graph = read_list_file(self.pathout['liste_graph'])
964 # list_graph = [['','']]
965 list_graph = [['nuage_1.png', 'Nuage']]
966 self.TabStatTot = GraphPanel(self.ira.nb, self.pathout, list_graph)
967 #self.TabStatTot.write(self.result['glob'])
968 self.Tab.AddPage(self.TabStatTot, 'Nuage')
969 self.Tab.corpus = self.corpus
970 self.Tab.parametres = self.parametres
971 self.ira.nb.AddPage(self.Tab, 'WordCloud %s' % self.parametres.get('corpus_name','corpus_name'))
972 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
973 self.ira.ShowAPane("Tab_content")
975 class SimiLayout(DefaultTextLayout) :
977 self.pathout.basefiles(simipath)
979 self.indices = indices_simi
980 if os.path.exists(self.pathout['liste_graph']) :
981 list_graph = read_list_file(self.pathout['liste_graph'])
983 list_graph = [['','']]
984 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
985 self.tabsimi = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
986 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
987 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
988 self.tabsimi.corpus = self.corpus
989 self.tabsimi.parametres = self.parametres
990 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
991 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
992 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
993 self.tabsimi.AddPage(self.graphpan, 'Graph')
994 self.ira.nb.AddPage(self.tabsimi, 'Analyse de graph')
995 self.ira.ShowTab(True)
996 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
998 def redosimi(self, evt) :
999 with open(self.pathout['selected.csv'],'r') as f :
1001 selected = [int(val) for val in selected.splitlines()]
1002 if self.actives is None :
1003 with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1004 self.actives = f.read()
1005 self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1006 dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1007 #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True)
1009 prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
1010 if prep.val == wx.ID_OK :
1011 self.parametres = prep.parametres
1013 script = PrintSimiScript(self)
1014 script.make_script()
1015 pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
1016 check_Rresult(self.ira, pid)
1017 if self.parametres['type_graph'] == 1:
1018 if os.path.exists(self.pathout['liste_graph']):
1019 graph_simi = read_list_file(self.pathout['liste_graph'])
1020 graph_simi.append([os.path.basename(script.filename), script.txtgraph])
1022 graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
1023 print_liste(self.pathout['liste_graph'], graph_simi)
1024 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1025 if self.parametres['type_graph'] == 1:
1026 self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1027 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1028 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1029 self.graphpan.Layout()
1030 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1032 def export(self, evt) :
1034 # def read_result(self) :
1035 # #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
1036 # #self.corpus.make_et_table()
1038 # with open(os.path.join(self.pathout,'glob.txt'), 'r') as f :
1039 # self.result['glob'] = f.read()