X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=textwordcloud.py;h=8022af6ff130e30cb6ddd4bd9b55bc1758769794;hp=b56d16d3d73d5a32db8900c64783bcb3bc9679ce;hb=fc14fc86c13eb0ed0f420771b08cc42a5db90c01;hpb=44b2ba75167b1ed5508e2f110130805bfe43a3bd diff --git a/textwordcloud.py b/textwordcloud.py index b56d16d..8022af6 100644 --- a/textwordcloud.py +++ b/textwordcloud.py @@ -4,20 +4,17 @@ #Copyright (c) 2008-2009 Pierre Ratinaud #Lisense: GNU/GPL -from chemins import ConstructPathOut, StatTxtPathOut, ffr, FFF -#from corpus import Corpus 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 dialog import StatDialog, PrefWordCloud -#from openanalyse import OpenAnalyse +from PrintRScript import WordCloudRScript #from ttparser import * import tempfile from time import sleep import wx import os -#from corpusNG import Corpus import logging logger = logging.getLogger('iramuteq.textwordcloud') @@ -27,10 +24,17 @@ class WordCloud(AnalyseText): def doanalyse(self) : self.parametres['type'] = 'wordcloud' #FIXME - self.actives = self.corpus.make_actives_limit(3) - 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']) + limit = 3 self.make_option() + if self.parametres['mode'] == 2 : + self.actives = self.corpus.make_actives_limit(limit, 1) + self.actives += self.corpus.make_actives_limit(limit, 2) + elif self.parametres['mode'] == 0 : + self.actives = self.corpus.make_actives_limit(limit, 1) + 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() @@ -41,24 +45,25 @@ class WordCloud(AnalyseText): dial.CenterOnParent() res = dial.ShowModal() if res == wx.ID_OK : - self.parametres['width'] = pref.spin_L.GetValue() - self.parametres['height'] = pref.spin_H.GetValue() - #maxword = pref.spin_maxword.GetValue() - self.parametres['mincex'] = float(pref.spin_mincex.GetValue())/float(10) - self.parametres['maxcex'] = float(pref.spin_maxcex.GetValue())/float(10) - self.parametres['col_text'] = pref.color_text.GetColour() - self.parametres['col_bg'] = pref.color_bg.GetColour() + self.parametres['width'] = dial.spin_L.GetValue() + self.parametres['height'] = dial.spin_H.GetValue() + self.parametres['maxword'] = dial.spin_maxword.GetValue() + self.parametres['mincex'] = float(dial.spin_mincex.GetValue())/float(10) + self.parametres['maxcex'] = float(dial.spin_maxcex.GetValue())/float(10) + self.parametres['col_text'] = dial.color_text.GetColour() + self.parametres['col_bg'] = dial.color_bg.GetColour() + self.parametres['mode'] = dial.typeformeschoice.GetSelection() outgraph = os.path.join(os.path.dirname(self.pathout['zipf.png']), 'nuage_') nb = 1 while os.path.exists(outgraph + str(nb) + '.png') : nb += 1 - self.parametres['outgraph'] = outgraph + str(nb) + '.png' + self.parametres['graphout'] = outgraph + str(nb) + '.png' def make_wordcloud(self) : - act = [[act, self.corpus.getlemeff(act)] for act in self.actives] + 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('\t'.join([[val[0], `val[1]`] for val in act]))) + f.write('\n'.join(act).encode(self.ira.syscoding)) #################################################################### # self.conf = None # self.parent = parent