'EmptyText' : u"Texte vide (probablement un problème de formatage du corpus). Le problème est apparu à la ligne ",
'CorpusEncoding' : u"Problème d'encodage.",
'TextBeforeTextMark' : u"Problème de formatage : du texte avant le premier marqueur de texte (****). Le problème est survenu à la ligne ",
+ 'MissingAnalyse' : u'Aucun fichier à cet emplacement :\n',
}
def BugReport(parent, error = None):
from guifunct import *
from tableau import Tableau
from dialog import PrefDialog, CorpusPref
-from tabfrequence import Frequences
+from tabfrequence import Frequences, FreqMultiple
from tabchi2 import ChiSquare
#from tabstudent import MakeStudent
from tabchddist import ChdCluster
ID_SimiTxt = wx.NewId()
ID_proto = wx.NewId()
ID_ImportTXM = wx.NewId()
+ID_FreqMulti = wx.NewId()
##########################################################
#elements de configuration
##########################################################
#view_menu.AppendSeparator()
matrix_menu = wx.Menu()
matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
+ matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
#matrix_menu.Append(ID_Student, u"t de Student")
menu_classif = wx.Menu()
self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
+ self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
def OnFreq(self, event, matrix = None):
self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
+
+ def OnFreqMulti(self, event, matrix = None):
+ self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
def OnChi2(self, event, matrix = None):
self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
ProtoLayout(self.parent, corpus, self.conf)
elif self.conf['type'] == 'matrix' :
MatLayout(self.parent, corpus)
- elif self.conf['type'] == 'freq' :
+ elif self.conf['type'] == 'freq' or self.conf['type'] == 'freqmulti':
FreqLayout(self.parent, corpus, self.conf)
elif self.conf['type'] == 'chi2' :
Chi2Layout(self.parent, corpus, self.conf)
from analysematrix import AnalyseMatrix
from functions import exec_rcode, check_Rresult
from dialog import FreqDialog
-from PrintRScript import PrintRScript
+from PrintRScript import PrintRScript, FreqMultiScript
+from operator import itemgetter
class Frequences(AnalyseMatrix) :
def doparametres(self, dlg=None) :
with open(fileout, 'w') as f :
f.write(pretexte + texte)
#return fileout
+
+class FreqMultiple(Frequences):
+ def doanalyse(self):
+ select = self.parametres['colsel']
+ freq = self.tableau.countmultiple(select)
+ tot = sum([freq[forme][0] for forme in freq])
+ freq = [[forme, freq[forme][0], `round((float(freq[forme][0])/tot)*100, 2)`,`len(list(set(freq[forme][1])))`, `round((float(len(list(set(freq[forme][1]))))/self.tableau.rownb)*100,2)`] for forme in freq]
+ freq = sorted(freq, key=itemgetter(1), reverse=True)
+ freq = [[line[0], `line[1]`, line[2], line[3], line[4]] for line in freq]
+ freq.insert(0, [u'mod', 'freq', 'percent of total', 'row number', 'percent of rows'])
+ self.freq = freq
+ with open(self.pathout['frequences.csv'], 'w') as f :
+ f.write('\n'.join(['\t'.join(line) for line in freq]))
+ self.rscript = FreqMultiScript(self)
+ self.rscript.make_script()
+ self.doR(self.rscript.scriptout)
+ self.dolayout()
+
+ def dolayout(self):
+ pretexte = u'''<html>
+ <meta http-equiv="content-Type" content="text/html; charset=%s" />
+ <body>\n<h1>Fréquences</h1>
+ <a name="deb"></a><br>
+ ''' % self.parent.SysEncoding
+ txt = """
+ <table>\n<tr><td>\n
+ <table border=1><tr><td>
+ """
+ txt += '</td></tr><tr><td>'.join(['</td><td>'.join(line) for line in self.freq]) + '</td></tr></table></td></tr>'
+ txt += '<tr><td><img src="%s" alt="graph"/></td><td><img src="%s" alt="graph"/></td></tr></table>' % (os.path.basename(self.pathout['barplotfreq.png']), os.path.basename(self.pathout['barplotrow.png']))
+ txt += "</body>\n</html>"
+ with open(self.pathout['resultats.html'], 'w') as f :
+ f.write(pretexte + txt)
+
+
+
+
+
+
+
\ No newline at end of file
imgmatroot = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'matroot.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['matrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'matrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['freq'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'frequences.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
+ self.ild['freqmulti'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'frequences.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['chi2'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'chi2.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['reinertmatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'reinertmatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['simimatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simimatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())