X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=textwordcloud.py;h=6f75498c546f6210f95a7d88f4aeced14616b180;hp=ed4c1cfb4685a8ed8c105347aa8b30e89eca4317;hb=b97b227a7f3f45bf2258f12853e4de9d7aa39f96;hpb=1fbb2fcb56ff6f0e0a0fa67daf55dadced5d0341 diff --git a/textwordcloud.py b/textwordcloud.py index ed4c1cf..6f75498 100644 --- a/textwordcloud.py +++ b/textwordcloud.py @@ -2,17 +2,17 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2008-2009 Pierre Ratinaud -#Lisense: GNU/GPL +#License: GNU/GPL from analysetxt import AnalyseText from guifunct import getPage, getCorpus, SelectColumn -from ConfigParser import RawConfigParser -from functions import sortedby, progressbar, CreateIraFile, exec_rcode, check_Rresult, MessageImage +#from ConfigParser import RawConfigParser +from functions import sortedby, progressbar from dialog import StatDialog, PrefWordCloud from PrintRScript import WordCloudRScript #from ttparser import * import tempfile -from time import sleep +#from time import sleep import wx import os import logging @@ -25,6 +25,7 @@ class WordCloud(AnalyseText): self.parametres['type'] = 'wordcloud' #FIXME limit = 3 + self.dlg.Destroy() res = self.make_option() if res == wx.ID_OK : if self.parametres['mode'] == 2 : @@ -35,16 +36,20 @@ class WordCloud(AnalyseText): elif self.parametres['mode'] == 1 : self.actives = self.corpus.make_actives_limit(limit, 2) dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) - SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], dlg = True) - self.make_wordcloud() - script = WordCloudRScript(self) - script.make_script() - self.doR(script.scriptout, dlg = self.dlg, message = 'R...') + selectcol = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], dlg = True) + if selectcol.ok : + self.dlg = progressbar(self.ira, 2) + self.make_wordcloud() + script = WordCloudRScript(self) + script.make_script() + self.doR(script.scriptout, dlg = self.dlg, message = 'R...') + else : + return 'NOK' else : return 'NOK' - def make_option(self) : - dial = PrefWordCloud(self.ira) + def make_option(self, fromcluster = False) : + dial = PrefWordCloud(self.ira, fromcluster) dial.CenterOnParent() res = dial.ShowModal() if res == wx.ID_OK : @@ -61,6 +66,8 @@ class WordCloud(AnalyseText): self.parametres['col_bg'] = dial.color_bg.GetColour() self.parametres['mode'] = dial.typeformeschoice.GetSelection() self.parametres['svg'] = svg + if fromcluster : + self.parametres['indice'] = dial.indice.GetSelection() outgraph = os.path.join(os.path.dirname(self.pathout['zipf.png']), 'nuage_') nb = 1 if svg : @@ -77,3 +84,29 @@ class WordCloud(AnalyseText): act = ['\t'.join([act, `self.corpus.getlemeff(act)`]) for act in self.actives] with open(self.pathout['actives_eff.csv'], 'w') as f : f.write('\n'.join(act).encode(self.ira.syscoding)) + + +class ClusterCloud(WordCloud) : + def doanalyse(self) : + self.parametres['type'] = 'clustercloud' + #FIXME + limit = 2 + res = self.make_option(True) + if res == wx.ID_OK : + prof = self.parametres['clusterprof'] + del self.parametres['clusterprof'] + if self.parametres['indice'] == 0 : + tokeep = 1 + else : + tokeep = 2 + prof = [[val[0], int(round(val[tokeep]))] for val in prof] + with open(self.pathout['actives_eff.csv'], 'w') as f : + f.write('\n'.join(['\t'.join([val[0], `val[1]`]) for val in prof]).encode(self.ira.syscoding)) + dictcol = dict([[i, val] for i, val in enumerate(prof)]) + self.actives = [val[0] for val in prof] + SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], dlg = True) + script = WordCloudRScript(self) + script.make_script() + self.doR(script.scriptout, dlg = self.dlg, message = 'R...') + else : + return 'NOK'