From: Pierre Date: Tue, 11 Feb 2014 13:02:28 +0000 (+0100) Subject: concordance and translation X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=commitdiff_plain;h=5d8c9f5cd6399fd4a7192b655b4aa0a7923d11b6 concordance and translation --- diff --git a/Liste.py b/Liste.py index 73d3f33..85abc69 100644 --- a/Liste.py +++ b/Liste.py @@ -71,6 +71,7 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self) self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED , self.OnPopupTwo, self) # for wxMSW self.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick) diff --git a/PrintRScript.py b/PrintRScript.py index d81d070..c84efa9 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2008-2011 Pierre Ratinaud -#Lisense: GNU/GPL +#License: GNU/GPL import tempfile from chemins import ffr @@ -390,15 +390,15 @@ write.csv2(gbcluster,file="%s") xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) """ % (DictChdTxtOut['AFC2DL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2], active=FALSE) """ % (DictChdTxtOut['AFC2DSL_OUT']) txt += """ if ((fin - debet) > 2) { - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2], active = FALSE) } """ % (DictChdTxtOut['AFC2DEL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col=TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col=TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2], active=FALSE) """ % (DictChdTxtOut['AFC2DCL_OUT']) # txt += """ # PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) @@ -855,6 +855,15 @@ class PrintSimiScript(PrintRScript) : if self.parametres['type_graph'] == 2 : type = 'rgl' if self.parametres['type_graph'] == 3 : graphnb = 1 + type = 'web' + dirout = os.path.dirname(self.pathout['mat01']) + while os.path.exists(os.path.join(dirout,'web_'+str(graphnb))): + graphnb +=1 + self.filename = ffr(os.path.join(dirout,'web_'+str(graphnb))) + os.mkdir(self.filename) + self.filename = os.path.join(self.filename, 'gexf.gexf') + if self.parametres['type_graph'] == 4 : + graphnb = 1 type = 'rglweb' dirout = os.path.dirname(self.pathout['mat01']) while os.path.exists(os.path.join(dirout,'webrgl_'+str(graphnb))): @@ -1045,7 +1054,7 @@ class PrintSimiScript(PrintRScript) : vertex.size <- NULL """ else : - print self.parametres + #print self.parametres if (self.parametres['type'] == 'clustersimitxt' and self.parametres.get('tmpchi', False)) or (self.parametres['type'] == 'simimatrix' and 'tmpchi' in self.parametres): txt += """ lchi <- read.table("%s") diff --git a/ProfList.py b/ProfList.py index b64d633..f564d60 100644 --- a/ProfList.py +++ b/ProfList.py @@ -134,7 +134,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col #events #self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) - #self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnPopupTwo, self) #self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected) self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick) @@ -147,6 +147,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col #for searching search_id = wx.NewId() searchall_id = wx.NewId() + concord_id = wx.NewId() self.parent.Bind(wx.EVT_MENU, self.onsearch, id = search_id) self.parent.Bind(wx.EVT_MENU, self.onsearchall, id = searchall_id) self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('F'), search_id), @@ -367,7 +368,11 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def onexport(self, evt) : if 'corpus' in dir(self.Source): corpus = self.Source.corpus - corpus.export_classe(self.Source.pathout['classe_%i_export.txt' % self.cl], self.cl) + if self.Source.parametres['classif_mode'] != 2 : + uci = False + else : + uci = True + corpus.export_classe(self.Source.pathout['classe_%i_export.txt' % self.cl], self.cl, uci = uci) dial = wx.MessageDialog(self, self.Source.pathout['classe_%i_export.txt' % self.cl], u"Export", wx.OK|wx.ICON_INFORMATION) dial.ShowModal() dial.Destroy() @@ -517,10 +522,14 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col dlg = progressbar(self, 2) corpus = self.Source.corpus uces = corpus.lc[self.cl-1] + if self.Source.parametres['classif_mode'] != 2 : + uci = False + else : + uci = True l = [] dlg.Update(1, u'Segments...') for i in range(2,10) : - li = corpus.find_segments_in_classe(uces, i, 1000) + li = corpus.find_segments_in_classe(uces, i, 1000, uci = uci) if li == [] : break else : @@ -545,7 +554,11 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col dlg = progressbar(self,maxi = 4) corpus = self.Source.corpus uces = corpus.lc[self.cl-1] - tab = corpus.make_table_with_classe(uces, self.la) + if self.Source.parametres['classif_mode'] != 2 : + uci = False + else : + uci = True + tab = corpus.make_table_with_classe(uces, self.la, uci = uci) tab.pop(0) dlg.Update(2, u'score...') if atype == 0 : @@ -558,7 +571,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col ntab2 = ntab2[:limite] nuces = [val[1] for val in ntab2] dlg.Update(3, u'concordancier...') - ucis_txt, ucestxt = doconcorde(corpus, nuces, self.la) + ucis_txt, ucestxt = doconcorde(corpus, nuces, self.la, uci = uci) dlg.Update(4, u'texte...') win = message(self, u"Segments de texte caractéristiques - Classe %i" % self.cl, (750, 600)) win.html = '\n' + '
'.join(['
'.join([ucis_txt[i], '
score : %.2f
' % ntab2[i][0], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n' @@ -650,7 +663,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col win.HtmlPage.SetPage(txt) win.Show(True) - def make_concord(self, uces, title, color = 'red') : corpus = self.Source.corpus ListWord = [self.getColumnText(self.GetFirstSelected(), 6)] @@ -659,9 +671,15 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col last = self.GetNextSelected(last) ListWord.append(self.getColumnText(last, 6)) ucef = [] - for word in ListWord : - ucef += list(set(corpus.getlemuces(word)).intersection(uces)) - ucis_txt, ucestxt = doconcorde(corpus, ucef, ListWord) + if self.Source.parametres['classif_mode'] != 2 : + for word in ListWord : + uci = False + ucef += list(set(corpus.getlemuces(word)).intersection(uces)) + else : + for word in ListWord : + ucef += list(set(corpus.getlemucis(word)).intersection(uces)) + uci = True + ucis_txt, ucestxt = doconcorde(corpus, ucef, ListWord, uci = uci) win = message(self, title, size=(750, 600)) win.html = ('\n

%s

' % ' '.join(ListWord)) + '
'.join(['
'.join([ucis_txt[i], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n' win.HtmlPage.SetPage(win.html) @@ -725,7 +743,10 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col rep = [] #FIXME : donner aussi eff reel a la place de nb uce for forme in lems[word].formes : - ucef = list(set(corpus.getworduces(forme)).intersection(uces)) + if self.Source.parametres['classif_mode'] != 2 : + ucef = list(set(corpus.getworduces(forme)).intersection(uces)) + else : + ucef = list(set(corpus.getworducis(forme)).intersection(uces)) #ucef = [uce for uce in corpus.formes[forme][1] if uce in uces] if ucef != [] : nb = len(ucef) diff --git a/iramuteq.py b/iramuteq.py index 6636b11..5d64a17 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2008-2012, Pierre Ratinaud -#Lisense: GNU GPL +#License: GNU GPL from optparse import OptionParser @@ -28,10 +28,7 @@ import logging #------------------------------------ import wx #import wx.aui -if wx.__version__ >= '2.11' : - import wx.lib.agw.aui as aui -else : - import aui +import wx.lib.agw.aui as aui import wx.html import wx.grid import wx.lib.hyperlink as hl @@ -40,7 +37,7 @@ from functions import BugReport, PlaySound, ReadLexique, History, DoConf, ReadDi from checkversion import NewVersion from guifunct import * from tableau import Tableau -from dialog import PrefDialog, EncodeDialog, CorpusPref +from dialog import PrefDialog, CorpusPref from tabfrequence import Frequences from tabchi2 import ChiSquare #from tabstudent import MakeStudent @@ -57,10 +54,10 @@ from textstat import Stat from textaslexico import Lexico from textsimi import SimiTxt, SimiFromCluster from textwordcloud import WordCloud, ClusterCloud -from profile_segment import ProfileSegment +#from profile_segment import ProfileSegment #from textcheckcorpus import checkcorpus from openanalyse import OpenAnalyse -from corpus import BuildFromAlceste, Builder +from corpus import Builder from sheet import MySheet from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut @@ -318,7 +315,7 @@ class IraFrame(wx.Frame): # f.write('') self.history = History(os.path.join(UserConfigPath, 'history.db')) self.tree = LeftTree(self) - self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption("Navigateur"). + self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Navigator").decode('utf8')). Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True). MinimizeButton(True)) @@ -494,7 +491,7 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" dlg = wx.MessageDialog(self, msg, u"Problème de configuration", wx.OK | wx.NO_DEFAULT | wx.ICON_WARNING) dlg.CenterOnParent() if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]: - evt.Veto() + pass dlg.Destroy() @@ -522,7 +519,7 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" dlg = wx.MessageDialog(self, u"Installation OK", u"Installation", wx.OK | wx.ICON_INFORMATION) dlg.CenterOnParent() if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]: - evt.Veto() + evt.Veto() def DisEnSaveTabAs(self, DISEN): #Disable SaveTabAs @@ -595,7 +592,7 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" inputname, self.input_path = OnOpen(self, "Texte") self.filename = self.input_path[0] if inputname: - self.OpenText() + self.OpenText() def OnViewData(self, event): print self.type @@ -617,7 +614,6 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" self._mgr.Update() def OpenText(self): - #dial = EncodeDialog(self) dlg = wx.ProgressDialog("Ouverture...", "Veuillez patienter...", maximum=2, @@ -735,7 +731,7 @@ Voulez-vous fermer quand même ?""" elif True in ListFile : remove = True if remove: - del self.DictTab[TabTitle] + del self.DictTab[TabTitle] else : self.LastTabClose() else : @@ -992,7 +988,7 @@ Voulez-vous fermer quand même ?""" self.res = DoSimi(self, param = None) #self.res = Verges(self) if self.res.val == wx.ID_OK : - PlaySound(self) + PlaySound(self) except : BugReport(self) ################################################################# @@ -1048,11 +1044,11 @@ Voulez-vous fermer quand même ?""" class IntroPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - #col = randint(0, 255) - #col1 = randint(0,255) - #col2 = randint(0,255) - col = 0 - bckgrdcolor = wx.Colour(col, col, col) + col = randint(0, 255) + col1 = randint(0,255) + col2 = randint(0,255) + col = 57 + bckgrdcolor = wx.Colour(col, col1, col2) self.SetBackgroundColour(bckgrdcolor) txtcolour = wx.Colour(250, 250, 250) linkcolor = wx.Colour(255, 0, 0) @@ -1094,7 +1090,7 @@ class IntroPanel(wx.Panel): self.hyper_lerass.UpdateLink() blank = wx.StaticText(PanelPres, -1, u'\n') blank1 = wx.StaticText(PanelPres, -1, u'\n') - labellicence = wx.StaticText(PanelPres, -1, u'Licence GNU GPL') + labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8')) labellicence.SetForegroundColour(txtcolour) labellicence.SetBackgroundColour(bckgrdcolor) labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright')) diff --git a/listlex.py b/listlex.py index 0de2997..409c9fc 100644 --- a/listlex.py +++ b/listlex.py @@ -243,7 +243,6 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor win = message(self, u"Segments de texte caractéristiques - %s" % self.first[ind], (750, 600)) win.html = '\n' + '
'.join(['
'.join([ucis_txt[i], '
score : %.2f
' % ntab2[i][0], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n' win.HtmlPage.SetPage(win.html) - #dlg.Destroy() win.Show(True) def OnPopupTwo(self, event):