profile translation
[iramuteq] / ProfList.py
index da8d316..6b553e9 100644 (file)
@@ -31,12 +31,13 @@ from copy import copy
 
 #---------------------------------------------------------------------------
 class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
 
 #---------------------------------------------------------------------------
 class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
-    def __init__(self, parent, gparent, profclasse, Alceste=False, cl=0):
+    def __init__(self, parent, gparent, profclasse, Alceste=False, cl=0, translation = False):
         wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
 
         self.parent = parent
         self.Alceste = Alceste
         self.Source = gparent
         wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
 
         self.parent = parent
         self.Alceste = Alceste
         self.Source = gparent
+        self.translation = translation
         self.cl = cl
         self.var_mod = {}
         self.them_mod = {}
         self.cl = cl
         self.var_mod = {}
         self.them_mod = {}
@@ -714,7 +715,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
         words = self.getselectedwords()
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
         words = self.getselectedwords()
-        tableout = [vchistable[fchistable.index(word)] for word in words]
+        tableout = [vchistable[fchistable.index(self.getword(word))] for word in words]
         tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
         nbcl = len(title)
         nbwords = len(words)
         tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
         nbcl = len(title)
         nbwords = len(words)
@@ -733,9 +734,15 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
         words = self.getselectedwords()
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
         words = self.getselectedwords()
-        tableout = [vchistable[fchistable.index(word)] for word in words]
+        tableout = [vchistable[fchistable.index(self.getword(word))] for word in words]
         BarFrame(self.Source.parent, tableout, title, words, tree = self.Source.pathout['Rdendro'])
 
         BarFrame(self.Source.parent, tableout, title, words, tree = self.Source.pathout['Rdendro'])
 
+    def getword(self, word) :
+        if self.translation :
+            return self.lems[word]
+        else :
+            return word
+
     def make_concord(self, uces, title, color = 'red') :
         corpus = self.Source.corpus
         ListWord = [self.getColumnText(self.GetFirstSelected(), 6)]
     def make_concord(self, uces, title, color = 'red') :
         corpus = self.Source.corpus
         ListWord = [self.getColumnText(self.GetFirstSelected(), 6)]
@@ -744,6 +751,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             last = self.GetNextSelected(last)
             ListWord.append(self.getColumnText(last, 6))
         ucef = []
             last = self.GetNextSelected(last)
             ListWord.append(self.getColumnText(last, 6))
         ucef = []
+        ListWord = [self.getword(word) for word in ListWord]
         if self.Source.parametres['classif_mode'] != 2 :
             for word in ListWord :
                 uci = False
         if self.Source.parametres['classif_mode'] != 2 :
             for word in ListWord :
                 uci = False
@@ -811,6 +819,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         #print 'ATTENTION PRINT ET TABLE'
         #corpus.make_et_table()
         word = self.getColumnText(self.GetFirstSelected(), 6)
         #print 'ATTENTION PRINT ET TABLE'
         #corpus.make_et_table()
         word = self.getColumnText(self.GetFirstSelected(), 6)
+        word = self.getword(word)
         lems = corpus.getlems()
         uces = corpus.lc[self.cl-1]
         rep = []
         lems = corpus.getlems()
         uces = corpus.lc[self.cl-1]
         rep = []