fileout.write(txt)
fileout.close()
-def AlcesteTxtProf(DictChdTxtOut, RscriptsPath, clnb, taillecar):
+def ReinertTxtProf(DictChdTxtOut, RscriptsPath, clnb, taillecar):
txt = "clnb<-%i\n" % clnb
txt += """
source("%s")
self.packages(['igraph', 'proxy', 'Matrix'])
self.sources([self.analyse.parent.RscriptsPath['simi'], self.analyse.parent.RscriptsPath['Rgraph']])
txt = ''
- if not self.parametres['keep_coord'] and not self.parametres['type'] == 'simimatrix':
+ if not self.parametres['keep_coord'] and not (self.parametres['type'] == 'simimatrix' or self.parametres['type'] == 'simiclustermatrix') :
txt += """
dm.path <- "%s"
cn.path <- "%s"
index <- which(colnames(dm) == forme)
}
"""
- elif not self.parametres['keep_coord'] and self.parametres['type'] == 'simimatrix' :
+ elif not self.parametres['keep_coord'] and (self.parametres['type'] == 'simimatrix' or self.parametres['type'] == 'simiclustermatrix'):
txt += """
dm.path <- "%s"
selected.col <- "%s"
if self.parametres['seuil_ok'] : seuil = str(self.parametres['seuil'])
else : seuil = 'NULL'
-
+
+ if not self.parametres.get('edgecurved', False) :
+ ec = 'FALSE'
+ else :
+ ec = 'TRUE'
+
+ txt += """
+ edge.curved <- %s
+ """ % ec
+
cols = str(self.parametres['cols']).replace(')',', max=255)')
cola = str(self.parametres['cola']).replace(')',',max=255)')
"""
else :
#print self.parametres
- if (self.parametres['type'] == 'clustersimitxt' and self.parametres.get('tmpchi', False)) or (self.parametres['type'] == 'simimatrix' and 'tmpchi' in self.parametres):
+ if (self.parametres['type'] == 'clustersimitxt' and self.parametres.get('tmpchi', False)) or (self.parametres['type'] in ['simimatrix','simiclustermatrix'] and 'tmpchi' in self.parametres):
txt += """
lchi <- read.table("%s")
lchi <- lchi[,1]
txt += """
lchi <- lchi[sel.col]
"""
- if self.parametres['type'] == 'clustersimitxt' and self.parametres.get('cexfromchi', False) :
+ if self.parametres['type'] in ['clustersimitxt', 'simimatrix', 'simiclustermatrix'] and self.parametres.get('cexfromchi', False) :
txt += """
label.cex <- norm.vec(lchi, vcexminmax[1], vcexminmax[2])
"""
label.cex <- graph.simi$label.cex
}
"""
- if (self.parametres['type'] == 'clustersimitxt' or self.parametres['type'] == 'simimatrix') and self.parametres.get('sfromchi', False):
+ if (self.parametres['type'] in ['clustersimitxt', 'simimatrix', 'simiclustermatrix']) and self.parametres.get('sfromchi', False):
txt += """
vertex.size <- norm.vec(lchi, minmaxeff[1], minmaxeff[2])
if (!length(vertex.size)) vertex.size <- 0
vertex.label.color <- colm[membership(com)]
}
}
- coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, svg = svg)
+ coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, edge.curved = edge.curved, svg = svg)
save.image(file="%s")
""" % (type, self.filename, ffr(self.pathout['RData']))
""" % ffr(self.pathout['tgenspec.csv'])
self.add(txt)
+class TgenProfScript(PrintRScript):
+ def make_script(self):
+ self.sources([self.analyse.ira.RscriptsPath['chdfunct']])
+ txt = """
+ tgen <- read.csv2("%s", row.names = 1, sep = '\\t')
+ """ % ffr(self.parametres['tgeneff'])
+ txt += """
+ res <- build.prof.tgen(tgen)
+ write.table(res$chi2, file = "%s", sep='\\t', col.names = NA)
+ write.table(res$pchi2, file = "%s", sep='\\t', col.names = NA)
+ """ % (ffr(self.pathout['tgenchi2.csv']), ffr(self.pathout['tgenpchi2.csv']))
+ self.add(txt)
+
class FreqMultiScript(PrintRScript):
def make_script(self):
self.sources([self.analyse.parent.RscriptsPath['Rgraph']])
from listlex import ListForSpec
from chemins import ConstructPathOut, ffr
from dialog import PrefExport, PrefUCECarac, SearchDial, message, MessageImage, BarFrame
-from tableau import Tableau
+from tableau import Tableau, copymatrix
from search_tools import SearchFrame
import webbrowser
#import cStringIO
from textclassechd import ClasseCHD
from shutil import copyfile
from operator import itemgetter
+from copy import copy
#---------------------------------------------------------------------------
class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
self.Source = gparent
self.cl = cl
self.var_mod = {}
+ self.them_mod = {}
line1 = profclasse.pop(0)
classen = [line for line in profclasse if line[0] != '*' and line[0] != '*****']
self.idexport = wx.NewId()
self.idexporttropes = wx.NewId()
self.idexportowledge = wx.NewId()
+ self.onmaketgen = wx.NewId()
# self.export_classes = wx.NewId()
self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.onexport, id = self.idexport)
self.Bind(wx.EVT_MENU, self.onexporttropes, id = self.idexporttropes)
self.Bind(wx.EVT_MENU, self.onexportowledge, id = self.idexportowledge)
+ self.Bind(wx.EVT_MENU, self.OnMakeTgen, id=self.onmaketgen)
# self.Bind(wx.EVT_MENU, self.on_export_classes, id = self.export_classes)
# self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
menu_conc.Append(self.popupID2, u"dans les segments de texte de la classe")
menu_conc.Append(self.popupID3, u"dans les segments de texte classés")
menu_conc.Append(self.popupID4, u"dans tous les segments de texte")
- menu.AppendMenu(-1, u"Concordancier", menu_conc)
+ menu.AppendMenu(-1, u"Concordancier", menu_conc)
+ menu.Append(self.onmaketgen, _(u"Make Tgen").decode('utf8'))
menu_cnrtl = wx.Menu()
menu_cnrtl.Append(self.popupID5, u"Définition")
menu_cnrtl.Append(self.popupID6, u"Etymologie")
menu.Append(self.pop2, u"Chi2 par classe")
menu.Append(self.pop3, u"Chi2 modalités de la variable")
menu.AppendSeparator()
- menu.Append(self.pop1, u"Graph de la classe")
+ menu.Append(self.pop1, u"Graphe de la classe")
self.PopupMenu(menu)
menu.Destroy()
if 'corpus' in dir(self.Source):
corpus = self.Source.corpus
prof = [[self.la[i], self.lchi[i], self.lfreq[i]] for i, val in enumerate(self.la)]
- parametres = self.Source.parametres
+ parametres = copy(self.Source.parametres)
parametres['clusterprof'] = prof
parametres['type'] = 'clustercloud'
parametres['prof'] = self.Source.pathout['actprof_classe_%i.csv' % self.cl]
words.append(self.getColumnText(last, 6))
return words
- def quest_var_mod(self, evt) :
+ def quest_var_mod(self, evt) :
+ word = self.getselectedwords()[0]
+ if len(word.split('_')) <= 1 :
+ dial = wx.MessageDialog(self, u"Ce n'est pas une forme du type variable_modalité", u"Problème", wx.OK | wx.ICON_WARNING)
+ dial.CenterOnParent()
+ dial.ShowModal()
+ dial.Destroy()
+ return
+
if 'corpus' in dir(self.Source):
corpus = self.Source.corpus
- if self.var_mod == {} :
- self.var_mod = self.Source.corpus.make_etoiles_dict()
+ if word.startswith(u'-*') :
+ if self.them_mod == {} :
+ self.them_mod = self.Source.corpus.make_theme_dict()
+ var_mod = self.them_mod
+ else :
+ if self.var_mod == {} :
+ self.var_mod = self.Source.corpus.make_etoiles_dict()
+ var_mod = self.var_mod
else :
corpus = self.Source.tableau
if self.var_mod == {} :
self.var_mod = treat_var_mod([val for val in corpus.actives] + [val for val in corpus.sups])
+ var_mod = self.var_mod
with codecs.open(self.Source.pathout['chisqtable'], 'r', corpus.parametres['syscoding']) as f :
chistable = [line.replace('\n','').replace('\r','').replace('"','').replace(',','.').split(';') for line in f]
title = chistable[0]
chistable.pop(0)
vchistable = [line[1:] for line in chistable]
fchistable = [line[0] for line in chistable]
- word = self.getselectedwords()[0]
- if len(word.split('_')) > 1 :
- var = word.split('_')
- #words = ['_'.join([var[0],word]) for word in self.var_mod[var[0]]]
- words = [word for word in self.var_mod[var[0]]]
- words.sort()
- tableout = []
- kwords = []
- for word in words :
- if word in fchistable :
- tableout.append(vchistable[fchistable.index(word)])
- kwords.append(word)
- BarFrame(self.Source.parent, tableout, title, kwords)
-# tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
-# txt = barplot(tableout, kwords, title, self.Source.parent.RscriptsPath['Rgraph'], tmpgraph)
-# tmpscript = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
-# file = open(tmpscript,'w')
-# file.write(txt)
-# file.close()
-# exec_rcode(self.Source.parent.RPath, tmpscript, wait = True)
-# win = MessageImage(self,u"Graphique", size=(700, 500))
-# win.addsaveimage(tmpgraph)
-# txt = "<img src='%s'>" % tmpgraph
-# win.HtmlPage.SetPage(txt)
-# win.Show(True)
- else :
- dial = wx.MessageDialog(self, u"Ce n'est pas une forme du type variable_modalité", u"Problème", wx.OK | wx.ICON_WARNING)
+
+ var = word.split('_')
+ #words = ['_'.join([var[0],word]) for word in self.var_mod[var[0]]]
+ try :
+ words = [word for word in var_mod[var[0]]]
+ except KeyError:
+ dial = wx.MessageDialog(self, _(u"This is not a meta-data"), u"Problème", wx.OK | wx.ICON_WARNING)
dial.CenterOnParent()
dial.ShowModal()
dial.Destroy()
+ return
+ words.sort()
+ tableout = []
+ kwords = []
+ for word in words :
+ if word in fchistable :
+ tableout.append(vchistable[fchistable.index(word)])
+ kwords.append(word)
+ BarFrame(self.Source.parent, tableout, title, kwords)
def quest_simi(self, evt) :
tableau = self.Source.tableau
'com' : 0,
'communities' : 0,
'halo' : 0,
- 'tmpchi': self.tmpchi
+ 'tmpchi': self.tmpchi,
+ 'fromprof' : True,
+ 'edgecurved' : True,
}
act = {}
+ tableau = copymatrix(tableau)
tableau.chi = {}
tableau.lchi = self.lchi
- tableau.parametres['fromprof'] = True
+ #tableau.parametres['fromprof'] = True
for i, val in enumerate(self.la) :
act[val] = [self.lfreq[i]]
tableau.chi[val] = [self.lchi[i]]
- self.parent.SimiCluster(parametres = paramsimi, fromprof = ffr(self.filename), pathout = pathout, listactives = self.la, actives = act, tableau = tableau)
+ paramsimi['listactives'] = copy(self.la)
+ paramsimi['actives'] = copy(act)
+ paramsimi['pathout'] = pathout
+ self.parent.SimiCluster(parametres = paramsimi, fromprof = ffr(self.filename), tableau = tableau)
def onwordgraph(self, evt):
word = self.getColumnText(self.GetFirstSelected(), 6)
ucis_txt, ucestxt = doconcorde(corpus, nuces, self.la, uci = uci)
items = dict([[i, '<br>'.join([ucis_txt[i], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table><br>' % ntab2[i][0], ucestxt[i]])] for i, uce in enumerate(nuces)])
dlg.Update(4, u'texte...')
- win = message(self, items, u"Segments de texte caractéristiques - Classe %i" % self.cl, (750, 600))
+ win = message(self, items, u"Segments de texte caractéristiques - Classe %i" % self.cl, (750, 600), uceids = nuces)
#win.html = '<html>\n' + '<br>'.join(['<br>'.join([ucis_txt[i], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table>' % ntab2[i][0], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n</html>'
#win.HtmlPage.SetPage(win.html)
dlg.Destroy()
nbcl = len(title)
nbwords = len(words)
BarFrame(self.Source.parent, tableout, title, words)
-# txt = barplot(tableout, words, title, self.Source.parent.RscriptsPath['Rgraph'], tmpgraph)
-# #print 'ATTENTION TEST R'
-# #txt = """
-# #sink('/Users/pierre/Desktop/qdfqsdfqsdfqsdf.txt')
-# #Sys.getlocale()
-# #sink()
-# #"""
-# tmpscript = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
-# file = open(tmpscript,'w')
-# file.write(txt)
-# file.close()
-# exec_rcode(self.Source.parent.RPath, tmpscript, wait = True)
-# w = 100 + (20 * nbwords) + (100 * nbcl)
-# h = 100 + (nbwords * 15)
-# if w > 1100 : w = 1100
-# if h > 800 : h = 800
-# if h < 450 : h = 450
-# win = MessageImage(self, u"Graphique", size=(w, h))
-# win.addsaveimage(tmpgraph)
-# txt = "<img src='%s'>" % tmpgraph
-# win.HtmlPage.SetPage(txt)
-# win.Show(True)
def onlexdendro(self, evt):
if 'corpus' in dir(self.Source):
uci = True
ucis_txt, ucestxt = doconcorde(corpus, ucef, ListWord, uci = uci)
items = dict([[i, '<br><br>'.join([ucis_txt[i], ucestxt[i]])] for i in range(0,len(ucestxt))])
- win = message(self, items, title, (800, 500))
- #win = message(self, title, size=(750, 600))
- #win.html = ('<html>\n<h1>%s</h1>' % ' '.join(ListWord)) + '<br>'.join(['<br>'.join([ucis_txt[i], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n</html>'
- #win.HtmlPage.SetPage(win.html)
+ win = message(self, items, title, (800, 500), uceids = ucef)
return win
def OnPopupTwo(self, event):
def OnPopupThree(self, event):
corpus = self.Source.corpus
uces = [classe[i] for classe in corpus.lc for i in range(0,len(classe))]
- win = self.make_concord(uces, "Concordancier - UCE classées")
+ win = self.make_concord(uces, "Concordancier - Segments de texte classés")
win.Show(True)
def OnPopupFour(self, event):
corpus = self.Source.corpus
uces = [classe[i] for classe in corpus.lc for i in range(0,len(classe))] + corpus.lc0
- win = self.make_concord(uces, "Concordancier - Toutes les UCE")
+ win = self.make_concord(uces, "Concordancier - Tous les segments de texte")
win.Show(True)
def OnPopupFive(self, event):
#win.html = '<html>\n' + '<br>'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n</html>'
#win.HtmlPage.SetPage(win.html)
win.Show(True)
+
+ def OnMakeTgen(self, evt):
+ self.parent.tree.OnTgenEditor(self.getselectedwords())
class wliste(wx.Frame):
names(ntoplot) <- rownames(toplot)
ntoplot <- ntoplot[order(ntoplot, decreasing = TRUE)]
ntoplot <- round(ntoplot, 0)
- ntoplot <- ntoplot[1:nbbycl]
+ if (length(toplot) > nbbycl) {
+ ntoplot <- ntoplot[1:nbbycl]
+ }
+ ntoplot <- ntoplot[which(ntoplot > 0)]
#ntoplot <- ntoplot[order(ntoplot)]
#ntoplot <- ifelse(length(ntoplot) > nbbycl, ntoplot[1:nbbycl], ntoplot)
lclasses[[classe]] <- ntoplot
#wordcloud(names(lclasses[[i]]), lclasses[[i]], scale = c(1.5, 0.2), random.order=FALSE, colors = colcloud[i])
yval <- 1.1
plot(0,0,pch='', axes = FALSE)
- vcex <- norm.vec(lclasses[[i]], 1.5, 1.5)
+ vcex <- norm.vec(lclasses[[i]], 1, 2)
for (j in 1:length(lclasses[[i]])) {
yval <- yval-(strheight( names(lclasses[[i]])[j],cex=vcex[j])+0.02)
text(-0.9, yval, names(lclasses[[i]])[j], cex = vcex[j], col = colcloud[i], adj=0)
}
}
+ if (!from.cmd) {
+ dev.off()
+ }
}
lclasses <- list()
for (classe in 1:length(sum.cl)) {
ntoplot <- toplot[,classe]
+ names(ntoplot) <- rownames(toplot)
ntoplot <- ntoplot[order(ntoplot, decreasing = TRUE)]
ntoplot <- round(ntoplot, 0)
- ntoplot <- ntoplot[1:nbbycl]
+ if (length(toplot) > nbbycl) {
+ ntoplot <- ntoplot[1:nbbycl]
+ }
ntoplot <- ntoplot[order(ntoplot)]
+ ntoplot <- ntoplot[which(ntoplot > 0)]
#ntoplot <- ifelse(length(ntoplot) > nbbycl, ntoplot[1:nbbycl], ntoplot)
lclasses[[classe]] <- ntoplot
}
plot.phylo(tree,label.offset=0.1,tip.col=col, type=type.dendro)
for (i in rev(tree.order)) {
par(mar=c(0,0,1,0),cex=0.9)
- wordcloud(names(lclasses[[i]]), lclasses[[i]], scale = c(4, 0.8), random.order=FALSE, colors = colcloud[i])
+ wordcloud(names(lclasses[[i]]), lclasses[[i]], scale = c(2.5, 0.5), random.order=FALSE, colors = colcloud[i])
}
}
mat
}
+build.prof.tgen <- function(x) {
+ nbst <- sum(x[nrow(x),])
+ totcl <- x[nrow(x),]
+ tottgen <- rowSums(x)
+ nbtgen <- nrow(x) - 1
+ chi2 <- x[1:(nrow(x)-1),]
+ pchi2 <- chi2
+ for (classe in 1:ncol(x)) {
+ for (tg in 1:nbtgen) {
+ cont <- c(x[tg, classe], tottgen[tg] - x[tg, classe], totcl[classe] - x[tg, classe], (nbst - totcl[classe]) - (tottgen[tg] - x[tg, classe]))
+ cont <- matrix(unlist(cont), nrow=2)
+ chiresult<-chisq.test(cont,correct=FALSE)
+ if (is.na(chiresult$p.value)) {
+ chiresult$p.value<-1
+ chiresult$statistic<-0
+ }
+ if (chiresult$expected[1,1] > cont[1,1]) {
+ chiresult$statistic <- chiresult$statistic * -1
+ }
+ chi2[tg,classe] <- chiresult$statistic
+ pchi2[tg,classe] <- chiresult$p.value
+ }
+ }
+ res <- list(chi2 = chi2, pchi2 = pchi2)
+}
+
BuildProf<- function(x,dataclasse,clusternb,lim=2) {
####
#r.names<-rownames(x)
out <- list(graph = g.toplot, mat.eff = mat.eff, eff = eff, mat = mat.simi, v.label = v.label, we.width = we.width, we.label=we.label, label.cex = label.cex, layout = lo, communities = com, halo = halo, elim=vec)
}
-plot.simi <- function(graph.simi, p.type = 'tkplot',filename=NULL, communities = NULL, vertex.col = 'red', edge.col = 'black', edge.label = TRUE, vertex.label=TRUE, vertex.label.color = 'black', vertex.label.cex= NULL, vertex.size=NULL, leg=NULL, width = 800, height = 800, alpha = 0.1, cexalpha = FALSE, movie = NULL, svg = FALSE) {
+plot.simi <- function(graph.simi, p.type = 'tkplot',filename=NULL, communities = NULL, vertex.col = 'red', edge.col = 'black', edge.label = TRUE, vertex.label=TRUE, vertex.label.color = 'black', vertex.label.cex= NULL, vertex.size=NULL, leg=NULL, width = 800, height = 800, alpha = 0.1, cexalpha = FALSE, movie = NULL, edge.curved = TRUE, svg = FALSE) {
mat.simi <- graph.simi$mat
g.toplot <- graph.simi$graph
if (is.null(vertex.size)) {
}
par(pch=' ')
if (is.null(graph.simi$com)) {
- plot(g.toplot,vertex.label='', edge.width=we.width, vertex.size=vertex.size, vertex.color=vertex.col, vertex.label.color='white', edge.label=we.label, edge.label.cex=cex, edge.color=edge.col, vertex.label.cex = 0, layout=lo, edge.curved=FALSE)#, rescale = FALSE)
+ plot(g.toplot,vertex.label='', edge.width=we.width, vertex.size=vertex.size, vertex.color=vertex.col, vertex.label.color='white', edge.label=we.label, edge.label.cex=cex, edge.color=edge.col, vertex.label.cex = 0, layout=lo, edge.curved=edge.curved)#, rescale = FALSE)
} else {
if (graph.simi$halo) {
mark.groups <- communities(graph.simi$com)
} else {
mark.groups <- NULL
}
- plot(com, g.toplot,vertex.label='', edge.width=we.width, vertex.size=vertex.size, vertex.color=vertex.col, vertex.label.color='white', edge.label=we.label, edge.label.cex=cex, edge.color=edge.col, vertex.label.cex = 0, layout=lo, mark.groups = mark.groups, edge.curved=FALSE)
+ plot(com, g.toplot,vertex.label='', edge.width=we.width, vertex.size=vertex.size, vertex.color=vertex.col, vertex.label.color='white', edge.label=we.label, edge.label.cex=cex, edge.color=edge.col, vertex.label.cex = 0, layout=lo, mark.groups = mark.groups, edge.curved=edge.curved)
}
#txt.layout <- lo
txt.layout <- layout.norm(lo, -1, 1, -1, 1, -1, 1)
self.dlg = dlg
self.parametres = parametres
self.val = False
- print self.parametres
if not 'pathout' in self.parametres :
self.parametres['pathout'] = PathOut(tableau.parametres['originalpath'], analyse_type = self.parametres['type'], dirout = tableau.parametres['pathout']).mkdirout()
- print self.parametres
self.pathout = PathOut(analyse_type = self.parametres['type'], dirout = self.parametres['pathout'])
- print self.pathout.dirout
else :
self.pathout = PathOut(filename = tableau.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['type'])
else :
self.val = False
if dlg :
- self.dlg.Destroy()
+ try :
+ self.dlg.Destroy()
+ except :
+ pass
else :
#if isinstance(dlg, wx.ProgressDialog) :
# self.dlg.Destroy()
author = Pierre Ratinaud
gpl-fr = gpl-2.0-fr.txt
dev = Pierre Ratinaud (Université de Toulouse - Laboratoire LERASS - ratinaud@univ-tlse2.fr);Sébastien Déjean (Université de Toulouse);David Skalinder (Mash Strategy - davids@mash.uk.com);
-version = 0.6 alpha 10
+version = 0.6 alpha 11
licence = GNU GPL (v2)
-version_nb = 0.6.a10
\ No newline at end of file
+version_nb = 0.6.a11
\ No newline at end of file
guilanguage=french
R_mem = false
R_max_mem = 1535
-version_nb = 0.6.a10
+version_nb = 0.6.a11
rlibs = false
libsvdc = false
libsvdc_path = /usr/bin/svd
-rmirror = http://cran.rstudio.com/
+rmirror = http://cran.rstudio.com/
\ No newline at end of file
type_graph = 1
coeff_tv = True
first = False
+edgecurved = True
res = self.cformes.execute(query)
return list(set(list(itertools.chain(*[[int(val) for val in row[0].split()] if not isinstance(row[0], int) else [row[0]] for row in res]))))
+ def gettgenst(self, tgen):
+ formesid = ', '.join([`val` for lem in tgen for val in self.lems[lem].formes if lem in self.lems])
+ query = 'SELECT uces FROM uces where id IN (%s) ORDER BY id' % formesid
+ res = self.cformes.execute(query)
+ return list(set(list(itertools.chain(*[[int(val) for val in row[0].split()] if not isinstance(row[0], int) else [row[0]] for row in res]))))
+
+ def gettgentxt(self, tgen):
+ sts = self.gettgenst(tgen)
+ return list(set([self.getucefromid(val).uci for val in sts]))
+
def getlemucis(self, lem) :
uces = self.getlemuces(lem)
return list(set([self.getucefromid(val).uci for val in uces]))
tgenoccurrences[t][etoiles[i]] += sum([lemuceeff[uce] for uce in concern])
return tgenoccurrences, totoccurrences
+ def make_tgen_profile(self, tgen, ucecl, uci = False) :
+ log.info('tgen/classes')
+ if uci :
+ tab = [[lem] + [len(set(self.gettgentxt(tgen[lem])).intersection(classe)) for classe in ucecl] for lem in tgen]
+ else :
+ tab = [[lem] + [len(set(self.gettgenst(tgen[lem])).intersection(classe)) for classe in ucecl] for lem in tgen]
+ tab = [[line[0]] + [val for val in line[1:]] for line in tab if sum(line[1:]) >= 3]
+ return tab
+ #i = 0
+ #nam = 'total'
+ #while nam + `i` in tgen :
+ # i += 1
+ #nam = nam + `i`
+ #last = [nam] + [`len(classe)` for classe in ucecl]
+ #tab += [last]
+ #line0 = ['tgen'] + ['_'.join(['cluster', `i+1`]) for i in range(len(ucecl))]
+ #tab = [line0] + tab
+ #with open(fileout, 'w') as f :
+ # f.write('\n'.join(['\t'.join(line) for line in tab]).encode(self.parametres['syscoding']))
+
def make_efftype_from_etoiles(self, etoiles) :
dtype = {}
etuces = [[] for et in etoiles]
except IndexError :
det[et[0]] = 1
return det
+
+ def make_theme_dict(self):
+ themes = [val for uci in self.ucis for val in uci.paras]
+ det = {}
+ for theme in themes :
+ th = theme.split('_')
+ if th[0] in det :
+ try :
+ endth = '_'.join(th[1:])
+ if theme in det[th[0]] :
+ det[th[0]][theme] += 1
+ else :
+ det[th[0]][theme] = 1
+ except IndexError :
+ det[th[0]] += 1
+ else :
+ try :
+ endth = '_'.join(th[1:])
+ det[th[0]] = {theme:1}
+ except IndexError :
+ det[th[0]] = 1
+ return det
def make_etline(self, listet) :
etuces = [[] for et in listet]
class SearchDial ( wx.Frame ):
def __init__( self, parent, listctrl, col, shown):
- wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE )
+ wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP )
self.parent = parent
self.listctrl = listctrl
self.col = col
willowy willowy adj
willpower willpower nom
willpowers willpower nom
-wills will nom
+wills wills nom
wilt wilt nom
wilted wilt ver
wilting wilt ver
yours yours sw
yourself yourself sw
yourselves yourselves sw
-yous you nom
+yous yous nom
youth youth nom
youthfulness youthfulness nom
youthfulnesses youthfulness nom
return path
while '\\\\' in path :
path = path.replace('\\\\', '\\')
- if sys.platform == 'win32' and path.startswith('\\') and not path.startswith('\\\\') :
+ if path.startswith('\\') and not path.startswith('\\\\') :
path = '\\' + path
return path
def __getitem__(self, key):
return self.tgen[key]
- def read(self, path):
+ def read(self, path = None):
+ if path is None :
+ path = self.path
with codecs.open(path, 'r', self.encoding) as f :
tgen = f.read()
tgen = [line.split('\t') for line in tgen.splitlines()]
return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]]
def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()):
- #print 'lecture des profils : ReadProfileAsDico'
- #if Alceste :
- # print 'lecture du dictionnaire de type'
- # dictlem = {}
- # for line in parent.corpus.lem_type_list :
- # dictlem[line[0]] = line[1]
dictlem = {}
print 'lecture des profiles'
- #encoding = sys.getdefaultencoding()
FileReader = codecs.open(File, 'r', encoding)
Filecontent = FileReader.readlines()
FileReader.close()
return '\n\n'.join(proflist)
def formatExceptionInfo(maxTBlevel=5):
- cla, exc, trbk = sys.exc_info()
- try :
- excName = cla.__name__
- except :
- excName = 'None'
- try:
- excArgs = exc.args[0]
- except :
- excArgs = "<no args>"
- excTb = traceback.format_tb(trbk, maxTBlevel)
- return (excName, excArgs, excTb)
+ cla, exc, trbk = sys.exc_info()
+ try :
+ excName = cla.__name__
+ except :
+ excName = 'None'
+ try:
+ excArgs = exc.args[0]
+ except :
+ excArgs = "<no args>"
+ excTb = traceback.format_tb(trbk, maxTBlevel)
+ return (excName, excArgs, excTb)
#fonction des etudiants de l'iut
else :
parent = self
try :
- print '###horrible hack progressbar'
maxi = int(maxi)
except :
maxi = 1
if self.tableau.parametres['colsep'] == 'tabulation' :
self.tableau.parametres['colsep'] = '\t'
self.tableau.parametres['filetype'] = 'csv'
+ self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()]
elif getfileextension(filename) == '.xls' :
dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE)
self.check_elab = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
fgSizer3.Add( self.check_elab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
+ self.m_staticline39 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+ fgSizer3.Add( self.m_staticline39, 0, wx.EXPAND |wx.ALL, 5 )
+
+ self.m_staticline40 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+ fgSizer3.Add( self.m_staticline40, 0, wx.EXPAND |wx.ALL, 5 )
+
+ self.m_staticText321 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edge curved"), wx.DefaultPosition, wx.DefaultSize, 0 )
+ self.m_staticText321.Wrap( -1 )
+ fgSizer3.Add( self.m_staticText321, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+
+ self.check_curved = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
+ fgSizer3.Add( self.check_curved, 0, wx.ALL, 5 )
+
self.m_staticline2914 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
fgSizer3.Add( self.m_staticline2914, 0, wx.EXPAND, 5 )
self.comcheck.SetValue(self.paramsimi['com'])
self.choix_com.SetSelection(self.paramsimi['communities'])
self.halo.SetValue(self.paramsimi['halo'])
+ self.check_curved.SetValue(self.paramsimi.get('edgecurved', True))
def ChangeCount(self, evt) :
self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount())
'com' :self.dial.comcheck.GetValue(),
'communities' : self.dial.choix_com.GetSelection(),
'halo' : self.dial.halo.GetValue(),
+ 'edgecurved' : self.dial.check_curved.GetValue(),
}
if 'cexfromchi' in self.parametres :
param['cexfromchi'] = self.dial.checkit.GetValue()
if 'sfromchi' in self.parametres :
param['sfromchi'] = self.dial.checki.GetValue()
- print param
if 'vlabcolor' in self.parametres :
param['vlabcolor'] = self.parametres['vlabcolor']
if 'check_bystar' in dir(self.dial) :
#License: GNU GPL
from optparse import OptionParser
+from wx import BusyCursor
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="open FILE", metavar="FILE", default=False)
(options, args) = parser.parse_args()
-#print args
-#print options
import sys
reload(sys)
import locale
import tempfile
import codecs
import os
-import shutil
from random import randint
-from ConfigParser import *
+from ConfigParser import ConfigParser, RawConfigParser
import webbrowser
import gettext
import logging
#------------------------------------
import wx
-#import wx.aui
import wx.lib.agw.aui as aui
import wx.html
import wx.grid
import wx.lib.hyperlink as hl
#------------------------------------
-from functions import BugReport, PlaySound, ReadLexique, History, DoConf, ReadDicoAsDico, progressbar
+from functions import BugReport, PlaySound, History
from checkversion import NewVersion
from guifunct import *
from tableau import Tableau
-from dialog import PrefDialog, CorpusPref
+from dialog import PrefDialog
from tabfrequence import Frequences, FreqMultiple
from tabchi2 import ChiSquare
#from tabstudent import MakeStudent
from tabrsimple import InputText
from tabverges import Prototypical
from tabsplitvar import SplitMatrixFromVar
-#from textafcuci import AfcUci
-from textdist import AnalysePam
+#from textdist import AnalysePam
from textstat import Stat
from textaslexico import Lexico
from textsimi import SimiTxt, SimiFromCluster
from textwordcloud import WordCloud, ClusterCloud
from textreinert import Reinert
-#from profile_segment import ProfileSegment
#from textcheckcorpus import checkcorpus
from openanalyse import OpenAnalyse
from corpus import Builder, SubBuilder
-#from sheet import MySheet
from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
from parse_factiva_xml import ImportFactiva
ConfigPath = ConstructConfigPath(UserConfigPath)
langues = {'french' : wx.LANGUAGE_FRENCH,
- 'english' : wx.LANGUAGE_ENGLISH,
- 'portuguese' : wx.LANGUAGE_PORTUGUESE,
- 'italian' : wx.LANGUAGE_ITALIAN,
- 'spanish' : wx.LANGUAGE_SPANISH}
+ 'english' : wx.LANGUAGE_ENGLISH,
+ 'portuguese' : wx.LANGUAGE_PORTUGUESE,
+ 'italian' : wx.LANGUAGE_ITALIAN,
+ 'spanish' : wx.LANGUAGE_SPANISH
+ }
code_langues = {'french' : 'fr_FR',
- 'english' : 'en',
- 'portuguese' : 'pt_PT',
- 'italian' : 'it_IT',
- 'spanish' : 'es_ES'
- }
+ 'english' : 'en',
+ 'portuguese' : 'pt_PT',
+ 'italian' : 'it_IT',
+ 'spanish' : 'es_ES'
+ }
#####################################################################
class IraFrame(wx.Frame):
#--------------------------------------------------------------------
self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
self.statusbar.SetStatusWidths([-2, -3])
- self.statusbar.SetStatusText(u"Prêt", 0)
- self.statusbar.SetStatusText(u"Bienvenue", 1)
+ self.statusbar.SetStatusText(_(u"Ready"), 0)
+ self.statusbar.SetStatusText(_(u"Welcome"), 1)
# min size for the frame itself isn't completely done.
# see the end up FrameManager::Update() for the test
# f.write('')
self.history = History(os.path.join(UserConfigPath, 'history.db'))
self.tree = LeftTree(self)
- self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Navigator").decode('utf8')).
+ self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
MinimizeButton(True))
self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
val = get_table_param(self, self.input_path[0])
if val == wx.ID_OK :
- self.tableau.make_content()
- OpenAnalyse(self, self.tableau.parametres)
- self.tree.OnItemAppend(self.tableau.parametres)
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
+ wx.SafeYield()
+ try :
+ self.tableau.make_content()
+ OpenAnalyse(self, self.tableau.parametres)
+ self.tree.OnItemAppend(self.tableau.parametres)
+ del busy
+ except :
+ del busy
+ BugReport(self)
#self.tableau.show_tab()
def OnOpenAnalyse(self, event):
except:
BugReport(self)
- def SimiCluster(self, parametres = {}, fromprof = False, pathout = '', listactives = [], actives = [], tableau = None) :
- DoSimi(self, param = parametres, fromprof = fromprof, listactives = listactives, actives = actives, tableau = tableau)
+ def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
+ self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
# def OnSimi(self,evt):
# try :
from wx.lib.agw.fmresources import *
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, progressbar, normpath_win32
+from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult, progressbar, normpath_win32, TGen
from ProfList import ProfListctrlPanel
from guiparam3d import param3d, simi3d
from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
panel.TabChdSim.AddPage(self.prof_seg_nb, _(u"Repeated segments profiles").decode('utf8'))
# panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport)
+ if os.path.exists(os.path.join(self.parametres['pathout'], 'tgenchi2.csv')) :
+ self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenchi2.csv')
+ TgenLayout(panel)
+ panel.TabChdSim.SetSelection(0)
self.parent.nb.AddPage(panel, _(u"Clustering").decode('utf8') + ' - %s' % corpname)
self.parent.ShowTab(True)
self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
self.page = page
parametres = self.page.parametres
ira = wx.GetApp().GetTopWindow()
+ tgenpath = os.path.join(parametres['pathout'], 'tgen.csv')
self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t")
+ tgen = TGen(path = tgenpath, encoding = parametres['encoding'])
+ tgen.read()
tgentab = False
gparent = None
+ if 'TabChdSim' in dir(page) :
+ page = page.TabChdSim
for i in range(page.GetPageCount()) :
tab = page.GetPage(i)
if 'gparent' in dir(tab) :
if tab.tgen :
tgentab = tab
break
+
if tgentab :
self.page.tgentab.RefreshData(self.page.tgens)
- self.page.SetSelection(i)
+ self.page.tgentab.tgens = tgen.tgen
+ page.SetSelection(i)
else :
self.page.tgentab = ListForSpec(ira, gparent, self.page.tgens, etoiles[1:])
self.page.tgentab.tgen = True
- self.page.AddPage(self.page.tgentab, u'Tgens Specificities')
- self.page.SetSelection(self.page.GetPageCount() - 1)
+ self.page.tgentab.tgens = tgen.tgen
+ page.AddPage(self.page.tgentab, u'Tgens Specificities')
+ page.SetSelection(page.GetPageCount() - 1)
class dolexlayout :
def __init__(self, ira, corpus, parametres):
self.TabStat.parametres = parametres
self.ListPan = ListForSpec(ira, self, self.DictSpec, self.etoiles)
if os.path.exists(self.pathout['banalites.csv']) :
- self.listban = ListForSpec(ira, self, self.dictban, ['eff'] + self.etoiles)
+ self.listban = ListForSpec(ira, self, self.dictban, ['eff'] + self.etoiles, usefirst = True)
#self.ListPan2 = ListForSpec(sash.rightwin1, self, self.DictSpec, first)
self.ListPant = ListForSpec(ira, self, self.DictType, self.etoiles)
self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles)
self.TabAFC.AddPage(self.tabAFCTGraph, 'AFC type')
self.TabStat.AddPage(self.TabAFC, 'AFC')
-
-
-
-
ira.nb.AddPage(self.TabStat, u'Spécificités')
self.ira = ira
self.panel_1.SetBackgroundColour('white')
self.deb = wx.StaticText(self.panel_1, -1, txt)
dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+ dendro_liste_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro_liste.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+ dendro_cloud_img= wx.Image(os.path.join(self.ira.images_path,'but_dendro_cloud.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
self.butdendro = wx.BitmapButton(self, -1, dendro_img)
- self.butdendrotexte = wx.BitmapButton(self, -1, dendro_img)
- self.butdendrocloud = wx.BitmapButton(self, -1, dendro_img)
+ self.butdendrotexte = wx.BitmapButton(self, -1, dendro_liste_img)
+ self.butdendrocloud = wx.BitmapButton(self, -1, dendro_cloud_img)
for i in range(0,len(list_graph)):
if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
txt += """
load("%s")
source("%s")
+ if (is.null(debsup)) {
+ debsup <- debet
+ }
chistable <- chistabletot[1:(debsup-1),]
open_file_graph("%s", width=%i, height=%i, svg = %s)
plot.dendro.prof(tree.cut1$tree.cl, classes, chistable, nbbycl = 60, type.dendro="%s", bw=%s, lab=NULL)
txt += """
load("%s")
source("%s")
+ if (is.null(debsup)) {
+ debsup <- debet
+ }
chistable <- chistabletot[1:(debsup-1),]
open_file_graph("%s", width=%i, height=%i, svg=%s)
plot.dendro.cloud(tree.cut1$tree.cl, classes, chistable, nbbycl = 300, type.dendro="%s", bw=%s, lab=NULL)
tmpfile = tempfile.mktemp()
with open(tmpfile, 'w') as f :
f.write(txt)
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self.parent)
+ wx.SafeYield()
error = exec_rcode(self.ira.RPath, tmpfile, wait=True)
+ del busy
check_Rresult(self.ira, error)
self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
'halo' : self.dial.halo.GetValue(),
'com' : self.dial.comcheck.GetValue(),
'communities' : self.dial.choix_com.GetSelection(),
+ 'edgecurved' : self.dial.check_curved.GetValue(),
}
if 'cexfromchi' in self.parametres :
paramsimi['cexfromchi'] = self.dial.checkit.GetValue()
#---------------------------------------------------------------------------
class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
- def __init__(self, parent,gparent, dlist = {}, first = [], menu = True):
+ def __init__(self, parent,gparent, dlist = {}, first = [], usefirst = False, menu = True):
#def __init__(self, parent) :
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
self.parent=parent
self.dlist=dlist
self.first = first
self.tgen = False
- if 'etoiles' in dir(self.gparent) :
+ if 'etoiles' in dir(self.gparent) and not usefirst :
self.etoiles = self.gparent.etoiles
else :
self.etoiles = []
menu.Append(self.popupID3, u"Graphique")
menu_stcaract = wx.Menu()
self.menuid = {}
- for i, et in enumerate(self.etoiles) :
- nid = wx.NewId()
- self.menuid[nid] = i
- menu_stcaract.Append(nid, et)
- self.Bind(wx.EVT_MENU, self.onstcaract, id = nid)
- menu.AppendMenu(-1, u"Segments de texte caractéristiques", menu_stcaract)
- #menu.Append(self.popup_Tgen_glob, "Tgen global")
if not self.tgen :
- menu.Append(self.onmaketgen, "Make Tgen")
+ for i, et in enumerate(self.etoiles) :
+ nid = wx.NewId()
+ self.menuid[nid] = i
+ menu_stcaract.Append(nid, et)
+ self.Bind(wx.EVT_MENU, self.onstcaract, id = nid)
+ menu.AppendMenu(-1, u"Segments de texte caractéristiques", menu_stcaract)
+ menu.Append(self.onmaketgen, _(u"Make Tgen").decode('utf8'))
self.PopupMenu(menu)
menu.Destroy()
parametres = page.parametres
paneff = self.gparent.ListPanEff
panchi = self.gparent.ListPan
- #etoiles = self.gparent.etoiles
et = self.etoiles[ind]
-
- #if et.startswith(u'X.') :
- # et = et.replace(u'X.', u'*')
uces = corpus.getucesfrometoile(et)
self.la = [panchi.dlist[i][0] for i in range(0, len(panchi.dlist)) if panchi.dlist[i][ind+1] >= minind ]
self.lchi = [panchi.dlist[i][ind+1] for i in range(0, len(panchi.dlist)) if panchi.dlist[i][ind+1] >= minind ]
- #lfreq = [paneff.dlist[i][ind+1] for i in range(0, len(panchi.dlist)) if panchi.dlist[i][ind+1] >= minind ]
if max(self.lchi) == float('inf') :
nchi = []
for val in self.lchi :
ucis_txt, ucestxt = doconcorde(corpus, nuces, self.la)
items = dict([[i, '<br>'.join([ucis_txt[i], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table><br>' % ntab2[i][0], ucestxt[i]])] for i in range(0,len(ucestxt))])
win = message(self, items, u"Segments de texte caractéristiques - %s" % self.first[ind], (900, 600))
- #win.html = '<html>\n' + '<br>'.join(['<br>'.join([ucis_txt[i], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table>' % ntab2[i][0], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n</html>'
- #win.HtmlPage.SetPage(win.html)
win.Show(True)
def OnPopupTwo(self, event):
corpus = page.corpus
else :
corpus = self.parent.parent.parent.corpus
- item=self.getColumnText(self.GetFirstSelected(), 0)
- uce_ok = corpus.getlemuces(item)
ira = wx.GetApp().GetTopWindow()
- ucis_txt, ucestxt = doconcorde(corpus, uce_ok, [item])
+ item=self.getColumnText(self.GetFirstSelected(), 0)
+ if not self.tgen :
+ uce_ok = corpus.getlemuces(item)
+ wordlist = [item]
+ else :
+ uce_ok = corpus.gettgenst(self.tgens[item])
+ wordlist = [val for val in self.tgens[item] if val in corpus.lems]
+ ucis_txt, ucestxt = doconcorde(corpus, uce_ok, wordlist)
items = dict([[i, '<br><br>'.join([ucis_txt[i], ucestxt[i]])] for i in range(0,len(ucestxt))])
- win = message(ira, items, u"Concordancier - %s" % item, (800, 500))
- #win = message(ira, u"Concordancier", (800, 500))
- #win.html = ('<html>\n<h1>%s</h1>' % item) + '<br>'.join(['<br>'.join([ucis_txt[i], ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n</html>'
- #win.HtmlPage.SetPage(win.html)
+ win = message(ira, items, u"Concordancier - %s" % item, (800, 500), uceids = uce_ok)
win.Show(True)
def getinf(self, txt) :
WordCloudLayout(self.parent, corpus, self.conf)
elif self.conf['type'] == 'reinertmatrix' :
OpenCHDS(self.parent, corpus, self.conf, Alceste = False)
- elif self.conf['type'] == 'simimatrix' :
+ elif self.conf['type'] == 'simimatrix' or self.conf['type'] == 'simiclustermatrix':
SimiMatLayout(self.parent, corpus, self.conf)
elif self.conf['type'] == 'proto' :
ProtoLayout(self.parent, corpus, self.conf)
self.cmd = self.parametres.get('cmd', False)
self.dirout = self.parametres.get('pathout', False)
if self.fromprof:
- self.paramsimi = parametres
+ self.paramsimi = self.parametres
else :
self.paramsimi = {'coeff' : 0,
'layout' : 2,
#self.parametres['type'] = 'simimatrix'
if not self.pathout :
self.parametres['pathout'] = ConstructPathOut(self.parametres['pathout'], 'SimiMatrix')
- print self.parametres['pathout']
else :
self.parametres['pathout'] = self.dirout
self.pathout.createdir(self.parametres['pathout'])
import sys
from functions import print_liste, exec_rcode, CreateIraFile, progressbar, check_Rresult, BugDialog
from layout import PrintRapport
-from PrintRScript import AlcesteTxtProf, RPamTxt
+from PrintRScript import ReinertTxtProf, RPamTxt
from openanalyse import OpenAnalyse
from time import time, sleep
from time import time
from analysetxt import AnalyseText
from OptionAlceste import OptionAlc
-from PrintRScript import RchdTxt, AlcesteTxtProf
+from PrintRScript import RchdTxt, ReinertTxtProf, TgenProfScript
from layout import PrintRapport
-from chemins import ChdTxtPathOut
-from functions import DoConf, print_liste
+from chemins import ChdTxtPathOut, PathOut
+from functions import DoConf, print_liste, TGen
class Reinert(AnalyseText) :
return self.pathout['Rchdtxt']
def printRscript2(self) :
- AlcesteTxtProf(self.pathout, self.parent.RscriptsPath, self.clnb, 0.9)
+ ReinertTxtProf(self.pathout, self.parent.RscriptsPath, self.clnb, 0.9)
return self.pathout['RTxtProfGraph']
def print_graph_files(self) :
chd_graph_list.append([os.path.basename(self.pathout['arbre2']), u'chd2'])
print_liste(self.pathout['liste_graph_afc'], afc_graph_list)
print_liste(self.pathout['liste_graph_chd'], chd_graph_list)
- PrintRapport(self, self.corpus, self.parametres)
\ No newline at end of file
+ PrintRapport(self, self.corpus, self.parametres)
+
+class TgenProf(AnalyseText):
+ def __init__(self, ira, corpus, parametres, cluster_size):
+ self.ira = ira
+ self.corpus = corpus
+ self.parametres = parametres
+ self.pathout = PathOut(dirout = self.parametres['pathout'])
+ self.cluster_size = [len(classe) for classe in corpus.lc]
+ print cluster_size
+ self.doanalyse()
+
+ def doanalyse(self):
+ self.tgen = TGen(path = self.parametres['tgenpath'], encoding = self.ira.syscoding)
+ self.tgen.read(self.tgen.path)
+ #self.parametres['etoiles'].sort()
+ self.parametres['tgeneff'] = os.path.join(self.parametres['pathout'], 'tgeneff.csv')
+ tgenst = self.corpus.make_tgen_profile(self.tgen.tgen, self.corpus.lc)
+ clnames = ['cluster_%03d' % i for i in range(1, len(self.cluster_size) + 1)]
+ et = dict(zip(clnames, self.cluster_size))
+ tgenst = dict([[line[0], dict(zip(clnames, line[1:]))] for line in tgenst])
+ self.tgen.writetable(self.parametres['tgeneff'], tgenst, et)
+ self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenchi2.csv')
+ self.Rscript = TgenProfScript(self)
+ self.Rscript.make_script()
+ self.Rscript.write()
+ self.doR(self.Rscript.scriptout, dlg = False, message = 'R...')
+
+
+
+
+
+
\ No newline at end of file
from layout import open_antiprofil, TgenLayout
from guifunct import TGenFrame
from textaslexico import TgenSpec
+from textreinert import TgenProf
log = logging.getLogger('iramuteq.tree')
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())
+ self.ild['simiclustermatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simimatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['proto'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'proto.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.SetImageList(self.il)
self.SetItemImage(self.root, 24, CT.TreeItemIcon_Normal)
self.SetItemImage(self.root, 13, CT.TreeItemIcon_Expanded)
- self.textroot = self.AppendItem(self.root, u'Corpus texte')
+ self.textroot = self.AppendItem(self.root, _(u'Textual corpus'))
self.SetPyData(self.textroot, {'uuid': 'textroot'})
self.SetItemImage(self.textroot, imgtextroot, CT.TreeItemIcon_Normal)
self.SetItemImage(self.textroot, imgtextroot, CT.TreeItemIcon_Expanded)
self.SetItemImage(last, img, CT.TreeItemIcon_Normal)
self.SetItemImage(last, img, CT.TreeItemIcon_Expanded)
- self.matroot = self.AppendItem(self.root, u'Matrices')
+ self.matroot = self.AppendItem(self.root, _(u'Matrix'))
self.SetPyData(self.matroot, {'uuid': 'matroot'})
self.SetItemImage(self.matroot, imgmatroot, CT.TreeItemIcon_Normal)
self.SetItemImage(self.matroot, imgmatroot, CT.TreeItemIcon_Expanded)
profsr = menu.Append(wx.ID_ANY, _(u"Repeated segments profiles").decode('utf8'))
profgram = menu.Append(wx.ID_ANY, _(u"POS profiles").decode('utf8'))
+ tgen = menu.Append(wx.ID_ANY, _(u"Tgen Editor").decode('utf8'))
+ computetgen = menu.Append(wx.ID_ANY, _(u"Compute Tgen").decode('utf8'))
export_corpus = menu.Append(wx.ID_ANY, _(u"Export corpus").decode('utf8'))
colored = menu.Append(wx.ID_ANY, _(u"Colored corpus").decode('utf8'))
navig = menu.Append(wx.ID_ANY, _(u"Navigator").decode('utf8'))
self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro)
self.Bind(wx.EVT_MENU, self.OnProfSR, profsr)
self.Bind(wx.EVT_MENU, self.OnProfGram, profgram)
+ self.Bind(wx.EVT_MENU, self.OnTgenEditor, tgen)
+ self.Bind(wx.EVT_MENU, self.OnTgenCompute, computetgen)
self.Bind(wx.EVT_MENU, self.OnExportCorpus, export_corpus)
self.Bind(wx.EVT_MENU, self.OnColored, colored)
self.Bind(wx.EVT_MENU, self.OnNavig, navig)
else :
self.page.parametres['tgenpath'] = tgenpath
tgen = TGen(path = tgenpath, encoding = self.parent.syscoding)
- self.page.parametres['etoiles'] = self.page.etoiles
- TgenSpec(self.parent, corpus, self.page.parametres)
+ if self.page.parametres['type'] == 'spec' :
+ self.page.parametres['etoiles'] = self.page.etoiles
+ TgenSpec(self.parent, corpus, self.page.parametres)
+ elif self.page.parametres['type'] == 'alceste' :
+ TgenProf(self.parent, corpus, self.page.parametres, self.page.cluster_size)
TgenLayout(self.page)
def OnExportClasses(self, event):
if select :
self.history.addtab(item)
self.SetItemBold(child, True)
+ self.SelectItem(child)
#dlg = wx.TextEntryDialog(self, "Please Enter The New Item Name", 'Item Naming', 'Python')