- outgraph = outgraph + str(nb) + '.png'
-
- txt = """
- source("%s")
- library(wordcloud)
- act <- read.csv2("%s", header = FALSE, row.names = 1)
- maxword <- %i
- maxtoprint <- ifelse(nrow(act) > maxword, maxword, nrow(act))
- toprint <- act[1:maxtoprint,]
- open_file_graph("%s", width = %i, height = %i)
- par(bg=rgb%s)
- wordcloud(row.names(toprint), toprint[,1], scale=c(%f,%f), random.order=FALSE, colors=rgb%s)
- dev.off()
- """ % (self.parent.RscriptsPath['Rgraph'], ffr(os.path.join(self.pathout, 'actives.csv')), maxword, ffr(outgraph), width, height, col_bg, maxcex, mincex, col_text)
- tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
- with open(tmpscript, 'w') as f :
- f.write(txt)
- pid = exec_rcode(self.parent.RPath, tmpscript, wait = False)
- while pid.poll() == None :
- self.dlg.Pulse('R...')
- sleep(0.2)
- check_Rresult(self.parent, pid)
- self.corpus.save_corpus(self.dictpathout['db'])
- CreateIraFile(self.dictpathout, 0, corpname = os.path.basename(self.corpus.parametre['filename']), section =
- 'wordcloud')
- #win = MessageImage(self.parent, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
- #win.imagename = "nuage.png"
- #win.addsaveimage(outgraph)
- #txt = "<img src='%s'>" % FFF(outgraph).replace('//','/')
- #win.HtmlPage.SetPage(txt)
- #win.Show(True)
- if not self.cmd :
- #OpenAnalyse(self.parent, self.dictpathout['ira'])
- #self.DoLayout(self.parent)
- OpenAnalyse(self.parent, self.dictpathout['ira'])
- self.dlg.Update(7, 'fini')
- self.dlg.Destroy()
+ self.parametres['graphout'] = outgraph + str(nb) + end
+ dial.Destroy()
+ return res
+
+ def make_wordcloud(self) :
+ act = ['\t'.join([act, repr(self.corpus.getlemeff(act))]) for act in self.actives]
+ with open(self.pathout['actives_eff.csv'], 'w') as f :
+ f.write('\n'.join(act))
+
+
+class ClusterCloud(WordCloud):
+
+ def doanalyse(self):
+ print('ClusterCloud')
+ self.parametres['type'] = 'clustercloud'
+ #FIXME
+ limit = 2
+ res = self.make_option(True) #dialogue d'options de WordCloud.make_option
+ 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], repr(val[1])]) for val in prof]))
+ 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()
+
+ dialProgression = progressbar(self.ira, self.dlg)
+ self.doR(script.scriptout, dlg = dialProgression, message = 'R...')
+ dialProgression.Destroy()
+
+ else:
+ return 'NOK'
+