chronology for windows
[iramuteq] / textlabbe.py
1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2016-2017 Pierre Ratinaud
4 #License: GNU/GPL
5
6 from chemins import ConstructPathOut, StatTxtPathOut, PathOut, ffr
7 from analysetxt import AnalyseText
8 import wx
9 import os
10 from functions import exec_rcode, progressbar, check_Rresult, CreateIraFile, print_liste, treat_var_mod, write_tab, DoConf, TGen
11 from dialog import OptLexi
12 import tempfile
13 from PrintRScript import LabbeScript
14 from time import sleep
15 import logging
16
17 log = logging.getLogger('iramuteq.labbe')
18
19 class DistLabbe(AnalyseText) :
20     def doanalyse(self) :
21         pathout = self.pathout.dirout
22         self.dictpathout = StatTxtPathOut(pathout)
23         self.parametres['ira'] = self.dictpathout['ira']
24         self.make_lexico()
25         if self.dlg :
26             try :
27                 self.dlg.Destroy()
28             except :
29                 pass
30
31     def preferences(self) :
32         listet = self.corpus.make_etoiles()
33         listet.sort()
34         variables = treat_var_mod(listet)
35         var = [v for v in variables]
36         dial = OptLexi(self.parent)
37         dial.listet = listet
38         dial.variables = var
39         for et in var :
40             dial.list_box_1.Append(et)
41         dial.CenterOnParent()
42         self.dialok = dial.ShowModal()
43         if self.dialok == wx.ID_OK :
44             if dial.choice.GetSelection() == 1 :
45                 ListEt = [listet[i] for i in dial.list_box_1.GetSelections()]
46             else :
47                 ListEt = variables[var[dial.list_box_1.GetSelections()[0]]]
48             self.listet = ListEt
49             self.listet.sort()
50             self.parametres['mineff'] = dial.spin.GetValue()
51             if dial.choice_indice.GetSelection() == 0 :
52                 self.parametres['indice'] = 'hypergeo'
53             else :
54                 self.parametres['indice'] = 'chi2'
55             self.parametres['typeformes'] = dial.typeformes.GetSelection()
56             self.parametres['clnb'] = len(ListEt)
57             dial.Destroy()
58             return self.parametres
59         else :
60             dial.Destroy()
61             return None
62
63     def make_lexico(self) :
64         mineff = self.parametres['mineff']
65         tabout = self.corpus.make_lexitable(mineff, self.listet, gram = self.parametres['typeformes'])
66         write_tab(tabout, self.dictpathout['tableafcm'])
67         #tabout = self.corpus.make_efftype_from_etoiles(self.listet)
68         #write_tab(tabout, self.dictpathout['tabletypem'])
69         if self.dlg :
70             self.dlg.Update(2, u'R...')
71         script = LabbeScript(self)
72         script.make_script()
73         self.doR(script.scriptout, dlg = self.dlg, message = 'R...')
74
75         if self.dlg :
76             self.dlg.Update(3, u'Chargement...')
77         afcf_graph_list = [[os.path.basename(self.dictpathout['afcf_row']), u'lignes'],\
78                             [os.path.basename(self.dictpathout['afcf_col']), u'colonnes']]
79         #afct_graph_list = [[os.path.basename(self.dictpathout['afct_row']), u'lignes'],\
80         #                    [os.path.basename(self.dictpathout['afct_col']), u'colonnes']]
81         print_liste(self.dictpathout['liste_graph_afcf'],afcf_graph_list)
82         #print_liste(self.dictpathout['liste_graph_afct'],afct_graph_list)