Merge branch 'master' of http://www.iramuteq.org/git/iramuteq
authorpierre <ratinaud@univ-tlse2.fr>
Mon, 22 Sep 2014 09:22:45 +0000 (11:22 +0200)
committerpierre <ratinaud@univ-tlse2.fr>
Mon, 22 Sep 2014 09:22:45 +0000 (11:22 +0200)
Conflicts:
layout.py

PrintRScript.py
corpus.py
dialog.py
tabverges.py
tree.py

index b0e64b9..57a5f2d 100644 (file)
@@ -1161,6 +1161,10 @@ class ProtoScript(PrintRScript) :
     def make_script(self) :
         self.sources([self.analyse.parent.RscriptsPath['Rgraph'], self.analyse.parent.RscriptsPath['prototypical.R']])
         self.packages(['wordcloud'])
+        if self.parametres.get('cloud', False) :
+            cloud = 'TRUE'
+        else :
+            cloud = 'FALSE'
         txt = """
         errorn <- function(x) {
             qnorm(0.975)*sd(x)/sqrt(lenght(n))
@@ -1170,9 +1174,9 @@ class ProtoScript(PrintRScript) :
         }
         mat <- read.csv2("%s", header = FALSE, row.names=1, sep='\t', quote='"', dec='.')
         open_file_graph("%s",height=800, width=1000)
-        prototypical(mat, mfreq = %s, mrank = %s, cloud = FALSE, cexrange=c(1,2.4), cexalpha= c(0.4, 1))
+        prototypical(mat, mfreq = %s, mrank = %s, cloud = FALSE, cexrange=c(1,2.4), cexalpha= c(0.4, 1), type = '%s')
         dev.off()
-        """ % (self.analyse.pathout['table.csv'], self.analyse.pathout['proto.png'], self.parametres['limfreq'], self.parametres['limrang'])
+        """ % (self.analyse.pathout['table.csv'], self.analyse.pathout['proto.png'], self.parametres['limfreq'], self.parametres['limrang'], self.parametres['typegraph'])
         self.add(txt)
         self.write()
 
index 69539d3..d13b2f5 100644 (file)
--- a/corpus.py
+++ b/corpus.py
@@ -1309,13 +1309,13 @@ class BuildCorpus :
 
 class BuildSubCorpus(BuildCorpus):
     def __init__(self, corpus, parametres, dlg = None) :
-        print parametres
         log.info('begin subcorpus...')
         self.dlg = dlg
         self.ori = corpus
         self.infile = None
         self.corpus = Corpus(self, {'type' : 'corpus', 'originalpath' : corpus.parametres['originalpath'], 'encoding' : corpus.parametres['encoding']})
         self.last = 0
+        self.parametres = parametres
         self.encoding = corpus.parametres['encoding']
         self.corpus.parametres['corpus_name'] = parametres['corpus_name']
         self.corpus.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = parametres['pathout'])
@@ -1345,38 +1345,41 @@ class BuildSubCorpus(BuildCorpus):
                         self.corpus.ucis.append(nuci)
                 else :
                     idpara += 1  
-        elif parametres.get('fromcluster', False) :
-            pass
+        elif parametres.get('fromclusters', False) :
+            self.parametres['uceids'] = [st for i in self.parametres['meta'] for st in self.parametres['lc'][i]]
+            self.fromuceids()
         elif parametres.get('fromuceids', False) :
-            print 'fromuceids'
-            dictucekeep = dict(zip(parametres['uceids'], parametres['uceids']))
-            idpara = 0
-            for uci in self.ori.ucis :
-                if uci.paras == [] :
-                    keepuces = [CopyUce(uce) for uce in uci.uces if uce.ident in dictucekeep]
-                    if keepuces != [] :
-                        nuci = CopyUci(uci)
-                        nuci.uces = keepuces
-                        self.corpus.ucis.append(nuci)
-                    idpara += 1
-                else :
-                    newuces = []
-                    newpara = []
-                    for et in uci.paras :
-                        keepuces = [CopyUce(uce) for uce in uci.uces if uce.ident in dictucekeep]
-                        idpara += 1
-                        if keepuces != [] :
-                            newuces += keepuces
-                            newpara.append(et)
-                    if newuces != [] :
-                        nuci = CopyUci(uci)
-                        nuci.uces = newuces
-                        nuci.paras = newpara
-                        self.corpus.ucis.append(nuci)
-                        
+            self.fromuceids()
         #create database
         self.connect()
         self.dobuild()
+
+    def fromuceids(self):
+        print 'fromuceids'
+        dictucekeep = dict(zip(self.parametres['uceids'], self.parametres['uceids']))
+        idpara = 0
+        for uci in self.ori.ucis :
+            if uci.paras == [] :
+                keepuces = [CopyUce(uce) for uce in uci.uces if uce.ident in dictucekeep]
+                if keepuces != [] :
+                    nuci = CopyUci(uci)
+                    nuci.uces = keepuces
+                    self.corpus.ucis.append(nuci)
+                idpara += 1
+            else :
+                newuces = []
+                newpara = []
+                for et in uci.paras :
+                    keepuces = [CopyUce(uce) for uce in uci.uces if uce.ident in dictucekeep]
+                    idpara += 1
+                    if keepuces != [] :
+                        newuces += keepuces
+                        newpara.append(et)
+                if newuces != [] :
+                    nuci = CopyUci(uci)
+                    nuci.uces = newuces
+                    nuci.paras = newpara
+                    self.corpus.ucis.append(nuci)       
     
     def read_corpus(self, infile = None):
         self.olduceid = [uce.ident for uci in self.corpus.ucis for uce in uci.uces]
@@ -1566,9 +1569,12 @@ class SubBuilder :
             parametres['meta'] = corpus.make_etoiles()
         elif parametres.get('fromtheme', False) :
             parametres['meta'] = corpus.make_themes()
+        elif parametres.get('fromclusters', False) :
+            parametres['meta'] = [' '.join(['classe', `i`]) for i in range(1,parametres['clnb'] + 1)]
         else :
             parametres['meta'] = []
-        parametres['meta'].sort()
+        if 'fromclusters' not in parametres :
+            parametres['meta'].sort()
         if dlg is not None :
             del busy
         dial = SubTextFromMetaDial(parent, parametres)
@@ -1586,7 +1592,10 @@ class SubBuilder :
                 i += 1
             parametres['pathout'] = pathout + '_%i' % i
             meta = dial.m_listBox1.GetSelections()
-            parametres['meta'] = [parametres['meta'][val] for val in meta]
+            if not 'fromclusters' in parametres :
+                parametres['meta'] = [parametres['meta'][val] for val in meta]
+            else :
+                parametres['meta'] = meta
             self.parametres = parametres
             dial.Destroy()
         else :
@@ -1594,9 +1603,3 @@ class SubBuilder :
     
     def doanalyse(self):
         return BuildSubCorpus(self.ori, parametres = self.parametres, dlg = self.dlg).corpus
-
-if __name__ == '__main__' :
-    t1 = time()
-    parametres = {'formesdb':'formes.db', 'ucesdb': 'uces.db', 'corpusdb' : 'corpus.db', 'syscoding' : 'utf-8', 'encoding' : 'utf8'}
-    intro = BuildCorpus(infile, parametres)#, tar_in, tar_infouce)#, tar_formes)
-    print time() - t1
index bfc6178..b30dede 100755 (executable)
--- a/dialog.py
+++ b/dialog.py
@@ -2800,7 +2800,7 @@ class ProtoDial ( wx.Dialog ):
     def __init__( self, parent, headers ):
         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
         
-        self.SetSizeHintsSz( wx.Size( 200,300 ), wx.DefaultSize )
+        self.SetSizeHintsSz( wx.Size( -1,-1 ), wx.DefaultSize )
         
         bSizer1 = wx.BoxSizer( wx.VERTICAL )
         
@@ -2817,19 +2817,19 @@ class ProtoDial ( wx.Dialog ):
         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
         
         variablesChoices = headers
-        self.variables = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, variablesChoices, wx.LB_MULTIPLE )
-        self.variables.SetMinSize( wx.Size( 150,-1 ) )
+        self.variables = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, variablesChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
+        self.variables.SetMinSize( wx.Size( 350,-1 ) )
         
-        fgSizer1.Add( self.variables, 0, wx.ALL|wx.EXPAND, 5 )
+        fgSizer1.Add( self.variables, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
         
         rangsChoices = headers
-        self.rangs = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, rangsChoices, wx.LB_MULTIPLE )
-        self.rangs.SetMinSize( wx.Size( 150,-1 ) )
+        self.rangs = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, rangsChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
+        self.rangs.SetMinSize( wx.Size( 350,-1 ) )
         
-        fgSizer1.Add( self.rangs, 0, wx.ALL|wx.EXPAND, 5 )
+        fgSizer1.Add( self.rangs, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
         
         
-        bSizer1.Add( fgSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
+        bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL, 5 )
         
         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
         fgSizer3.SetFlexibleDirection( wx.BOTH )
@@ -2882,8 +2882,16 @@ class ProtoDial ( wx.Dialog ):
         self.m_textCtrl4 = wx.TextCtrl( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
         fgSizer3.Add( self.m_textCtrl4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
         
+        self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"Type de représentation", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText6.Wrap( -1 )
+        fgSizer3.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        m_choice3Choices = [ u"Classical - List", u"Classical - Cloud", u"Plan" ]
+        self.typegraph = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice3Choices, 0 )
+        self.typegraph.SetSelection( 0 )
+        fgSizer3.Add( self.typegraph, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
         
-        bSizer1.Add( fgSizer3, 1, wx.EXPAND, 5 )
+        bSizer1.Add( fgSizer3, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
         
         m_sdbSizer1 = wx.StdDialogButtonSizer()
         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
index b31bf7c..b56d42c 100644 (file)
@@ -56,6 +56,14 @@ class Prototypical(AnalyseMatrix) :
                     else :
                         self.parametres['limrang'] = self.dial.ranglim.GetValue()
                     self.parametres['freqmin'] = int(self.dial.m_textCtrl4.GetValue())
+                    if self.dial.typegraph.GetSelection() == 0 :
+                        self.parametres['typegraph'] = 'classical'
+                        self.parametres['cloud'] = False
+                    elif self.dial.typegraph.GetSelection() == 1 :
+                        self.parametres['typegraph'] = 'classical'
+                        self.parametres['cloud'] = True
+                    else :
+                        self.parametres['typegraph'] = 'plan'      
                     table_assoc, table_rank = self.dotable()
                     self.makedatas(table_assoc, table_rank)
                     self.DoR()
diff --git a/tree.py b/tree.py
index 82aada2..25106fa 100644 (file)
--- a/tree.py
+++ b/tree.py
@@ -440,7 +440,8 @@ class LeftTree(CT.CustomTreeCtrl):
                 navig = menu.Append(wx.ID_ANY, _(u"Navigator").decode('utf8'))
                 statclasse = menu.Append(wx.ID_ANY, _(u"Clusters statistics").decode('utf8'))
                 rapport = menu.Append(wx.ID_ANY, _(u"Report").decode('utf8'))
-                export_classes = menu.Append(wx.ID_ANY, _(u"Export Clusters").decode('utf8'))
+                export_classes = menu.Append(wx.ID_ANY, _(u"Export clusters").decode('utf8'))
+                subcorpusfromcl = menu.Append(wx.ID_ANY, _(u"Sub corpus from clusters").decode('utf8'))
                 menu.AppendSeparator()
                 self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro)
                 self.Bind(wx.EVT_MENU, self.OnProfSR, profsr)
@@ -451,6 +452,7 @@ class LeftTree(CT.CustomTreeCtrl):
                 self.Bind(wx.EVT_MENU, self.StatClasse, statclasse)
                 self.Bind(wx.EVT_MENU, self.OnRapport, rapport)
                 self.Bind(wx.EVT_MENU, self.OnExportClasses, export_classes)
+                self.Bind(wx.EVT_MENU, self.OnSubCorpusFromClusters, subcorpusfromcl)
             elif pydata.get('type', False) == 'stat'  and pydata['uuid'] in self.parent.history.opened :
                 export_dictionary =  menu.Append(wx.ID_ANY, _(u"Export dictionary").decode('utf8'))
                 export_lems =  menu.Append(wx.ID_ANY, _(u"Export lemma dictionary").decode('utf8'))
@@ -723,6 +725,9 @@ class LeftTree(CT.CustomTreeCtrl):
         dial.ShowModal()
         dial.Destroy()
     
+    def OnSubCorpusFromClusters(self, evt):
+        self.parent.OnSubText(self.getcorpus(), parametres = {'fromclusters' : True, 'clnb': self.page.parametres['clnb'], 'lc' : self.page.corpus.lc})
+    
     def OnRename(self, event):
         pydata = self.itemdict['pydata']
         print pydata