ident += 1
f.write('\n'.join([self.ucis[self.iduces[uce[0]].uci].paras[ident].encode(self.parametres['syscoding']), uce[1].encode(self.parametres['syscoding'])]) + '\n')
+ def export_meta_table(self, outf) :
+ metas = [[`i`] + text.etoiles[1:] for i, text in enumerate(self.ucis)]
+ longueur_max = max([len(val) for val in metas])
+ first = ['column_%i' % i for i in range(longueur_max)]
+ metas.insert(0, first)
+ with open(outf, 'w') as f :
+ f.write('\n'.join(['\t'.join(line) for line in metas]).encode(self.parametres['syscoding']))
+
def export_corpus_classes(self, outf, alc = True, lem = False, uci = False) :
ucecl = {}
for i, lc in enumerate(self.lc) :
indices_simi = [u'cooccurrence' ,'pourcentage de cooccurrence',u'Russel',u'Jaccard', 'Kulczynski1', 'Kulczynski2', 'Mountford', 'Fager', 'simple matching', 'Hamman', 'Faith', 'Tanimoto', 'Dice', 'Phi', 'Stiles', 'Michael', 'Mozley', 'Yule', 'Yule2', 'Ochiai', 'Simpson', 'Braun-Blanquet','Chi-squared', 'Phi-squared', 'Tschuprow', 'Cramer', 'Pearson', 'binomial']
+
+def open_folder(folder):
+ if sys.platform == "win32":
+ os.startfile(folder)
+ else:
+ opener ="open" if sys.platform == "darwin" else "xdg-open"
+ call([opener, folder])
+
def normpath_win32(path) :
if not sys.platform == 'win32' :
return path
import os
import sys
from copy import copy
-import dialog
+from dialog import FileOptionDialog, SelectColDial, OptLexi, PrefSimpleFile
from listlex import *
from vitemspicker import VItemsPicker, EVT_IP_SELECTION_CHANGED, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES
from functions import treat_var_mod
def get_table_param(self, filename) :
if getfileextension(filename) == '.csv':
- dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200),
+ dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE)
dlg.CenterOnParent()
val = dlg.ShowModal()
self.tableau.parametres['filetype'] = 'csv'
self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()]
elif getfileextension(filename) == '.xls' :
- dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
+ dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE)
dlg.CenterOnParent()
val = dlg.ShowModal()
self.tableau.parametres['sheetnb'] = dlg.spin1.GetValue()
self.tableau.parametres['filetype'] = 'xls'
elif getfileextension(filename) == '.ods':
- dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200),
+ dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE)
dlg.CenterOnParent()
val = dlg.ShowModal()
def __init__(self, parent, dictcol, actives, pathout, selected = None, dlg = False) :
self.ira = parent
if dlg :
- dial = dialog.SelectColDial(self.ira)
+ dial = SelectColDial(self.ira)
listcol = ListForSpec(dial, self, dictcol, ['eff'])
dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 )
dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK )
if 'bystar' in self.parametres :
if self.dial.check_bystar.GetValue() :
variables = treat_var_mod(self.parametres['stars'])
- vardial = dialog.OptLexi(parent, force_chi = True)
+ vardial = OptLexi(parent, force_chi = True)
vardial.listet = self.parametres['stars']
vardial.variables = [v for v in variables]
for et in vardial.variables :
self.tgens.Append(self.dial.m_textCtrl1.GetValue())
self.dial.Destroy()
evt.Skip()
+
+class ExportMetaTable :
+ def __init__(self, parent, corpus):
+ self.ira = parent
+ dial = PrefSimpleFile(self, self.ira, **{'mask' : '*.csv', 'title': _(u"meta-data table").decode('utf8')})
+ dial.fbb.SetValue(corpus.pathout['metadata.csv'])
+ dial.CenterOnParent()
+ res = dial.ShowModal()
+ if res == wx.ID_OK :
+ fileout = dial.fbb.GetValue()
+ dial.Destroy()
+ corpus.export_meta_table(fileout)
+ dlg = wx.MessageDialog(self.ira, _("Done !").decode('utf8'), _(u"Export meta-data").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
+ dlg.CenterOnParent()
+ dlg.ShowModal()
+ dlg.Destroy()
+ else :
+ dial.Destroy()
ID_Fact_xml = wx.NewId()
ID_Fact_mail = wx.NewId()
ID_Fact_copy = wx.NewId()
+ID_exportmeta = wx.NewId()
##########################################################
#elements de configuration
##########################################################
'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]},
[ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'],
[ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'],
- [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta']]
+ [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'],
+ ]
for analyse in matanalyses :
if not isinstance(analyse, dict) :
{'name' : _(u"Sub corpus").decode('utf8'),
'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'],
[ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]},
+ [ID_exportmeta, _(u"Export meta-data table").decode('utf8'), None],
]
for analyse in analyses_text :
self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
+ self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
self.Bind(wx.EVT_CLOSE, self.OnClose)
##################################################################
flags = self._mgr.GetAGWFlags()
ImportFactiva(self, 'euro')
except :
BugReport(self)
+
+ def OnExportMeta(self, evt, corpus = None):
+ if corpus is None :
+ corpus = self.tree.getcorpus()
+ try :
+ ExportMetaTable(self, corpus)
+ except :
+ BugReport(self)
def ExtractTools(self, evt) :
ID = evt.GetId()
from openanalyse import OpenAnalyse
from corpus import Corpus, copycorpus
from tableau import Tableau, copymatrix
-from functions import DoConf, GetTxtProfile, TGen, BugReport
+from functions import DoConf, GetTxtProfile, TGen, BugReport, open_folder
from profile_segment import ProfileSegment, ProfilType
from search_tools import SearchFrame
from dialog import PrefSimpleFile, PrefExport
rename = wx.MenuItem(menu, wx.ID_ANY, _(u"Rename").decode('utf8'))
rename.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_TIP, size = (16,16)))
menu.AppendItem(rename)
+
+ openfolder = wx.MenuItem(menu, wx.ID_ANY, _(u"Open directory").decode('utf8'))
+ openfolder.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FOLDER_OPEN, size = (16,16)))
+ menu.AppendItem(openfolder)
+
menu.AppendSeparator()
if 'corpus_name' in pydata :
self.Bind(wx.EVT_MENU, self.OnItemInfo, info)
self.Bind(wx.EVT_MENU, self.OnRename, rename)
self.Bind(wx.EVT_MENU, self.OnItemDelete, itemdelete)
+ self.Bind(wx.EVT_MENU, self.OnOpenFolder, openfolder)
#self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11)
#self.Bind(wx.EVT_MENU, self.OnItemAppend, item12)
self.history.update(pydata)
self.SetItemText(self.current, newname)
self.EnsureVisible(self.current)
+
+ def OnOpenFolder(self, evt):
+ try :
+ open_folder(os.path.dirname(self.pydata['ira']))
+ except :
+ print 'cannot open folder %s' % self.pydata.get('ira', 'noirapath')
def OnItemBackground(self, event):