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
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'] == 'simi' :
66 # #if self.conf['type'] in ['analyse','lexico','stat','wordcloud'] :
67 # # self.corpus = Corpus(parent)
68 # if 'analyse' in self.conf.sections() :
69 # DictPathOut=ChdTxtPathOut(os.path.dirname(filename))
70 # self.pathout = os.path.dirname(filename)
71 # self.DictPathOut=DictPathOut
72 # #self.corpus = Corpus(parent)
73 # self.corpus.dictpathout = self.DictPathOut
74 # self.corpus.read_corpus_from_shelves(self.DictPathOut['db'])
75 # self.corpus.parametre['analyse'] = 'alceste'
76 # self.corpus.make_lem_type_list()
77 # # print 'EXTRACT NR'
78 # # self.corpus.extractnr()
80 # #self.corpus.save_corpus(self.corpus.dictpathout['db'])
81 # #self.corpus.make_uci_stat()
82 # #self.corpus.make_et_table()
83 # #self.corpus.prof_type()
84 # #self.corpus.make_type_tot()
85 # #self.corpus.make_size_uci()
86 # #self.corpus.get_stat_by_cluster()
87 # OpenCHDS(parent, self, filename, Alceste)
88 # self.parent.ShowMenu(_("Text analysis"))
89 # self.parent._mgr.Update()
90 # elif 'questionnaire' in self.conf.sections() :
91 # self.DictPathOut=ChdTxtPathOut(os.path.dirname(filename))
92 # self.pathout = os.path.dirname(filename)
93 # self.tableau = Tableau(parent, filename)
94 # self.tableau.dictpathout = self.DictPathOut
95 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
96 # OpenCHDS(parent, self, filename, False)
97 # elif 'simi' in self.conf.sections():
98 # self.tableau = Tableau(parent, filename)
99 # self.DictPathOut=construct_simipath(os.path.abspath(os.path.dirname(filename)))
100 # self.tableau.dictpathout = self.DictPathOut
101 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
102 # if self.tableau.parametre.get('fromtxt', False) :
103 # self.corpus=Corpus(parent)
104 # self.corpus.read_corpus_from_shelves(self.DictPathOut['corpus'])
105 # self.corpus.parametre['openpath'] = os.path.dirname(filename)
106 # self.parent.ShowMenu(_("Text analysis"))
107 # DoSimi(parent, self.conf, isopen = True, filename = filename, gparent = self, openfromprof=simifromprof)
108 # elif 'lexico' in self.conf.sections():
110 # #self.corpus = Corpus(parent)
111 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
112 # self.parent.ShowMenu(_("Text analysis"))
113 # dolexlayout(parent, self, filename)
114 # elif 'stat' in self.conf.sections():
116 # #self.corpus = Corpus(parent)
117 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
118 # self.parent.ShowMenu(_("Text analysis"))
119 # StatLayout(parent, self, filename)
120 # elif 'chd_dist_quest' in self.conf.sections():
121 # self.DictPathOut = ChdTxtPathOut(os.path.dirname(filename))
122 # self.pathout = os.path.dirname(filename)
123 # self.tableau = Tableau(parent, filename)
124 # self.tableau.dictpathout = self.DictPathOut
125 # self.tableau.read_tableau(self.tableau.dictpathout['db'])
126 # OpenCHDS(parent, self, filename, False)
127 # elif 'wordcloud' in self.conf.sections() :
128 # self.corpus.dictpathout = StatTxtPathOut(os.path.dirname(filename))
129 # self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
130 # self.parent.ShowMenu(_("Text analysis"))
131 # WordCloudLayout(parent, self, filename)
132 # if self.conf.sections()[0] in ['analyse','lexico','stat','wordcloud'] :
133 # self.corpus.parametre['openpath'] = os.path.dirname(filename)
135 # BugReport(self.parent)