DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout, wordgraph = word)
def on_graph(self, evt):
- dlg = progressbar(self, 2)
- corpus = self.Source.corpus
- uces = corpus.lc[self.cl-1]
- dlg.Update(1, u'Tableau...')
- #tab = corpus.make_table_with_classe(uces, self.la)
- pathout = ConstructPathOut(self.Source.pathout.dirout+'/', 'simi_classe_%i' %self.cl)
- self.filename = os.path.join(pathout,'mat01.csv')
- dlg.Update(2, u'Ecriture...')
- #corpus.write_tab(tab, self.filename)
- #del tab
- corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
- dlg.Destroy()
- paramsimi = {'coeff' : 0,
- 'layout' : 2,
- 'type' : 1,
- 'arbremax' : 1,
- 'coeff_tv' : 1,
- 'coeff_tv_nb' : 0,
- 'tvprop' : 0,
- 'tvmin' : 5,
- 'tvmax' : 30,
- 'coeff_te' : 1,
- 'coeff_temin' : 1,
- 'coeff_temax' : 10,
- 'label_v': 1,
- 'label_e': 0,
- 'vcex' : 0,
- 'vcexmin' : 10,
- 'vcexmax' : 25,
- 'cex' : 10,
- 'cexfromchi' : True,
- 'sfromchi': False,
- 'seuil_ok' : 0,
- 'seuil' : 1,
- 'cols' : (255,0,0),
- 'cola' : (200,200,200),
- 'width' : 1000,
- 'height' : 1000,
- 'first' : True,
- 'keep_coord' : True,
- 'alpha' : 20,
- 'film': False,
- }
- self.tableau = Tableau(self.parent, '')
- self.tableau.listactives = self.la
- self.tableau.actives = {}
- self.tableau.lchi = self.lchi
- self.tableau.chi = {}
- self.tableau.parametre['fromprof'] = True
- for i, val in enumerate(self.la) :
- self.tableau.actives[val] = [self.lfreq[i]]
- self.tableau.chi[val] = [self.lchi[i]]
- DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout)
+ self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = {'type' : 'clustersimitxt', 'pathout' : self.Source.parametres['pathout']}, dlg = progressbar(self, 4))
+ #dlg = progressbar(self, 2)
+ #corpus = self.Source.corpus
+ #uces = corpus.lc[self.cl-1]
+ #dlg.Update(1, u'Tableau...')
+ ##tab = corpus.make_table_with_classe(uces, self.la)
+ #pathout = ConstructPathOut(self.Source.pathout.dirout+'/', 'simi_classe_%i' %self.cl)
+ #self.filename = os.path.join(pathout,'mat01.csv')
+ #dlg.Update(2, u'Ecriture...')
+ ##corpus.write_tab(tab, self.filename)
+ ##del tab
+ #corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
+ #dlg.Destroy()
+ #paramsimi = {'coeff' : 0,
+ # 'layout' : 2,
+ # 'type' : 1,
+ # 'arbremax' : 1,
+ # 'coeff_tv' : 1,
+ # 'coeff_tv_nb' : 0,
+ # 'tvprop' : 0,
+ # 'tvmin' : 5,
+ # 'tvmax' : 30,
+ # 'coeff_te' : 1,
+ # 'coeff_temin' : 1,
+ # 'coeff_temax' : 10,
+ # 'label_v': 1,
+ # 'label_e': 0,
+ # 'vcex' : 0,
+ # 'vcexmin' : 10,
+ # 'vcexmax' : 25,
+ # 'cex' : 10,
+ # 'cexfromchi' : True,
+ # 'sfromchi': False,
+ # 'seuil_ok' : 0,
+ # 'seuil' : 1,
+ # 'cols' : (255,0,0),
+ # 'cola' : (200,200,200),
+ # 'width' : 1000,
+ # 'height' : 1000,
+ # 'first' : True,
+ # 'keep_coord' : True,
+ # 'alpha' : 20,
+ # 'film': False,
+ # }
+ #self.tableau = Tableau(self.parent, '')
+ #self.tableau.listactives = self.la
+ #self.tableau.actives = {}
+ #self.tableau.lchi = self.lchi
+ #self.tableau.chi = {}
+ #self.tableau.parametre['fromprof'] = True
+ #for i, val in enumerate(self.la) :
+ # self.tableau.actives[val] = [self.lfreq[i]]
+ # self.tableau.chi[val] = [self.lchi[i]]
+ #DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout)
def on_segments(self,evt) :
dlg = progressbar(self, 2)
#ALCESTE
from PrintRScript import RchdTxt, AlcesteTxtProf
from OptionAlceste import OptionAlc
-from layout import PrintRapport
+#from layout import PrintRapport
from openanalyse import OpenAnalyse
from time import time
######################################
self.dialok = True
self.parametres = parametres
self.val = False
- self.pathout = PathOut(corpus.parametres['originalpath'], analyse_type = parametres['type'], dirout = corpus.parametres['pathout'])
+ if not 'pathout' in self.parametres :
+ self.pathout = PathOut(corpus.parametres['originalpath'], analyse_type = parametres['type'], dirout = corpus.parametres['pathout'])
+ else :
+ self.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['name'])
self.parametres = self.make_config(parametres)
log.info(self.pathout.dirout)
if self.parametres is not None :
import os
import sys
import shutil
-from chemins import ConstructConfigPath
+from chemins import ConstructConfigPath, ConstructDicoPath
from functions import exec_rcode, exec_RCMD
import wx
import tempfile
def CreateIraDirectory(UserConfigPath,AppliPath):
if not os.path.exists(UserConfigPath):
os.mkdir(UserConfigPath)
+ if not os.path.exists(os.path.join(UserConfigPath, 'dictionnaires')) :
+ os.mkdir(os.path.join(UserConfigPath, 'dictionnaires'))
def CopyConf(self) :
DictUser = self.ConfigPath
if item == u'preferences' :
if not os.path.exists(filein) :
shutil.copyfile(DictAppli[item],filein)
+ dicoUser = self.DictPath
+ dicoAppli = ConstructDicoPath(self.AppliPath)
+ for fi in dicoUser :
+ if not os.path.exists(dicoUser[fi]) :
+ shutil.copyfile(dicoAppli[fi], dicoUser[fi])
def CheckRPath(PathPath):
if not os.path.exists(PathPath.get('PATHS','rpath')):
'path': os.path.join(ConfigPath, 'path.cfg'),
'preferences' : os.path.join(ConfigPath, 'iramuteq.cfg'),
'pam' : os.path.join(ConfigPath, 'pam.cfg'),
- 'history' : os.path.join(ConfigPath, 'history.db'),
'corpus' : os.path.join(ConfigPath, 'corpus.cfg'),
'stat' : os.path.join(ConfigPath, 'stat.cfg'),
'simitxt' : os.path.join(ConfigPath, 'simitxt.cfg'),
lemuceeff[uce] = lemuceeff.get(uce, 0) + eff[i]
return lemuceeff
+ def getlemclustereff(self, lem, cluster) :
+ return len(list(set(self.lc[cluster]).intersection(self.getlemuces(lem))))
+
def getlemeff(self, lem) :
return self.lems[lem].freq
ReadLexique(self.parent, lang = parametres['lang'])
self.parent.expressions = ReadDicoAsDico(self.parent.DictPath.get(parametres['lang']+'_exp', 'french_exp'))
self.parametres = parametres
+ else :
+ if self.dlg is not None :
+ self.dlg.Destroy()
dial.Destroy()
def doanalyse(self) :
fgSizer4.Add( self.check_charact, 0, wx.ALL, 5 )
self.txt_charact = wx.TextCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
- self.txt_charact.SetMinSize( wx.Size( 200,-1 ) )
+ self.txt_charact.SetMinSize( wx.Size( 400,-1 ) )
fgSizer4.Add( self.txt_charact, 0, wx.ALL|wx.EXPAND, 5 )
return False
#except :
# BugReport(parent)
+ else :
+ return None
else :
if pid != 0 :
#try :
return False
#except :
# BugReport(parent)
+ else :
+ return None
def print_liste(filename,liste):
with open(filename,'w') as f :
self.dial.CenterOnParent()
self.val = self.dial.ShowModal()
if self.val == wx.ID_OK :
- if self.dial.check_bystar.GetValue() :
- variables = treat_var_mod(self.parametres['stars'])
- vardial = dialog.OptLexi(parent)
- vardial.listet = self.parametres['stars']
- vardial.variables = [v for v in variables]
- for et in vardial.variables :
- vardial.list_box_1.Append(et)
- nval = vardial.ShowModal()
- if nval == wx.ID_OK :
- if vardial.choice.GetSelection() == 1 :
- listet = [vardial.listet[i] for i in vardial.list_box_1.GetSelections()]
- else :
- listet = variables[vardial.variables[vardial.list_box_1.GetSelections()[0]]]
- self.dial.Destroy()
- vardial.Destroy()
- self.etline = source.corpus.make_etline(listet)
- self.parametres['selectedstars'] = listet
- self.parametres['listet'] = self.etline
- else:
- vardial.Destroy()
+ if 'bystar' in self.parametres :
+ if self.dial.check_bystar.GetValue() :
+ variables = treat_var_mod(self.parametres['stars'])
+ vardial = dialog.OptLexi(parent)
+ vardial.listet = self.parametres['stars']
+ vardial.variables = [v for v in variables]
+ for et in vardial.variables :
+ vardial.list_box_1.Append(et)
+ nval = vardial.ShowModal()
+ if nval == wx.ID_OK :
+ if vardial.choice.GetSelection() == 1 :
+ listet = [vardial.listet[i] for i in vardial.list_box_1.GetSelections()]
+ else :
+ listet = variables[vardial.variables[vardial.list_box_1.GetSelections()[0]]]
+ self.dial.Destroy()
+ vardial.Destroy()
+ self.etline = source.corpus.make_etline(listet)
+ self.parametres['selectedstars'] = listet
+ self.parametres['listet'] = self.etline
+ else:
+ vardial.Destroy()
last = self.dial.listcol.GetFirstSelected()
lastl = [self.dial.listcol.GetFirstSelected()]
indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
from textdist import PamTxt
from textstat import Stat
from textaslexico import Lexico
-from textsimi import SimiTxt
+from textsimi import SimiTxt, SimiFromCluster
from textwordcloud import WordCloud
from profile_segment import ProfileSegment
from textcheckcorpus import checkcorpus
self.images_path = os.path.join(AppliPath,'images')
self.UserConfigPath = UserConfigPath
self.RscriptsPath = ConstructRscriptsPath(AppliPath)
- self.DictPath = ConstructDicoPath(AppliPath)
+ #self.DictPath = ConstructDicoPath(AppliPath)
+ self.DictPath = ConstructDicoPath(UserConfigPath)
self.ConfigGlob = ConfigGlob
self.ConfigPath = ConstructConfigPath(UserConfigPath)
self.pref = RawConfigParser()
+ #workaround for import problem
+ self.SimiFromCluster = SimiFromCluster
#langues
mylocale = wx.Locale(wx.LANGUAGE_FRENCH)
mylocale.AddCatalogLookupPathPrefix(os.path.join(AppliPath,'locale'))
import agw.aui as aui
from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
from ConfigParser import ConfigParser
-from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult
-from ProfList import *
+from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult, progressbar
+from ProfList import ProfListctrlPanel
from guiparam3d import param3d, simi3d
from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
from profile_segment import ProfileSegment
import os
import shelve
#from ConfigParser import *
-from tabsimi import DoSimi
+#from tabsimi import DoSimi
from functions import BugReport, DoConf
import logging
elif self.conf['type'] == 'alceste' :
self.parent.ShowMenu(_("Text analysis"))
OpenCHDS(self.parent, corpus, self.conf, Alceste = True)
- elif self.conf['type'] == 'simitxt' :
+ elif self.conf['type'] == 'simitxt' or self.conf['type'] == 'clustersimitxt' :
self.parent.ShowMenu(_("Text analysis"))
SimiLayout(self.parent, corpus, self.conf)
elif self.conf['type'] == 'wordcloud' :
# -*- coding: utf-8 -*-
#Author: Pierre Ratinaud
-#Copyright (c) 2008-2011 Pierre Ratinaud
+#Copyright (c) 2008-2013 Pierre Ratinaud
#Lisense: GNU/GPL
from chemins import ffr, simipath
#from corpus import Corpus
import os
from analysetxt import AnalyseText
-from ConfigParser import RawConfigParser
-from guifunct import getPage, getCorpus
+#from ConfigParser import RawConfigParser
+#from guifunct import getPage, getCorpus
from dialog import StatDialog
from guifunct import SelectColumn, PrepSimi
from functions import indices_simi, progressbar, treat_var_mod, read_list_file, print_liste
-from tableau import Tableau
-from tabsimi import DoSimi
+#from tableau import Tableau
+#from tabsimi import DoSimi
from PrintRScript import PrintSimiScript
import wx
from copy import copy
#self.actives, lim = self.corpus.make_actives_nb(self.parametres.get('max_actives',1500), 1)
self.parametres['eff_min_forme'] = lim
self.parametres['nbactives'] = len(self.actives)
- self.parametres['fromprof'] = True
+ self.parametres['fromprof'] = False
self.corpus.make_and_write_sparse_matrix_from_uces(self.actives, self.pathout['mat01.csv'], self.pathout['listeuce1.csv'])
with open(self.pathout['actives.csv'], 'w') as f :
f.write('\n'.join(self.actives).encode(self.ira.syscoding))
+class SimiFromCluster(SimiTxt) :
+ def __init__(self, ira, corpus, actives, numcluster, parametres = None, dlg = False) :
+ self.actives = actives
+ self.numcluster = numcluster
+ parametres['name'] = 'simi_classe_%i' % (numcluster + 1)
+ SimiTxt.__init__(self, ira, corpus, parametres, dlg)
+
+ def preferences(self) :
+ return self.parametres
+
+ def doanalyse(self) :
+ self.parametres['type'] = 'clustersimitxt'
+ self.pathout.basefiles(simipath)
+ self.indices = indices_simi
+ self.makesimiparam()
+ if 'bystar' in self.parametres :
+ del self.parametres['bystar']
+ dictcol = dict([[i, [act, self.corpus.getlemclustereff(act, self.numcluster)]] for i, act in enumerate(self.actives)])
+ continu = True
+ if self.dlg :
+ #self.listet = self.corpus.make_etoiles()
+ #self.listet.sort()
+ self.stars = []#copy(self.listet)
+ self.parametres['stars'] = False#copy(self.listet)
+ self.parametres['sfromchi'] = True
+ prep = PrepSimi(self.ira, self, self.parametres, self.pathout['selected.csv'], self.actives, indices_simi, wordlist=dictcol)
+ if prep.val == wx.ID_OK :
+ continu = True
+ self.parametres = prep.parametres
+ else :
+ continu = False
+ if continu :
+ self.makefiles()
+ script = PrintSimiScript(self)
+ script.make_script()
+ if self.doR(script.scriptout) :
+ return False
+ if self.parametres['type_graph'] == 1:
+ if os.path.exists(self.pathout['liste_graph']):
+ graph_simi = read_list_file(self.pathout['liste_graph'])
+ graph_simi.append([os.path.basename(script.filename), script.txtgraph])
+ else :
+ graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
+ print_liste(self.pathout['liste_graph'], graph_simi)
+ else :
+ return False
+ def makefiles(self) :
+ self.parametres['eff_min_forme'] = 3
+ self.parametres['nbactives'] = len(self.actives)
+ self.parametres['fromprof'] = True
+ self.corpus.make_and_write_sparse_matrix_from_classe(self.actives, self.corpus.lc[self.numcluster], self.pathout['mat01.csv'])
+ with open(self.pathout['actives.csv'], 'w') as f :
+ f.write('\n'.join(self.actives).encode(self.ira.syscoding))
# self.tableau = Tableau(self.parent, '')
# self.tableau.listactives = self.actives