From: pierre Date: Mon, 12 Feb 2024 15:29:16 +0000 (+0100) Subject: Merge branch '3.0' of http://www.iramuteq.org/git/iramuteq into 3.0 X-Git-Url: http://www.iramuteq.org/git?a=commitdiff_plain;h=af8c3ff85a3c867356cb6353ca0e9bfe414d5b76;hp=-c;p=iramuteq Merge branch '3.0' of iramuteq.org/git/iramuteq into 3.0 --- af8c3ff85a3c867356cb6353ca0e9bfe414d5b76 diff --combined iramuteq.py index fad74ea,a8afd32..3f5183b --- a/iramuteq.py +++ b/iramuteq.py @@@ -56,6 -56,7 +56,7 @@@ from tabfrequence import Frequences, Fr 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 @@@ -93,6 -94,7 +94,7 @@@ ID_CHECKCORPUS = wx.Window.NewControlId 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() @@@ -217,7 -219,8 +219,8 @@@ images_analyses = 'preferences' : 'preferences.png', 'exportmetatable' : 'exportmetatable.png', 'importdmi' : 'twitter.png', - 'labbe' : 'spec.png' + 'labbe' : 'spec.png', + 'categorisation' : 'spec.png', } @@@ -235,7 -238,10 +238,10 @@@ class IraFrame(wx.Frame) 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') @@@ -351,6 -357,7 +357,7 @@@ [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) : @@@ -426,7 -433,7 +433,7 @@@ # 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 @@@ -488,10 -495,10 +495,10 @@@ #------------------------------------------------------------------------------------------------ # 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 #------------------------------------------------------------------------------------------------ @@@ -504,7 -511,7 +511,7 @@@ Name("lefttree"). Caption(_("Historic")). Left(). - MinSize(wx.Size(200,500)). + MinSize(wx.Size(300,400)). Layer(1). Position(1). CloseButton(False). @@@ -602,6 -609,7 +609,7 @@@ 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) #??? @@@ -700,10 -708,14 +708,14 @@@ 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: @@@ -740,23 -752,16 +752,23 @@@ # 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' : @@@ -764,9 -769,9 +776,9 @@@ 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 @@@ -914,7 -919,6 +926,7 @@@ Inc., 59 Temple Place - Suite 330, Bost # action ou évènement ? def OnPageChanged(self, event) : + print("OnPageChange") new = event.GetSelection() nobject = event.GetEventObject() parent = nobject.GetParent() @@@ -923,13 -927,14 +935,13 @@@ 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): @@@ -971,6 -976,7 +983,6 @@@ pane.Hide() self._mgr.GetPane(panel).Show() self._mgr.Update() - print('show a pane refresh') wx.CallAfter(self.nb.SendSizeEvent) self.Refresh() @@@ -1022,6 -1028,10 +1034,10 @@@ 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() diff --combined layout.py index c8532d4,7c7edd9..fec0197 --- a/layout.py +++ b/layout.py @@@ -38,6 -38,7 +38,7 @@@ from PrintRScript import write_afc_grap 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 @@@ -250,7 -251,7 +251,7 @@@ class GraphPanelAfc(wx.Panel) """ 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) @@@ -990,7 -991,7 +991,7 @@@ class GraphPanelDendro(wx.Panel) """ % (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) @@@ -1205,7 -1206,7 +1206,7 @@@ def blender(self) """ # 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) @@@ -1398,6 -1399,11 +1399,11 @@@ class ProtoLayout(DefaultMatLayout) #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) : @@@ -1423,7 -1429,7 +1429,7 @@@ #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 : @@@ -1436,7 -1442,6 +1442,7 @@@ 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() @@@ -1451,7 -1456,7 +1457,7 @@@ 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() @@@ -1579,7 -1584,7 +1585,7 @@@ #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) diff --combined tableau.py index 5760ad7,7325279..1be437b --- a/tableau.py +++ b/tableau.py @@@ -173,7 -173,6 +173,6 @@@ class Tableau() 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) @@@ -181,7 -180,7 +180,7 @@@ 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 @@@ -207,12 -206,12 +206,12 @@@ 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) : @@@ -234,11 -233,11 +233,11 @@@ 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) @@@ -287,10 -286,9 +286,9 @@@ 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) : @@@ -300,10 -298,10 +298,10 @@@ 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) : @@@ -321,7 -319,7 +319,7 @@@ 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) : @@@ -331,15 -329,15 +329,15 @@@ #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 = [] @@@ -378,9 -376,9 +376,9 @@@ 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[:]