self.Bind(wx.EVT_MENU, self.onwordgraph, id = self.idwordgraph)
self.Bind(wx.EVT_MENU, self.onproxe, id = self.popup_proxe)
self.Bind(wx.EVT_MENU, self.onlexdendro, id = self.idlexdendro)
- #self.Bind(wx.EVT_MENU, self.onexport, id = self.idexport)
+ self.Bind(wx.EVT_MENU, self.onexport, id = self.idexport)
# self.Bind(wx.EVT_MENU, self.on_export_classes, id = self.export_classes)
# self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
menu.Append(self.popupIDgraph, u"Graphe de la classe")
menu.Append(self.idseg, u"Segments répétés")
menu.Append(self.iducecarac, u"UCE caractéristiques")
- #menu.Append(self.idexport, 'Partitionner...')
+ menu.Append(self.idexport, 'Exporter...')
#menu.Append(self.popupID2, u"Concordancier")
# menu.Append(self.popupID3, "recharger")
def onexport(self, evt) :
if 'corpus' in dir(self.Source):
corpus = self.Source.corpus
- ClasseCHD(self.parent, corpus, self.cl)
+ corpus.export_classe(self.Source.pathout['classe_%i_export.txt' % self.cl], self.cl)
+ dial = wx.MessageDialog(self, self.Source.pathout['classe_%i_export.txt' % self.cl], u"Export", wx.ID_OK|wx.ICON_INFORMATION)
+ dial.ShowModal()
+ dial.Destroy()
+ #if 'corpus' in dir(self.Source):
+ # corpus = self.Source.corpus
+ #ClasseCHD(self.parent, corpus, self.cl)
def getselectedwords(self) :
words = [self.getColumnText(self.GetFirstSelected(), 6)]
f.write(etline.encode(self.parametres['syscoding']) + '\n')
f.write(guce.encode(self.parametres['syscoding']) + '\n\n')
+ def export_classe(self, outf, classe, lem = False) :
+ sts = self.lc[classe]
+ res = self.getconcorde(sts)
+ self.make_iduces()
+ with open(outf, 'w') as f :
+ for uce in res :
+ guce = uce[1]
+ f.write(' '.join(self.ucis[self.iduces[uce[0]].uci].etoiles).encode(self.parametres['syscoding']) + '\n')
+ if lem :
+ guce = ' '.join([self.formes[forme].lem for forme in guce.split()])
+ f.write(guce.encode(self.parametres['syscoding']) + '\n\n')
+
def make_and_write_sparse_matrix_from_uces(self, actives, outfile, listuce = False) :
log.info('make_and_write_sparse_matrix_from_uces %s' % outfile)
nbl = 0
self.lc0 = self.lc.pop(0)
#return ucecl
- def get_stat_by_cluster(self, outf) :
+ def get_stat_by_cluster(self, outf, lclasses = None) :
log.info('get_stat_by_cluster')
+ if lclasses is None :
+ lclasses = self.lc
t1 = time()
- occurrences = dict([[i + 1, 0] for i in range(len(self.lc))])
- formescl = dict([[i + 1, 0] for i in range(len(self.lc))])
- hapaxcl = dict([[i + 1, 0] for i in range(len(self.lc))])
- lenclasses = dict([[i+1,len(cl)] for i, cl in enumerate(self.lc)])
- sets = [set(cl) for cl in self.lc]
+ occurrences = dict([[i + 1, 0] for i in range(len(lclasses))])
+ formescl = dict([[i + 1, 0] for i in range(len(lclasses))])
+ hapaxcl = dict([[i + 1, 0] for i in range(len(lclasses))])
+ lenclasses = dict([[i+1,len(cl)] for i, cl in enumerate(lclasses)])
+ sets = [set(cl) for cl in lclasses]
for forme in self.formes :
formeuceeff = self.getformeuceseff(forme)
- for i, classe in enumerate(self.lc) :
+ for i, classe in enumerate(lclasses) :
concern = sets[i].intersection(formeuceeff.keys())
if len(concern) :
occurrences[i+1] += sum([formeuceeff[uce] for uce in concern])
formescl[i+1] += 1
if self.formes[forme].freq == 1 :
hapaxcl[i+1] += 1
- toprint = '\n'.join([';'.join([`i`, `occurrences[i]`, `formescl[i]`, `hapaxcl[i]`, `lenclasses[i]`, `float(hapaxcl[i])/float(formescl[i])`]) for i in occurrences])
- with open(outf, 'w') as f :
- f.write(toprint)
log.info('%f' % (time() - t1))
+ if outf is not None :
+ toprint = '\n'.join([';'.join([`i`, `occurrences[i]`, `formescl[i]`, `hapaxcl[i]`, `lenclasses[i]`, `float(hapaxcl[i])/float(formescl[i])`]) for i in occurrences])
+ with open(outf, 'w') as f :
+ f.write(toprint)
+ else :
+ return [[`occurrences[i]`, `formescl[i]`, `hapaxcl[i]`, `lenclasses[i]`, `float(hapaxcl[i])/float(formescl[i])`] for i in occurrences]
+
+ def get_stat_by_et(self, outf, etoiles) :
+ lclasses = [self.getucesfrometoile(etoile) for etoile in etoiles]
+ stats = self.get_stat_by_cluster(None, lclasses)
+ stats = [[etoiles[i]] + val for i, val in enumerate(stats)]
def gethapaxbyet(self, etoiles) :
hapaxuces = [self.getlemuces(forme)[0] for forme in self.lems if self.lems[forme].freq == 1]
def OnOpen(self, type):
if type == "Data":
- wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Clac|*.ods|Fichier excel|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
+ wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Calc|*.ods|Excel 97/2000/XP/2003|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
elif type == "Texte":
wildcard = "Fichier texte|*.txt|Tous les fichiers|*"
elif type == "Analyse":
self.Bind(wx.EVT_MENU, self.OnSpec, spec)
self.Bind(wx.EVT_MENU, self.OnSimiTxt, simi)
self.Bind(wx.EVT_MENU, self.OnWordCloud, wdc)
- elif pydata.get('type', False) == 'alceste' and pydata['uuid'] in self.parent.history.opened :
+ elif pydata.get('type', False) == 'alceste' and pydata['uuid'] in self.parent.history.opened :
openmenu = wx.Menu()
antipro = openmenu.Append(wx.ID_ANY, u"antiprofils")
menu.AppendMenu(wx.ID_ANY, u"Ouvrir...", openmenu)
self.Bind(wx.EVT_MENU, self.OnExportDictionary, export_dictionary)
self.Bind(wx.EVT_MENU, self.OnExportLems, export_lems)
menu.AppendSeparator()
+ elif pydata.get('type', False) == 'gnepamatrix' and pydata['uuid'] in self.parent.history.opened :
+ openmenu = wx.Menu()
+ antipro = openmenu.Append(wx.ID_ANY, u"antiprofils")
+ menu.AppendMenu(wx.ID_ANY, u"Ouvrir...", openmenu)
+ self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro)
+
itemdelete = menu.Append(wx.ID_ANY, "Supprimer de l'historique")
if item == self.GetRootItem():