2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2010, Pierre Ratinaud
10 from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList
12 from dialog import PrefSegProf, PrefProfTypes
13 from time import sleep
15 class ProfileSegment() :
16 def __init__(self, parent, corpus) :
19 dial = PrefSegProf(self.parent)
21 if dial.ShowModal() == wx.ID_OK :
22 if dial.box_lem.GetSelection() == 0 :
26 self.mini = dial.spin_min.GetValue()
27 self.maxi = dial.spin_max.GetValue()
28 self.eff = dial.spin_eff.GetValue()
30 self.dlg = progressbar(self, maxi = 4)
31 self.dlg.Update(1, u'Recherche des segments')
34 self.dlg.Update(3, u'ouverture des profils')
36 self.dlg.Update(4, 'fini')
39 def make_table(self) :
40 self.corpus.make_segments_profile(self.corpus.dictpathout['segments_classes'], lenmin = self.mini, lenmax = self.maxi, effmin = self.eff, lem = self.lem)
46 """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
49 dt <- read.csv2("%s", row.names = 1)
50 to <- build.pond.prof(dt)
51 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
52 """ % (self.corpus.dictpathout['segments_classes'], self.corpus.dictpathout['prof_seg'], self.corpus.dictpathout['antiprof_seg'])
53 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
54 with open(fo, 'w') as f :
56 pid = exec_rcode(self.parent.RPath, fo, wait = False)
57 while pid.poll() == None :
58 self.dlg.Pulse(u'Construction des profils...')
60 check_Rresult(self.parent, pid)
63 SelectTab = self.parent.nb.GetSelection()
64 page = self.parent.nb.GetPage(SelectTab).TabChdSim
66 prof_seg = ReadProfileAsDico(self, self.corpus.dictpathout['prof_seg'], True, self.corpus.parametre['syscoding'])
67 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
68 for i in range(0,len(self.corpus.lc)) :
69 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
70 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
71 page.AddPage(prof_seg_nb, u'Profils des segements répétés')
72 page.SetSelection(page.GetPageCount() - 1)
75 def __init__(self, parent, corpus) :
78 self.outprof = self.corpus.dictpathout['prof_type']
79 dial = PrefProfTypes(self.parent)
80 dial.fbb.SetValue(self.outprof)
82 res = dial.ShowModal()
84 if dial.radio_type.GetSelection() == 0 :
88 if 'outprof' in self.corpus.parametre :
89 self.corpus.parametre['outprof'][self.outprof] = alceste
91 self.corpus.parametre['outprof'] = {self.outprof: alceste}
92 self.dlg = progressbar(self, maxi = 4)
93 self.dlg.Update(1, u'Recherche des types')
95 self.dlg.Update(1, u'Construction des profils')
96 self.make_prof(alceste = alceste)
97 self.dlg.Update(3, u'Ouverture des profils')
98 self.do_layout(alceste = alceste)
99 self.dlg.Update(4, 'fini')
102 def make_table(self) :
103 self.corpus.prof_type()
105 def make_prof(self, alceste = True) :
109 """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
112 dt <- read.csv2("%s", row.names = 1)
113 """ % self.corpus.dictpathout['type_cl']
116 to <- build.pond.prof(dt)
117 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
118 """ % (self.outprof, self.corpus.dictpathout['antiprof_type'])
122 write.csv2(to[[1]], file = "%s")
124 #write.csv2(to[[3]], file = "%s")
126 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
127 with open(fo, 'w') as f :
129 pid = exec_rcode(self.parent.RPath, fo, wait = False)
130 while pid.poll() == None :
131 self.dlg.Pulse(u'Construction des profils...')
133 check_Rresult(self.parent, pid)
135 def do_layout(self, alceste = True) :
136 SelectTab = self.parent.nb.GetSelection()
137 page = self.parent.nb.GetPage(SelectTab).TabChdSim
138 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
140 prof_seg = ReadProfileAsDico(self, self.outprof, True)
141 for i in range(0,len(self.corpus.lc)) :
142 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
143 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
145 self.DictSpec, first = ReadList(self.outprof)
146 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first)
147 prof_seg_nb.AddPage(self.ListPan, u'Spécificités')
149 page.AddPage(prof_seg_nb, u'Profils des types')
150 page.SetSelection(page.GetPageCount() - 1)