2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2012, Pierre Ratinaud
7 from chemins import ChdTxtPathOut, StatTxtPathOut, construct_simipath
8 from layout import OpenCHDS, dolexlayout, StatLayout, WordCloudLayout, OpenCorpus, SimiLayout
9 #from corpus import Corpus
10 from corpusNG import Corpus, copycorpus
11 from tableau import Tableau
14 from ConfigParser import *
15 from tabsimi import DoSimi
16 from functions import BugReport, DoConf
19 log = logging.getLogger('iramuteq.openanalyse')
22 def __init__(self, parent, parametres, Alceste=True, simifromprof = False):
23 #self.conf = RawConfigParser()
24 #self.conf.read(filename)
25 log.info('OpenAnalyse')
27 if isinstance(parametres, dict) :
28 self.conf = DoConf(parametres['ira']).getoptions()
30 self.conf = DoConf(parametres).getoptions()
32 if self.conf.get('corpus', '!!') in self.parent.history.history :
33 if self.conf.get('corpus', '!!') in self.parent.history.openedcorpus :
34 log.info('corpus is already opened')
35 corpus = copycorpus(self.parent.history.openedcorpus[self.conf['corpus']])
37 if os.path.exists(self.parent.history.history[self.conf['corpus']]['ira']) :
38 corpus = Corpus(self, parametres = DoConf(self.parent.history.history[self.conf['corpus']]['ira']).getoptions('corpus'), read = self.parent.history.history[self.conf['corpus']]['ira'])
39 self.parent.history.openedcorpus[self.conf['corpus']] = corpus
40 if self.conf.get('lem',1) :
41 corpus.make_lems(True)
43 corpus.make_lems(False)
47 self.parent.history.addtab(self.conf)
49 def doopen(self, corpus) :
51 if self.conf['type'] == 'corpus' :
52 self.parent.ShowMenu(_("Text analysis"))
53 OpenCorpus(self.parent, self.conf)
54 elif self.conf['type'] == 'stat' :
55 self.parent.ShowMenu(_("Text analysis"))
56 StatLayout(self.parent, corpus, self.conf)
57 elif self.conf['type'] == 'spec' :
58 self.parent.ShowMenu(_("Text analysis"))
59 dolexlayout(self.parent, corpus, self.conf)
60 elif self.conf['type'] == 'alceste' :
61 self.parent.ShowMenu(_("Text analysis"))
62 OpenCHDS(self.parent, corpus, self.conf, Alceste = True)
63 elif self.conf['type'] == 'simitxt' :
64 self.parent.ShowMenu(_("Text analysis"))
65 SimiLayout(self.parent, corpus, self.conf)
66 #self.tableau = Tableau(self.parent, self.conf['ira'])
67 #self.DictPathOut=construct_simipath(self.conf['pathout'])
68 #self.tableau.dictpathout = self.DictPathOut
69 #self.tableau.read_tableau(self.tableau.dictpathout['db'])
70 #if self.tableau.parametre.get('corpus', False) :
72 #self.corpus.read_corpus_from_shelves(self.DictPathOut['corpus'])
73 # self.corpus.parametres['openpath'] = self.conf['pathout']
74 #DoSimi(self.parent, self.conf, isopen = True, filename = self.conf['ira'], gparent = self, openfromprof=False)
77 # #if self.conf['type'] in ['analyse','lexico','stat','wordcloud'] :
78 # # self.corpus = Corpus(parent)
79 # if 'analyse' in self.conf.sections() :
80 # DictPathOut=ChdTxtPathOut(os.path.dirname(filename))
81 # self.pathout = os.path.dirname(filename)
82 # self.DictPathOut=DictPathOut
83 # #self.corpus = Corpus(parent)
84 # self.corpus.dictpathout = self.DictPathOut
85 # self.corpus.read_corpus_from_shelves(self.DictPathOut['db'])
86 # self.corpus.parametre['analyse'] = 'alceste'
87 # self.corpus.make_lem_type_list()
88 # # print 'EXTRACT NR'
89 # # self.corpus.extractnr()
91 # #self.corpus.save_corpus(self.corpus.dictpathout['db'])
92 # #self.corpus.make_uci_stat()
93 # #self.corpus.make_et_table()
94 # #self.corpus.prof_type()
95 # #self.corpus.make_type_tot()
96 # #self.corpus.make_size_uci()
97 # #self.corpus.get_stat_by_cluster()
98 # OpenCHDS(parent, self, filename, Alceste)
99 # self.parent.ShowMenu(_("Text analysis"))
100 # self.parent._mgr.Update()
101 # elif 'questionnaire' in self.conf.sections() :
102 # self.DictPathOut=ChdTxtPathOut(os.path.dirname(filename))
103 # self.pathout = os.path.dirname(filename)
104 # self.tableau = Tableau(parent, filename)
105 # self.tableau.dictpathout = self.DictPathOut
106 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
107 # OpenCHDS(parent, self, filename, False)
108 # elif 'simi' in self.conf.sections():
109 # self.tableau = Tableau(parent, filename)
110 # self.DictPathOut=construct_simipath(os.path.abspath(os.path.dirname(filename)))
111 # self.tableau.dictpathout = self.DictPathOut
112 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
113 # if self.tableau.parametre.get('fromtxt', False) :
114 # self.corpus=Corpus(parent)
115 # self.corpus.read_corpus_from_shelves(self.DictPathOut['corpus'])
116 # self.corpus.parametre['openpath'] = os.path.dirname(filename)
117 # self.parent.ShowMenu(_("Text analysis"))
118 # DoSimi(parent, self.conf, isopen = True, filename = filename, gparent = self, openfromprof=simifromprof)
119 # elif 'lexico' in self.conf.sections():
121 # #self.corpus = Corpus(parent)
122 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
123 # self.parent.ShowMenu(_("Text analysis"))
124 # dolexlayout(parent, self, filename)
125 # elif 'stat' in self.conf.sections():
127 # #self.corpus = Corpus(parent)
128 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
129 # self.parent.ShowMenu(_("Text analysis"))
130 # StatLayout(parent, self, filename)
131 # elif 'chd_dist_quest' in self.conf.sections():
132 # self.DictPathOut = ChdTxtPathOut(os.path.dirname(filename))
133 # self.pathout = os.path.dirname(filename)
134 # self.tableau = Tableau(parent, filename)
135 # self.tableau.dictpathout = self.DictPathOut
136 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
137 # OpenCHDS(parent, self, filename, False)
138 # elif 'wordcloud' in self.conf.sections() :
139 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
140 # self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
141 # self.parent.ShowMenu(_("Text analysis"))
142 # WordCloudLayout(parent, self, filename)
143 # if self.conf.sections()[0] in ['analyse','lexico','stat','wordcloud'] :
144 # self.corpus.parametre['openpath'] = os.path.dirname(filename)
146 # BugReport(self.parent)