X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=tabverges.py;fp=tabverges.py;h=8ba6619c6c353af5f75ae92baf47091ab1e1778f;hp=12f4a61e187ab6a92d3b1080b9b081bcf2a217e4;hb=6919f2ef8d85c176c7be824b606c4b71142e10fd;hpb=54fef96ad151ba25920f3e589b39a83c3f62ae2c diff --git a/tabverges.py b/tabverges.py index 12f4a61..8ba6619 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 @@ -60,7 +60,7 @@ class Prototypical(AnalyseMatrix) : 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,15 +71,16 @@ 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]))