from tableau import Tableau
from tabrsimple import InputText
from tabsimi import DoSimi
+ from tabcatego import Categorisation
from tabsplitvar import SplitMatrixFromVar
from tabverges import Prototypical
from textaslexico import Lexico
ID_Tabcontent = wx.Window.NewControlId()
ID_AFCM = wx.Window.NewControlId()
ID_SIMI = wx.Window.NewControlId()
+ ID_CATE = wx.Window.NewControlId()
ID_CloseTab = wx.Window.NewControlId()
ID_SaveTab = wx.Window.NewControlId()
ID_CreateText = wx.Window.NewControlId()
'preferences' : 'preferences.png',
'exportmetatable' : 'exportmetatable.png',
'importdmi' : 'twitter.png',
- 'labbe' : 'spec.png'
+ 'labbe' : 'spec.png',
+ 'categorisation' : 'spec.png',
}
wx.CLIP_CHILDREN):
log.info('Starting Iramuteq... ' )
log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
+ print(size)
wx.Frame.__init__(self, parent, id, title, pos, size, style)
+ #Font
+ self.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
# configuration
self.AppliPath = AppliPath
self.images_path = os.path.join(AppliPath,'images')
[ID_SIMI, _("Similarities Analysis"), 'simimatrix'],
[ID_proto, _("Prototypical Analysis"), 'proto'],
[ID_Splitfromvar, _("Split from variable"), 'subcorpusmeta'],
+ [ID_CATE, _("ElCaTeGoRiZatoR"), 'categorisation'],
]
for analyse in matanalyses :
if not isinstance(analyse, dict) :
# min size for the frame itself isn't completely done.
# see the end up FrameManager::Update() for the test
# code. For now, just hard code a frame minimum size
- self.SetMinSize(wx.Size(400, 400))
+ self.SetMinSize(wx.Size(800, 600))
#--------------------------------------------------------------------
# barre d'outils : le menu de petits icones en haut de la fenetre
#------------------------------------------------------------------------------------------------
# fichier d'historique de Iramuteq
#------------------------------------------------------------------------------------------------
- #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
- # with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
- # f.write('')
- self.history = History(os.path.join(UserConfigPath, 'historyIramuteq'))
+ if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
+ with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
+ f.write('{}')
+ self.history = History(os.path.join(UserConfigPath, 'history.db'))
# l'extension ".db" est ajoutée automatiquement par le module
#------------------------------------------------------------------------------------------------
Name("lefttree").
Caption(_("Historic")).
Left().
- MinSize(wx.Size(200,500)).
+ MinSize(wx.Size(300,400)).
Layer(1).
Position(1).
CloseButton(False).
self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
+ self.Bind(wx.EVT_MENU, self.OnCategorisation, id = ID_CATE)
#self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE) #???
#self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR) #???
#self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS) #???
BestRPath = False
if not CheckRPath(self.PathPath) :
if sys.platform == 'win32':
- if os.path.exists(self.AppliPath + '\\R\\R') :
+ if os.path.exists(self.AppliPath + '\\R\\R\\x64\\R.exe') :
BestRPath = self.AppliPath + '\\R\\R\\bin\\x64\\R.exe'
+ elif os.path.exists(self.AppliPath + '\\R\\R\\i386\\R.exe') :
+ BestRPath = self.AppliPath + '\\R\\R\\bin\\i386\\R.exe'
else :
BestRPath = FindRPAthWin32()
+ elif os.path.exists(self.AppliPath + '/R/R') :
+ BestRPath = self.AppliPath + '/R/R'
else:
BestRPath = FindRPathNix()
if BestRPath:
# vu comme elle est écrite, impossible de gérer
# l'affichage/masquage des toolbars en fonction du contexte
def ShowMenu(self, menu, Show=True):
+ print("showmenu")
if menu == 'text' :
menu_pos = 4
if Show :
self._mgr.GetPane('tb_text').Show()
+ self._mgr.GetPane('tb_mat').Hide()
+ self.mb.EnableTop(menu_pos, Show)
+ self.mb.EnableTop(3, False)
else :
self._mgr.GetPane('tb_text').Hide()
elif menu == 'matrix' :
menu_pos = 3
if Show :
self._mgr.GetPane('tb_mat').Show()
+ self._mgr.GetPane('tb_text').Hide()
+ self.mb.EnableTop(menu_pos, Show)
+ self.mb.EnableTop(4, False)
else :
self._mgr.GetPane('tb_mat').Hide()
elif menu == 'view' :
else :
menu_pos = None
if not menu_pos is None :
- self.mb.EnableTop(menu_pos, Show)
+ #self.mb.EnableTop(menu_pos, Show)
self.mb.Refresh()
- #self._mgr.Update()
+ self._mgr.Update()
#--------------------------------------------------------------------
# fin de __init__ du wx.Frame
# action ou évènement ?
def OnPageChanged(self, event) :
+ print("OnPageChange")
new = event.GetSelection()
nobject = event.GetEventObject()
parent = nobject.GetParent()
if 'parametres' in dir(npage) :
#self.tree.GiveFocus(uuid=npage.parametres['uuid'])
if npage.parametres.get('matrix', False) :
- self.ShowMenu('text', False)
+ #self.ShowMenu('text', False)
self.ShowMenu('matrix', True)
elif npage.parametres.get('corpus', False) :
self.ShowMenu('text')
- self.ShowMenu('matrix', False)
- #self._mgr.Update()
- #wx.CallAfter(self.nb.SendSizeEvent)
- #self.Refresh()
+ #self.ShowMenu('matrix', False)
+ wx.CallAfter(self.nb.SendSizeEvent)
+ self.Refresh()
# action ou évènement ?
def OnCloseTab(self, evt):
pane.Hide()
self._mgr.GetPane(panel).Show()
self._mgr.Update()
- print('show a pane refresh')
wx.CallAfter(self.nb.SendSizeEvent)
self.Refresh()
def OnSimiTab(self, event, matrix = None):
self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
+ def OnCategorisation(self, event, matrix = None) :
+ self.analyse_matrix(Categorisation, matrix = matrix, analyse_type = 'categorisation', dlgnb = 1)
+
+
def OnCHDReinert(self, event, matrix = None):
#if matrix is None :
# matrix = self.tree.getmatrix()
from profile_segment import ProfileSegment
from listlex import *
from Liste import *
+ from elcategorizator import ElCategorizator
from search_tools import SearchFrame
from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro, SimpleDialog, ImageViewer
from guifunct import SelectColumn, PrepSimi, PrefSimi, redosimi
"""
txt += write_afc_graph(self)
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
pid = exec_rcode(self.ira.RPath, filetmp)
check_Rresult(self.ira, pid)
""" % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
tmpfile = tempfile.mktemp()
# ecriture du fichier de script à éxécuter
- with open(tmpfile, 'w') as f :
+ with open(tmpfile, 'w', encoding='utf8') as f :
f.write(txt)
# dialogue d'attente
busy = wx.BusyInfo(_("Please wait..."), self.parent)
"""
# ecriture du fichier de script à éxécuter
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
exec_rcode(self.ira.RPath, filetmp)
GraphToJson(nodesfile, edgesfile, jsonout)
#self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
#self.ira.ShowAPane("Tab_content")
+ class CateLayout(DefaultMatLayout) :
+
+ def dolayout(self) :
+ TabCate = ElCategorizator(self.ira.nb, self.pathout, self.tableau)
+ self.ira.nb.AddPage(TabCate, ' - '.join([_('ElCaTeGoRiZaToR'), self.parametres['name']]))
class SimiMatLayout(DefaultMatLayout) :
#self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
def redosimi(self,evt) :
- with open(self.pathout['selected.csv'],'r') as f :
+ with open(self.pathout['selected.csv'],'r', encoding='utf8') as f :
selected = f.read()
selected = [int(val) for val in selected.splitlines()]
#if self.actives is None :
actives = [[val, self.tableau.actives[val]] for val in self.tableau.actives]
#self.tableau.make_listactives()
actives = dict([[i, val] for i, val in enumerate(actives)])
+ print(actives)
#dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives)
self.dial.CenterOnParent()
indexes.append(self.dial.listcol.getColumnText(last,0))
self.column = [self.tableau.listactives.index(val) for val in indexes]
self.column.sort()
- with open(self.pathout['selected.csv'], 'w') as f :
+ with open(self.pathout['selected.csv'], 'w', encoding='utf8') as f :
f.write('\n'.join([repr(val) for val in self.column]))
self.make_param()
self.dial.Destroy()
#saveAsGEXF(graph, filepath = fileout)
""" % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout)
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
exec_rcode(self.ira.RPath, filetmp)
mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK)
self.read_ods()
self.parametres['csvfile'] = os.path.join(self.parametres['pathout'], 'csvfile.csv')
self.make_tmpfile()
- print(self.parametres)
DoConf().makeoptions(['matrix'],[self.parametres], self.parametres['ira'])
self.parent.history.addMatrix(self.parametres)
self.parametres['csvfile'] = os.path.join(self.parametres['pathout'], 'csvfile.csv')
self.make_tmpfile()
DoConf().makeoptions(['matrix'],[self.parametres], self.parametres['ira'])
- self.parent.history.addMatrix(self.parametres)
+ self.parent.history.addMatrix(self.parametres)
def read_xls(self) :
#FIXME : encodage
def read_csv(self) :
with codecs.open(self.parametres['originalpath'], 'r', self.parametres['encodage']) as f :
- content = f.read()
+ content = f.read()
self.linecontent = [line.split(self.parametres['colsep']) for line in content.splitlines()]
self.linecontent = [[val.replace('"','').replace(';',' ').replace('\t', ' ').strip() for val in line] for line in self.linecontent]
def write_csvfile(self) :
- with open(self.parametres['csvfile'], 'w') as f :
+ with open(self.parametres['csvfile'], 'w', encoding='utf8') as f :
f.write('\n'.join(['\t'.join(line) for line in self.csvtable]))
def make_tmpfile(self) :
else :
self.rownames = [repr(i) for i in range(self.rownb)]
self.idname = 'identifiant'
- self.csvtable = [[self.idname] + self.colnames] + [[self.rownames[i]] + self.linecontent[i] for i in range(len(self.rownames))]
+ self.csvtable = [[self.idname] + self.colnames] + [[self.rownames[i]] + self.linecontent[i] for i in range(len(self.rownames))]
self.write_csvfile()
def read_csvfile(self):
- with codecs.open(self.parametres['csvfile'], 'r', self.parametres['syscoding']) as f:
+ with open(self.parametres['csvfile'], 'r', encoding='utf8') as f:
self.csvtable = [line.split('\t') for line in f.read().splitlines()]
self.linecontent = [line[1:] for line in self.csvtable]
self.linecontent.pop(0)
def getactlistfromselection(self, listact) :
selcol = self.select_col(listact)
self.actives = self.make_dico(selcol)
- return [[val, self.actives[val][0]] for val in self.actives]
+ return [[val, self.actives[val][0]] for val in self.actives]
def make_listactives(self) :
- print(self.actives, self.parametres['mineff'])
self.listactives = [val for val in self.actives if val != 'NA' and self.actives[val][0] >= self.parametres['mineff']]
def write01(self, fileout, dico, linecontent) :
for i, forme in enumerate(self.listactives) :
for line in dico[forme][1] :
out[line][i] = '1'
- #out = [[self.rownames[i]] + out[i] for i in range(len(linecontent))]
+ #out = [[self.rownames[i]] + out[i] for i in range(len(linecontent))]
#out.insert(0,[self.idname] + self.listactives)
out.insert(0, self.listactives)
- with open(fileout, 'w') as f :
+ with open(fileout, 'w', encoding='utf8') as f :
f.write('\n'.join([';'.join(line) for line in out]))
def make_01_from_selection(self, listact, listsup = None, dowrite = True) :
if forme[0] == '*':
UpdateDico(self.sups, forme, i)
else:
- UpdateDico(self.actives, forme, i)
+ UpdateDico(self.actives, forme, i)
self.listactives = [val for val in self.actives if self.actives[val][0] >= self.parametres['mineff']]
table = [['0' for i in range(len(self.listactives))] for j in range(self.rownb)]
for i, val in enumerate(self.listactives) :
#table = [[self.rownames[i]] + table[i] for i in range(len(self.rownames))]
#table.insert(0, [self.idname] + self.listactives)
table.insert(0, self.listactives)
- with open(fileout, 'w') as f:
+ with open(fileout, 'w', encoding='utf8') as f:
f.write('\n'.join([';'.join(line) for line in table]))
def printtable(self, filename, Table, sep = ';'):
- with open(filename, 'w') as f :
+ with open(filename, 'w', encoding='utf8') as f :
f.write('\n'.join([sep.join(line) for line in Table]))
def buildprofil(self) :
- with open(self.pathout['uce'], 'r') as filein :
+ with open(self.pathout['uce'], 'r', encoding='utf8') as filein :
content = filein.readlines()
content.pop(0)
lsucecl = []
if sup in self.linecontent[uce]:
line[i + 1] += 1
tablecontet.append([line[0]] + [repr(don) for don in line if type(don) == type(1)])
-
+
self.printtable(self.pathout['ContEtOut'], tablecontet)
- self.printtable(self.pathout['Contout'], tablecont)
+ self.printtable(self.pathout['Contout'], tablecont)
def get_colnames(self) :
return self.colnames[:]