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))
}
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()
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'])
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]
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)
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 :
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
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 )
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 )
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 )
self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
if "gtk2" in wx.PlatformInfo:
self.tab.SetStandardFonts()
+ print self.pathout['resultats.html']
self.tab.LoadPage(self.pathout['resultats.html'])
self.tab.parametres = self.parametres
self.ira.nb.AddPage(self.tab, u"Fréquences")
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()
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)
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'))
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