From: Pierre Ratinaud Date: Mon, 17 Nov 2014 23:14:58 +0000 (+0100) Subject: split matrix X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=commitdiff_plain;h=9a12a3e7eee7e594312047115cc130f769a3adc3 split matrix --- diff --git a/analysematrix.py b/analysematrix.py index 9803994..a89b10e 100644 --- a/analysematrix.py +++ b/analysematrix.py @@ -25,9 +25,12 @@ class AnalyseMatrix : self.dlg = dlg self.parametres = parametres self.val = False - self.parametres['pathout'] = PathOut(tableau.parametres['originalpath'], analyse_type = self.parametres['type'], dirout = tableau.parametres['pathout']).mkdirout() + print self.parametres if not 'pathout' in self.parametres : - self.pathout = PathOut(tableau.parametres['originalpath'], analyse_type = self.parametres['type'], dirout = tableau.parametres['pathout']) + self.parametres['pathout'] = PathOut(tableau.parametres['originalpath'], analyse_type = self.parametres['type'], dirout = tableau.parametres['pathout']).mkdirout() + print self.parametres + self.pathout = PathOut(analyse_type = self.parametres['type'], dirout = self.parametres['pathout']) + print self.pathout.dirout else : self.pathout = PathOut(filename = tableau.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['type']) @@ -48,17 +51,19 @@ class AnalyseMatrix : else : result_analyse = False if result_analyse is None : - self.time = time() - self.t1 - minutes, seconds = divmod(self.time, 60) - hours, minutes = divmod(minutes, 60) - self.parametres['time'] = '%.0fh %.0fm %.0fs' % (hours, minutes, seconds) - self.parametres['ira'] = self.pathout['Analyse.ira'] - DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira']) - self.ira.history.addMatrixAnalyse(self.parametres) + if self.parametres.get('tohistory', True) : + self.time = time() - self.t1 + minutes, seconds = divmod(self.time, 60) + hours, minutes = divmod(minutes, 60) + self.parametres['time'] = '%.0fh %.0fm %.0fs' % (hours, minutes, seconds) + self.parametres['ira'] = self.pathout['Analyse.ira'] + DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira']) + self.ira.history.addMatrixAnalyse(self.parametres) if self.dlg is not None : self.dlg.Destroy() - OpenAnalyse(self.parent, self.parametres['ira']) - self.ira.tree.AddMatAnalyse(self.parametres) + if self.parametres.get('tohistory', True) : + OpenAnalyse(self.parent, self.parametres['ira']) + self.ira.tree.AddMatAnalyse(self.parametres) self.val = 5100 else : self.val = False diff --git a/dialog.py b/dialog.py index 2ab63d4..9d166c3 100755 --- a/dialog.py +++ b/dialog.py @@ -2337,7 +2337,9 @@ class CorpusPref ( wx.Dialog ): fgSizer5.Add( self.radio_other_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.otherdictpath = wx.FilePickerCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, _(u"Select a file").decode('utf8'), u"*.*", wx.DefaultPosition, wx.Size( 300,-1 ), wx.FLP_DEFAULT_STYLE ) + self.otherdictpath.SetMinSize(wx.Size(300, -1)) fgSizer5.Add( self.otherdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.otherdictpath.Enable( False ) bSizer2.Add( fgSizer5, 1, wx.EXPAND, 5 ) @@ -2493,7 +2495,9 @@ class CorpusPref ( wx.Dialog ): # Connect Events self.Bind(wx.EVT_BUTTON, self.OnChangeDir, self.m_button1) self.lang_choices.Bind( wx.EVT_CHOICE, self.OnChangeLangage ) - self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.radio_default_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.otherdictpath.Bind( wx.EVT_FILEPICKER_CHANGED, self.selectdict) self.setparametres(parametres) self.SetSizer( bSizer1 ) @@ -2534,6 +2538,7 @@ class CorpusPref ( wx.Dialog ): self.check_tirets.SetValue(parametres['tiret']) self.check_tolist.SetValue(parametres['tolist']) self.check_ponct.SetValue(parametres['keep_ponct']) + self.defaultdictpath.SetValue(self.langues[0]) def doparametres(self) : parametres = {} @@ -2553,6 +2558,8 @@ class CorpusPref ( wx.Dialog ): parametres['tiret'] = self.check_tirets.GetValue() parametres['tolist'] = self.check_tolist.GetValue() parametres['keep_ponct'] = self.check_ponct.GetValue() + if self.radio_other_dict.GetValue() : + parametres['dictionary'] = self.otherdictpath.GetPath() for val in parametres : if isinstance(parametres[val], bool) : if parametres[val] : @@ -2562,10 +2569,21 @@ class CorpusPref ( wx.Dialog ): return parametres def OnChangeLangage(self, evt): - pass + self.defaultdictpath.SetValue(self.langues[self.lang_choices.GetSelection()]) def changedictchoice(self, evt): - pass + if self.radio_default_dict.GetValue() : + self.otherdictpath.Enable( False ) + self.m_sdbSizer1OK.Enable( True ) + else : + self.otherdictpath.Enable( True ) + if self.otherdictpath.GetPath() == '' : + self.m_sdbSizer1OK.Enable( False ) + + def selectdict(self, evt): + if self.otherdictpath.GetPath() != '' : + self.m_sdbSizer1OK.Enable( True ) + class ConcordList(wx.HtmlListBox): diff --git a/tabsplitvar.py b/tabsplitvar.py index 4deea43..73eca1e 100644 --- a/tabsplitvar.py +++ b/tabsplitvar.py @@ -13,6 +13,7 @@ from analysematrix import AnalyseMatrix from functions import exec_rcode, check_Rresult from dialog import FreqDialog from PrintRScript import PrintRScript +from tableau import Tableau class SplitMatrixFromVar(AnalyseMatrix): def doparametres(self, dlg=None) : @@ -25,6 +26,7 @@ class SplitMatrixFromVar(AnalyseMatrix): if val == wx.ID_OK : self.parametres['colsel'] = dial.m_listBox1.GetSelections() self.parametres['header'] = dial.header + self.parametres['tohistory'] = False else : self.parametres = None dial.Destroy() @@ -32,7 +34,10 @@ class SplitMatrixFromVar(AnalyseMatrix): def doanalyse(self): newtabs = self.tableau.splitfromvar(self.parametres['colsel'][0]) for mod in newtabs : - fout = self.tableau.pathout['%s.csv' % mod].replace(u'*','') - with open(fout, 'w') as f : - f.write('\n'.join(['\t'.join(line) for line in newtabs[mod]]).encode(self.parent.syscoding)) - print 'done!' \ No newline at end of file + tab = Tableau(self.ira, os.path.join(self.tableau.pathout['%s.csv' % mod]).replace(u'*','')) + if not os.path.exists(tab.pathout.dirout) : + os.mkdir(tab.pathout.dirout) + tab.linecontent = newtabs[mod] + tab.make_content_simple() + tab.parametres['matrix'] = tab.parametres['uuid'] + self.ira.tree.OnItemAppend(tab.parametres, select = False) \ No newline at end of file