X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=profile_segment.py;h=e0f68b8b0daaeb7eca72de1461dac34c30e6b0b3;hp=639b660b44b150622442e7ed45d91a71c83efdfc;hb=148fe710bf14981c45e865e8b4ddb68333e62f7c;hpb=5d8a0a0e99d9075adc28f2525fe0aba8e14c2b0a diff --git a/profile_segment.py b/profile_segment.py index 639b660..e0f68b8 100644 --- a/profile_segment.py +++ b/profile_segment.py @@ -1,16 +1,18 @@ #!/bin/env python # -*- coding: utf-8 -*- -#Author: Pierre Ratinaud -#Copyright (c) 2010, Pierre Ratinaud -#Lisense: GNU/GPL +# Author: Pierre Ratinaud +# Copyright (c) 2010, Pierre Ratinaud +# License: GNU/GPL import tempfile from ProfList import * -import agw.aui as aui +import wx +import wx.lib.agw.aui as aui from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList from listlex import * from dialog import PrefSegProf, PrefProfTypes from time import sleep +from chemins import ffr class ProfileSegment() : def __init__(self, parent, pathout, parametres, corpus) : @@ -21,41 +23,41 @@ class ProfileSegment() : dial = PrefSegProf(self.parent) dial.CenterOnParent() if dial.ShowModal() == wx.ID_OK : - if dial.box_lem.GetSelection() == 0 : - self.lem = True - else : - self.lem = False - self.mini = dial.spin_min.GetValue() - self.maxi = dial.spin_max.GetValue() - self.eff = dial.spin_eff.GetValue() - dial.Destroy() - self.dlg = progressbar(self, maxi = 4) - self.dlg.Update(1, u'Recherche des segments') - self.make_table() - self.make_prof() - self.dlg.Update(3, u'ouverture des profils') - self.do_layout() - self.dlg.Update(4, 'fini') - self.dlg.Destroy() + if dial.box_lem.GetSelection() == 0 : # @IndentOk + self.lem = True + else : + self.lem = False + self.mini = dial.spin_min.GetValue() + self.maxi = dial.spin_max.GetValue() + self.eff = dial.spin_eff.GetValue() + dial.Destroy() + self.dlg = progressbar(self, maxi=4) + self.dlg.Update(1, u'Recherche des segments') + self.make_table() + self.make_prof() + self.dlg.Update(3, u'ouverture des profils') + self.do_layout() + self.dlg.Update(4, 'fini') + self.dlg.Destroy() def make_table(self) : - self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin = self.mini, lenmax = self.maxi, effmin = self.eff, lem = self.lem) + self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin=self.mini, lenmax=self.maxi, effmin=self.eff, lem=self.lem) def make_prof(self) : txt = """ load("%s") source("%s") - """ % (self.dictpathout['RData'], self.parent.RscriptsPath['chdfunct']) + """ % (ffr(self.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct'])) txt += """ dt <- read.csv2("%s", row.names = 1) to <- build.pond.prof(dt) PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s") - """ % (self.corpus.dictpathout['segments_classes'], self.dictpathout['prof_seg'], self.dictpathout['antiprof_seg']) + """ % (ffr(self.corpus.dictpathout['segments_classes']), ffr(self.dictpathout['prof_seg']), ffr(self.dictpathout['antiprof_seg'])) fo = tempfile.mktemp(dir=self.parent.TEMPDIR) with open(fo, 'w') as f : f.write(txt) - pid = exec_rcode(self.parent.RPath, fo, wait = False) + pid = exec_rcode(self.parent.RPath, fo, wait=False) while pid.poll() == None : self.dlg.Pulse(u'Construction des profils...') sleep(0.2) @@ -64,9 +66,9 @@ class ProfileSegment() : def do_layout(self) : SelectTab = self.parent.nb.GetSelection() page = self.parent.nb.GetPage(SelectTab).TabChdSim - prof_seg = ReadProfileAsDico(self, self.dictpathout['prof_seg'], True, self.parent.syscoding) + prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding) prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition) - for i in range(0,len(self.corpus.lc)) : + for i in range(0, len(self.corpus.lc)) : ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1) prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1)) page.AddPage(prof_seg_nb, u'Profils des segements répétés') @@ -87,65 +89,65 @@ class ProfilType() : alceste = True else : alceste = False - #if 'outprof' in self.corpus.parametre : + # if 'outprof' in self.corpus.parametre : # self.corpus.parametre['outprof'][self.outprof] = alceste - #else : + # else : # self.corpus.parametre['outprof'] = {self.outprof: alceste} - self.dlg = progressbar(self, maxi = 4) + self.dlg = progressbar(self, maxi=4) self.dlg.Update(1, u'Recherche des types') self.make_table() self.dlg.Update(1, u'Construction des profils') - self.make_prof(alceste = alceste) + self.make_prof(alceste=alceste) self.dlg.Update(3, u'Ouverture des profils') - self.do_layout(alceste = alceste) + self.do_layout(alceste=alceste) self.dlg.Update(4, 'fini') self.dlg.Destroy() def make_table(self) : self.corpus.make_proftype(self.corpus.dictpathout['type_cl']) - def make_prof(self, alceste = True) : + def make_prof(self, alceste=True) : txt = """ load("%s") source("%s") - """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct']) + """ % (ffr(self.corpus.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct'])) txt += """ dt <- read.csv2("%s", row.names = 1) - """ % self.corpus.dictpathout['type_cl'] + """ % ffr(self.corpus.dictpathout['type_cl']) if alceste : txt += """ to <- build.pond.prof(dt) PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s") - """ % (self.outprof, self.corpus.dictpathout['antiprof_type']) + """ % (ffr(self.outprof), ffr(self.corpus.dictpathout['antiprof_type'])) else : txt += """ to <- AsLexico2(dt) write.csv2(to[[1]], file = "%s") - """ % (self.outprof) - #write.csv2(to[[3]], file = "%s") + """ % (ffr(self.outprof)) + # write.csv2(to[[3]], file = "%s") # % (self.outprof) fo = tempfile.mktemp(dir=self.parent.TEMPDIR) with open(fo, 'w') as f : f.write(txt) - pid = exec_rcode(self.parent.RPath, fo, wait = False) + pid = exec_rcode(self.parent.RPath, fo, wait=False) while pid.poll() == None : self.dlg.Pulse(u'Construction des profils...') sleep(0.2) check_Rresult(self.parent, pid) - def do_layout(self, alceste = True) : + def do_layout(self, alceste=True) : SelectTab = self.parent.nb.GetSelection() page = self.parent.nb.GetPage(SelectTab).TabChdSim prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition) if alceste : - prof_seg = ReadProfileAsDico(self, self.outprof, True) - for i in range(0,len(self.corpus.lc)) : + prof_seg = ReadProfileAsDico(self.outprof, True) + for i in range(0, len(self.corpus.lc)) : ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1) prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1)) else : self.DictSpec, first = ReadList(self.outprof) - self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first) + self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first[1:]) prof_seg_nb.AddPage(self.ListPan, u'Spécificités') page.AddPage(prof_seg_nb, u'Profils des types')