X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=tabverges.py;h=b56d42c81202fa2eb27f19d5ae22740ef4b4453a;hp=12f4a61e187ab6a92d3b1080b9b081bcf2a217e4;hb=9b78e6210e7fc88a7e77d178c4090aabb23580d9;hpb=2ffa9388c45dce689bb45c1cf6c7ad81d2636409 diff --git a/tabverges.py b/tabverges.py index 12f4a61..b56d42c 100644 --- a/tabverges.py +++ b/tabverges.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2012 Pierre Ratinaud -#Lisense: GNU GPL +#License: GNU GPL import os import string @@ -19,23 +19,23 @@ from analysematrix import AnalyseMatrix from dialog import ProtoDial class Prototypical(AnalyseMatrix) : - def __init__(self, parent, parametres): - self.parent = parent - self.tableau = self.parent.tableau - self.parametres = parametres - self.parametres['filename'] = parent.tableau.parametre['filename'] - self.parametres['pathout'] = ConstructPathOut(parent.tableau.parametre['filename'], 'proto') - self.parametres['type'] = 'proto' - dlg = progressbar(self.parent, 2) - self.colnames = self.tableau.get_colnames() - AnalyseMatrix.__init__(self, parent, parent.tableau, self.parametres, dlg = dlg) +# def __init__(self, parent, parametres): +# self.parent = parent +# self.tableau = self.parent.tableau +# self.parametres = parametres +# self.parametres['filename'] = parent.tableau.parametre['filename'] +# self.parametres['pathout'] = ConstructPathOut(parent.tableau.parametre['filename'], 'proto') +# self.parametres['type'] = 'proto' +# dlg = progressbar(self.parent, 2) +# self.colnames = self.tableau.get_colnames() +# AnalyseMatrix.__init__(self, parent, parent.tableau, self.parametres, dlg = dlg) def doanalyse(self) : res = self.check_val() return res def check_val(self) : - self.dial = ProtoDial(self.ira, self.colnames) + self.dial = ProtoDial(self.ira, self.tableau.colnames) self.dial.CenterOnParent() self.val = self.dial.ShowModal() @@ -56,11 +56,19 @@ class Prototypical(AnalyseMatrix) : else : self.parametres['limrang'] = self.dial.ranglim.GetValue() self.parametres['freqmin'] = int(self.dial.m_textCtrl4.GetValue()) + if self.dial.typegraph.GetSelection() == 0 : + self.parametres['typegraph'] = 'classical' + self.parametres['cloud'] = False + elif self.dial.typegraph.GetSelection() == 1 : + self.parametres['typegraph'] = 'classical' + self.parametres['cloud'] = True + else : + self.parametres['typegraph'] = 'plan' table_assoc, table_rank = self.dotable() self.makedatas(table_assoc, table_rank) self.DoR() else : - return 'stop' + return 'stop' def dotable(self) : table_assoc = self.tableau.select_col(self.ColSel1) @@ -71,20 +79,21 @@ class Prototypical(AnalyseMatrix) : words = {} for i in range(0, len(table_assoc)) : for j, word in enumerate(table_assoc[i]) : - if word in words : - words[word][0] += 1 - if table_rank[i][j] != '' : - words[word][1].append(int(table_rank[i][j])) - else : - if table_rank[i][j] != '' : - words[word] = [1, [int(table_rank[i][j])]] + if word.strip() != "" : + if word in words : + words[word][0] += 1 + if table_rank[i][j] != '' : + words[word][1].append(float(table_rank[i][j])) else : - words[word] = [1, []] + if table_rank[i][j] != '' : + words[word] = [1, [float(table_rank[i][j])]] + else : + words[word] = [1, []] res = [[word, words[word][0], float(sum(words[word][1])) / len(words[word][1])] for word in words if len(words[word][1]) != 0 and words[word][0] >= self.parametres['freqmin']] with open(self.pathout['table.csv'], 'w') as f : f.write('\n'.join(['\t'.join(['"' + val[0] +'"', `val[1]`, `val[2]`]) for val in res])) - self.parent.tableau.parametres = self.parent.tableau.parametre - self.parent.tableau.save_tableau(self.pathout['analyse.db']) + #self.parent.tableau.parametres = self.parent.tableau.parametre + #self.parent.tableau.save_tableau(self.pathout['analyse.db']) def DoR(self) : script = ProtoScript(self)