From: Pierre Date: Sun, 27 Jan 2013 21:16:30 +0000 (+0100) Subject: ...+++... X-Git-Url: http://iramuteq.org/git?a=commitdiff_plain;h=12b4b71c8c8feb6154abc04dfa9bb93a521ef789;p=iramuteq ...+++... --- diff --git a/OptionAlceste.py b/OptionAlceste.py index ec3ab55..3d52b42 100755 --- a/OptionAlceste.py +++ b/OptionAlceste.py @@ -27,14 +27,14 @@ class OptionAlc(wx.Dialog): #self.radio_1 = wx.RadioBox(self, -1, u"", choices=['oui', 'non'], majorDimension=0, style=wx.RA_SPECIFY_ROWS) self.label_12 = wx.StaticText(self, -1, u"Classification") - self.radio_box_2 = wx.RadioBox(self, -1, u"", choices=[u"double sur UC", u"simple sur UCE", u"simple sur UCI"], majorDimension=0, style=wx.RA_SPECIFY_ROWS) #, u"simple sur UCE (non implemente)" - self.label_2 = wx.StaticText(self, -1, u"taille uc 1") + self.radio_box_2 = wx.RadioBox(self, -1, u"", choices=[u"double sur RST", u"simple sur segments de texte", u"simple sur textes"], majorDimension=0, style=wx.RA_SPECIFY_ROWS) #, u"simple sur UCE (non implemente)" + self.label_2 = wx.StaticText(self, -1, u"taille rst 1") self.spin_ctrl_1 = wx.SpinCtrl(self, -1, "formes actives",size = (100,30), min=0, max=100) - self.label_3 = wx.StaticText(self, -1, u"taille uc 2") + self.label_3 = wx.StaticText(self, -1, u"taille rst 2") self.spin_ctrl_2 = wx.SpinCtrl(self, -1, "",size = (100,30), min=0, max=100) self.lab_nbcl = wx.StaticText(self, -1, u"nombre de classes terminales de la phase 1") self.spin_nbcl = wx.SpinCtrl(self, -1, "",size = (100,30), min=2, max=100) - txt = """Nombre minimum d'uce par classe + txt = """Nombre minimum de segments de texte par classe (0 = automatique)""" self.label_7 = wx.StaticText(self, -1, txt) self.spin_ctrl_4 = wx.SpinCtrl(self, -1, "",size = (100,30), min=0, max=1000) diff --git a/PrintRScript.py b/PrintRScript.py index d0dc4f0..b80c899 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -19,7 +19,7 @@ class PrintRScript : self.analyse = analyse self.parametres = analyse.parametres self.scriptout = self.pathout['temp'] - self.script = u"#Script genere par IRaMuTeQ - %s" % datetime.now().ctime() + self.script = u"#Script genere par IRaMuTeQ - %s\n" % datetime.now().ctime() def add(self, txt) : self.script = '\n'.join([self.script, txt]) @@ -251,8 +251,8 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv fileout.close() def RPamTxt(corpus, RscriptPath): - DicoPath = corpus.dictpathout - param = corpus.parametre + DicoPath = corpus.pathout + param = corpus.parametres print param txt = """ source("%s") @@ -309,7 +309,7 @@ def RchdQuest(DicoPath, RscriptPath, nbcl = 10, mincl = 10): save(tree.cut1, file="%s") open_file_graph("%s", width = 600, height=400) classes<-n1[,ncol(n1)] - plot.dendropr(tree_cut1$tree.cl,classes) + plot.dendropr(tree_cut1$tree.cl,classes, histo = TRUE) """ % (DicoPath['Rdendro'],DicoPath['dendro1']) txt += """ @@ -385,34 +385,19 @@ write.csv2(gbcluster,file="%s") """ % (DictChdTxtOut['afc_facteur'], DictChdTxtOut['afc_col'], DictChdTxtOut['afc_row']) txt += """ - #xlab <- paste('facteur 1 - ', round(afc$facteur[1,2],2), sep = '') - #ylab <- paste('facteur 2 - ', round(afc$facteur[2,2],2), sep = '') - #xlab <- paste(xlab, ' %', sep = '') - #ylab <- paste(ylab, ' %', sep = '') - """ - - txt += """ PARCEX<-%s - xmin <- min(afc$rowcoord[,1], na.rm = TRUE) + (0.1 * min(afc$rowcoord[,1], na.rm = TRUE)) - xmax <- max(afc$rowcoord[,1], na.rm = TRUE) + (0.1 * max(afc$rowcoord[,1], na.rm = TRUE)) - ymin <- min(afc$rowcoord[,2], na.rm = TRUE) + (0.1 * min(afc$rowcoord[,2], na.rm = TRUE)) - ymax <- max(afc$rowcoord[,2], na.rm = TRUE) + (0.1 * max(afc$rowcoord[,2], na.rm = TRUE)) - print(xmin) - print(xmax) - print(ymin) - print(ymax) """ % taillecar txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab, xmin=xmin, xmax=xmax, ymin = ymin, ymax=ymax) + xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) """ % (DictChdTxtOut['AFC2DL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab, xmin=xmin, xmax=xmax, ymin = ymin, ymax=ymax) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (DictChdTxtOut['AFC2DSL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin=xmin, xmax=xmax, ymin = ymin, ymax=ymax) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (DictChdTxtOut['AFC2DEL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col=TRUE, what='coord', xlab = xlab, ylab = ylab, xmin=xmin, xmax=xmax, ymin = ymin, ymax=ymax) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col=TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (DictChdTxtOut['AFC2DCL_OUT']) # txt += """ # PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) @@ -705,7 +690,7 @@ class PrintSimiScript(PrintRScript) : self.packages(['igraph', 'proxy', 'Matrix']) self.sources([self.analyse.parent.RscriptsPath['simi'], self.analyse.parent.RscriptsPath['Rgraph']]) txt = '' - if not self.parametres['keep_coord'] : + if not self.parametres['keep_coord'] and not self.parametres['type'] == 'simimatrix': txt += """ dm.path <- "%s" cn.path <- "%s" @@ -737,7 +722,36 @@ class PrintSimiScript(PrintRScript) : index <- which(colnames(dm) == forme) } """ - + elif not self.parametres['keep_coord'] and self.parametres['type'] == 'simimatrix' : + txt += """ + dm.path <- "%s" + selected.col <- "%s" + """ % (self.pathout['mat01.csv'], self.pathout['selected.csv']) + if 'word' in self.parametres : + txt += """ + word <- TRUE + index <- %i + 1 + """ % self.parametres['word'] + else : + txt += """ + word <- FALSE + """ + txt += """ + dm <-read.csv2(dm.path) + dm <- as.matrix(dm) + sel.col <- read.csv2(selected.col, header = FALSE) + sel.col <- sel.col[,1] + 1 + if (!word) { + dm <- dm[, sel.col] + } else { + forme <- colnames(dm)[index] + if (!index %in% sel.col) { + sel.col <- append(sel.col, index) + } + dm <- dm[, sel.col] + index <- which(colnames(dm) == forme) + } + """ else : txt += """ load("%s") @@ -956,10 +970,22 @@ class PrintSimiScript(PrintRScript) : # g.toplot <- g.ori # } # """ + if self.parametres['com'] : + com = `self.parametres['communities']` + else : + com = 'NULL' + if self.parametres['halo'] : + halo = 'TRUE' + else : + halo = 'FALSE' + txt += """ + communities <- %s + halo <- %s + """ % (com, halo) txt += """ eff <- colSums(dm) x <- list(mat = mat, eff = eff) - graph.simi <- do.simi(x, method='%s', seuil = seuil, p.type = '%s', layout.type = '%s', max.tree = %s, coeff.vertex=%s, coeff.edge = %s, minmaxeff = minmaxeff, vcexminmax = vcexminmax, cex = cex, coords = coords) + graph.simi <- do.simi(x, method='%s', seuil = seuil, p.type = '%s', layout.type = '%s', max.tree = %s, coeff.vertex=%s, coeff.edge = %s, minmaxeff = minmaxeff, vcexminmax = vcexminmax, cex = cex, coords = coords, communities = communities, halo = halo) """ % (method, type, layout, arbremax, coeff_tv, coeff_te) if self.parametres.get('bystar',False) : @@ -1013,8 +1039,13 @@ class PrintSimiScript(PrintRScript) : } """ txt += """ vertex.size <- NULL """ + if self.parametres['svg'] : svg = 'TRUE' + else : svg = 'FALSE' + txt += """ + svg <- %s + """ % svg txt += """ - coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = cols, 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) + coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = cols, 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) save.image(file="%s") """ % (type, self.filename, self.pathout['RData']) diff --git a/ProfList.py b/ProfList.py index e2a7c84..a3c5c94 100644 --- a/ProfList.py +++ b/ProfList.py @@ -17,7 +17,7 @@ import os import sys import wx import wx.lib.mixins.listctrl as listmix -from tabsimi import DoSimi +#from tabsimi import DoSimi from listlex import ListForSpec from chemins import ConstructPathOut, ffr from dialog import PrefExport, PrefUCECarac, SearchDial, message @@ -376,17 +376,21 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col vchistable = [line[1:] for line in chistable] fchistable = [line[0] for line in chistable] word = self.getselectedwords()[0] + print self.var_mod if len(word.split('_')) > 1 : var = word.split('_') - words = ['_'.join([var[0],word]) for word in self.var_mod[var[0]]] + #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 : + print word if word in fchistable : tableout.append(vchistable[fchistable.index(word)]) kwords.append(word) tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR) + print tableout txt = barplot(tableout, kwords, title, self.Source.parent.RscriptsPath['Rgraph'], tmpgraph) tmpscript = tempfile.mktemp(dir=self.Source.parent.TEMPDIR) file = open(tmpscript,'w') diff --git a/Rscripts/Rgraph.R b/Rscripts/Rgraph.R index b0b555c..a4dd0da 100644 --- a/Rscripts/Rgraph.R +++ b/Rscripts/Rgraph.R @@ -83,6 +83,15 @@ PlotAfc2dCoul<- function(afc,chisqrtable,filename, what='coord',col=FALSE, axeto classes <- 1:clnb cex.par <- rep(1,clnb) } + if (is.null(xmin)) { + table.in <- rowcoord + xminmax <- c(min(table.in[,1], na.rm = TRUE) + ((max(cex.par)/10) * min(table.in[,1], na.rm = TRUE)), max(table.in[,1], na.rm = TRUE) + ((max(cex.par)/10) * max(table.in[,1], na.rm = TRUE))) + xmin <- xminmax[1] + xmax <- xminmax[2] + yminmax <- c(min(table.in[,2], na.rm = TRUE) + ((max(cex.par)/10) * min(table.in[,2], na.rm = TRUE)), max(table.in[,2], na.rm = TRUE) + ((max(cex.par)/10) * max(table.in[,2], na.rm = TRUE))) + ymin <- yminmax[1] + ymax <- yminmax[2] + } #ntabtot <- cbind(rowcoord, classes) #if (!col) ntabtot <- ntabtot[row_keep,] xlab <- paste('facteur ', x, ' -') @@ -101,7 +110,8 @@ PlotAfc2dCoul<- function(afc,chisqrtable,filename, what='coord',col=FALSE, axeto classes <- classes[table.in[,4]] cex.par <- cex.par[table.in[,4]] make_afc_graph(table.in, classes, clnb, xlab, ylab, cex.txt = cex.par, xminmax=c(xmin,xmax), yminmax=c(ymin,ymax)) - + xyminmax <- list(yminmax = c(ymin,ymax), xminmax = c(xmin,xmax)) + xyminmax #plot(rowcoord[,x],rowcoord[,y], pch='', xlab = xlab, ylab = ylab) #abline(h=0,v=0) #for (i in 1:clnb) { diff --git a/Rscripts/afc_graph.R b/Rscripts/afc_graph.R index 8a62d8a..e0c2adf 100644 --- a/Rscripts/afc_graph.R +++ b/Rscripts/afc_graph.R @@ -76,21 +76,22 @@ if ( qui == 3 ) { ry <- range(table.in[,2], na.rm = TRUE) rz <- range(table.in[,3], na.rm = TRUE) } + eff <- rowSums(afctable) if (!is.null(debsup)) { if ( qui == 0 ) { table.in <- table.in[1:(debsup-1),] tablechi <- tablechi[1:(debsup-1),] - cex.par <- afc$rowmass[1:(debsup-1)] + cex.par <- eff[1:(debsup-1)] } if ( qui == 1 ) { table.in <- table.in[debsup:(debet-1),] tablechi <- tablechi[debsup:(debet-1),] - #cex.par <- afc$rowmass[debsup:(debet-1)] + cex.par <- eff[debsup:(debet-1)] } if ( qui == 2 ) { table.in <- table.in[debet:nrow(table.in),] tablechi <- tablechi[debet:nrow(tablechi),] - #cex.par <- afc$rowmass[debet:nrow(tablechi)] + cex.par <- eff[debet:nrow(afctable)] } } @@ -99,14 +100,14 @@ if ( qui == 3 ) { if (!is.null(debet)) { table.in <- table.in[1:(debet-1),] tablechi <- tablechi[1:(debet-1),] - cex.par <- afc$rowmass[1:(debet-1)] + cex.par <- eff[1:(debet-1)] } else { - cex.par <- afc$rowmass + cex.par <- eff } } else { table.in <- table.in[debet:nrow(table.in),] tablechi <- tablechi[debet:nrow(tablechi),] - #cex.par <- afc$rowmass[debet:nrow(tablechi)] + cex.par <- eff[debet:nrow(afctable)] } } diff --git a/Rscripts/chdquest.R b/Rscripts/chdquest.R index 0bbe0d8..e8ad294 100644 --- a/Rscripts/chdquest.R +++ b/Rscripts/chdquest.R @@ -9,12 +9,36 @@ fille<-function(classe,classeuce) { listf } + +croiseeff <- function(croise, classeuce1, classeuce2) { + cl1 <- 0 + cl2 <- 1 + for (i in 1:ncol(classeuce1)) { + cl1 <- cl1 + 2 + cl2 <- cl2 + 2 + clj1 <- 0 + clj2 <- 1 + for (j in 1:ncol(classeuce2)) { + clj1 <- clj1 + 2 + clj2 <- clj2 + 2 + croise[cl1 - 1, clj1 -1] <- length(which(classeuce1[,i] == cl1 & classeuce2[,j] == clj1)) + croise[cl1 - 1, clj2 -1] <- length(which(classeuce1[,i] == cl1 & classeuce2[,j] == clj2)) + croise[cl2 - 1, clj1 -1] <- length(which(classeuce1[,i] == cl2 & classeuce2[,j] == clj1)) + croise[cl2 - 1, clj2 -1] <- length(which(classeuce1[,i] == cl2 & classeuce2[,j] == clj2)) + } + } + croise +} + + #fonction pour la double classification #cette fonction doit etre splitter en 4 ou 5 fonctions -Rchdquest<-function(tableuc1,listeuce1,uceout ,nbt = 9, mincl = 2) { +Rchdquest<-function(tableuc1,listeuce1,uceout ,nbt = 9, mincl = 2, mode.patate = FALSE, svd.method = 'irlba') { #source('/home/pierre/workspace/iramuteq/Rscripts/CHD.R') - + if (svd.method == 'irlba') { + library(irlba) + } #lecture des tableaux data1<-read.csv2(tableuc1)#,row.names=1) cn.data1 <- colnames(data1) @@ -28,7 +52,7 @@ Rchdquest<-function(tableuc1,listeuce1,uceout ,nbt = 9, mincl = 2) { sc<-sc[-which(sc<=4)] } #analyse des tableaux avec la fonction CHD qui doit etre sourcee avant - chd1<-CHD(data1, x = nbt) + chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method) chd2<-chd1 #FIXME: le nombre de classe peut etre inferieur @@ -40,53 +64,70 @@ Rchdquest<-function(tableuc1,listeuce1,uceout ,nbt = 9, mincl = 2) { listuce2<-listuce1 #Une fonction pour assigner une classe a chaque UCE - AssignClasseToUce<-function(listuce,chd) { - out<-matrix(nrow=nrow(listuce),ncol=ncol(chd)) - for (i in 1:nrow(listuce)) { - for (j in 1:ncol(chd)) { - out[i,j]<-chd[(listuce[i,2]+1),j] - } - } - out - } +# AssignClasseToUce<-function(listuce,chd) { +# out<-matrix(nrow=nrow(listuce),ncol=ncol(chd)) +# for (i in 1:nrow(listuce)) { +# for (j in 1:ncol(chd)) { +# out[i,j]<-chd[(listuce[i,2]+1),j] +# } +# } +# out +# } + AssignClasseToUce <- function(listuce, chd) { + print('assigne classe -> uce') + chd[listuce[,2]+1,] + } #Assignation des classes classeuce1<-AssignClasseToUce(listuce1,chd1$n1) classeuce2<-classeuce1 #calcul des poids (effectifs) poids1<-vector(mode='integer',length=tcl) - makepoids<-function(classeuce,poids) { - for (classes in 2:(tcl + 1)){ - for (i in 1:ncol(classeuce)) { - if (poids[(classes-1)] 3.84, arr.ind = TRUE) + #print(listxy) + val <- chicroise[which(chicroise > 3.84)] + ord <- order(val, decreasing = TRUE) + listxy <- listxy[ord,] + #for (i in 1:nrow(listxy)) { + # if ((!listxy[,2][i] %in% listx) & (!listxy[,1][i] %in% listy)) { + # listx <- c(listx, listxy[,2][i]) + # listy <- c(listy, listxy[,1][i]) + # } + #} + xy <- list(x = listxy[,2], y = listxy[,1]) + xy + } + xy <- doxy(chicroise) + print(xy) + listx <- xy$x + listy <- xy$y + +# maxi<-vector() +# chimax<-vector() +# for (i in 1:tcl) { +# maxi[i]<-which.max(chicroise) +# chimax[i]<-chicroise[maxi[i]] +# chicroise[maxi[i]]<-0 +# } +# testpres<-function(x,listcoord) { +# for (i in 1:length(listcoord)) { +# if (x==listcoord[i]) { +# return(-1) +# } else { +# a<-1 +# } +# } +# a +# } +# c.len=nrow(chicroise) +# r.len=ncol(chicroise) +# listx<-c(0) +# listy<-c(0) +# rang<-0 +# cons<-list() +# #on garde une valeur par ligne / colonne +# for (i in 1:length(maxi)) { +# #coordonnées de chi2 max +# x.co<-ceiling(maxi[i]/c.len) +# y.co<-maxi[i]-(x.co-1)*c.len +# a<-testpres(x.co,listx) +# b<-testpres(y.co,listy) +# +# if (a==1) { +# if (b==1) { +# rang<-rang+1 +# listx[rang]<-x.co +# listy[rang]<-y.co +# } +# } +# cons[[1]]<-listx +# cons[[2]]<-listy +# } #pour ecrire les resultats for (i in 1:length(listx)) { txt<-paste(listx[i]+1,listy[i]+1,sep=' ') diff --git a/Rscripts/simi.R b/Rscripts/simi.R index 067eaec..b8c2369 100644 --- a/Rscripts/simi.R +++ b/Rscripts/simi.R @@ -114,7 +114,7 @@ BuildProf01<-function(x,classes) { mat } -do.simi <- function(x, method = 'cooc',seuil = NULL, p.type = 'tkplot',layout.type = 'frutch', max.tree = TRUE, coeff.vertex=NULL, coeff.edge = NULL, minmaxeff=c(NULL,NULL), vcexminmax= c(NULL,NULL), cex = 1, coords = NULL) { +do.simi <- function(x, method = 'cooc',seuil = NULL, p.type = 'tkplot',layout.type = 'frutch', max.tree = TRUE, coeff.vertex=NULL, coeff.edge = NULL, minmaxeff=c(NULL,NULL), vcexminmax= c(NULL,NULL), cex = 1, coords = NULL, communities = NULL, halo = FALSE) { mat.simi <- x$mat mat.eff <- x$eff v.label <- colnames(mat.simi) @@ -122,7 +122,11 @@ do.simi <- function(x, method = 'cooc',seuil = NULL, p.type = 'tkplot',layout.ty g.toplot<-g1 weori<-get.edge.attribute(g1,'weight') if (max.tree) { - invw<-1/weori + if (method == 'cooc') { + invw<-1/weori + } else { + + } E(g1)$weight<-invw g.max<-minimum.spanning.tree(g1) E(g.max)$weight<-1/E(g.max)$weight @@ -130,19 +134,20 @@ do.simi <- function(x, method = 'cooc',seuil = NULL, p.type = 'tkplot',layout.ty } if (!is.null(seuil)) { - if (seuil >= max(mat.simi)) seuil <- max(mat.simi)-1 + print(seuil) + if (seuil >= max(mat.simi)) seuil <- 0 vec<-vector() w<-E(g.toplot)$weight tovire <- which(w<=seuil) - g.toplot <- delete.edges(g.toplot,(tovire-1)) - for (i in 0:(length(V(g.toplot))-1)) { + g.toplot <- delete.edges(g.toplot,(tovire)) + for (i in 0:(length(V(g.toplot)))) { if (length(neighbors(g.toplot,i))==0) { vec<-append(vec,i) } } g.toplot <- delete.vertices(g.toplot,vec) v.label <- V(g.toplot)$name - if (!is.logical(vec)) mat.eff <- mat.eff[-(vec+1)] + if (!is.logical(vec)) mat.eff <- mat.eff[-(vec)] } if (!is.null(minmaxeff[1])) { @@ -187,10 +192,32 @@ do.simi <- function(x, method = 'cooc',seuil = NULL, p.type = 'tkplot',layout.ty } else { lo <- coords } - 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) + if (!is.null(communities)) { + if (communities == 0 ){ #'edge.betweenness.community') { + com <- edge.betweenness.community(g.toplot) + } else if (communities == 1) { + com <- fastgreedy.community(g.toplot) + } else if (communities == 2) { + com <- label.propagation.community(g.toplot) + } else if (communities == 3) { + com <- leading.eigenvector.community(g.toplot) + } else if (communities == 4) { + com <- multilevel.community(g.toplot) + } else if (communities == 5) { + com <- optimal.community(g.toplot) + } else if (communities == 6) { + com <- spinglass.community(g.toplot) + } else if (communities == 7) { + com <- walktrap.community(g.toplot) + } + } else { + com <- NULL + } + + 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) } -plot.simi <- function(graph.simi, p.type = 'tkplot',filename=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) { +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) { mat.simi <- graph.simi$mat g.toplot <- graph.simi$graph if (is.null(vertex.size)) { @@ -232,14 +259,31 @@ plot.simi <- function(graph.simi, p.type = 'tkplot',filename=NULL, vertex.col = } if (p.type=='nplot') { #print('ATTENTION - PAS OPEN FILE') - open_file_graph(filename, width = width, height = height) + open_file_graph(filename, width = width, height = height, svg = svg) par(mar=c(2,2,2,2)) if (!is.null(leg)) { layout(matrix(c(1,2),1,2, byrow=TRUE),widths=c(3,lcm(7))) par(mar=c(2,2,1,0)) } par(pch=' ') - 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)#, rescale = FALSE) + 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)#, rescale = FALSE) + } else { + com <- graph.simi$com + colm <- rainbow(length(com)) + if (vertex.size != 0 || graph.simi$halo) { + vertex.label.color <- 'black' + vertex.col <- colm[membership(com)] + } else { + vertex.label.color <- colm[membership(com)] + } + if (graph.simi$halo) { + mark.groups <- communities(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) + } #txt.layout <- lo txt.layout <- layout.norm(lo, -1, 1, -1, 1, -1, 1) #txt.layout <- txt.layout[order(label.cex),] diff --git a/analysematrix.py b/analysematrix.py index 1a14c4a..2a3c88d 100644 --- a/analysematrix.py +++ b/analysematrix.py @@ -57,4 +57,15 @@ class AnalyseMatrix : def doanalyse(self) : pass - + + def doR(self, Rscript, wait = False, dlg = None, message = '') : + log.info('R code...') + pid = exec_rcode(self.ira.RPath, Rscript, wait = wait) + while pid.poll() is None : + if dlg : + self.dlg.Pulse(message) + sleep(0.2) + else : + sleep(0.2) + return check_Rresult(self.ira, pid) + diff --git a/chemins.py b/chemins.py index b441a32..57e31c9 100644 --- a/chemins.py +++ b/chemins.py @@ -271,18 +271,16 @@ def StatTxtPathOut(pathout): } return d -def construct_simipath(pathout): - d = {'mat01' : ffr(os.path.join(pathout, 'mat01.csv')), - 'matsimi' : ffr(os.path.join(pathout, 'matsimi.csv')), - 'eff' : ffr(os.path.join(pathout, 'eff.csv')), - 'RData' : ffr(os.path.join(pathout, 'RData.RData')), - 'liste_graph' : os.path.join(pathout, 'liste_graph.txt'), - 'ira' : os.path.join(pathout, 'Analyse.ira'), - 'film' : ffr(pathout), - 'db' : os.path.join(pathout, 'analyse.db'), - 'corpus' : os.path.join(pathout, 'corpus.db'), - } - return d +#def construct_simipath(pathout): +# d = {'mat01' : 'mat01.csv', +# 'matsimi' : 'matsimi.csv', +# 'eff' : 'eff.csv', +# 'RData' : 'RData.RData', +# 'liste_graph' : 'liste_graph.txt', +# 'ira' : 'Analyse.ira', +# 'film' : '', +# 'db' : 'analyse.db', +# } simipath = {'mat01' : 'mat01.csv', 'matsimi' : 'matsimi.csv', diff --git a/corpus.py b/corpus.py index 90332c1..44ea0ef 100644 --- a/corpus.py +++ b/corpus.py @@ -563,16 +563,16 @@ class Corpus : if et[0] in det : try : endet = '_'.join(et[1:]) - if endet in det[et[0]] : - det[et[0]][endet] += 1 + if etoile in det[et[0]] : + det[et[0]][etoile] += 1 else : - det[et[0]][endet] = 1 + det[et[0]][etoile] = 1 except IndexError : det[et[0]] += 1 else : try : endet = '_'.join(et[1:]) - det[et[0]] = {endet :1} + det[et[0]] = {etoile :1} except IndexError : det[et[0]] = 1 return det diff --git a/dialog.py b/dialog.py index 3a6917a..d918538 100755 --- a/dialog.py +++ b/dialog.py @@ -604,7 +604,7 @@ par le chi2 de liaison aux classes""" self.label_6 = wx.StaticText(self, -1, u'Eliminer les recouvrements') self.check3 = wx.CheckBox(self, -1) txt = u"""Taille du texte proportionnel -à la masse de la forme""" +à l'effectif de la forme""" self.label_7 = wx.StaticText(self, -1, txt) self.check4 = wx.CheckBox(self, -1) self.label_min = wx.StaticText(self, -1, 'min') @@ -904,7 +904,7 @@ au chi2 d'association de la forme""" self.slider_sphere.Enable(False) def OnPass(self,evt) : - if evt.GetString() != u'actives' : + if evt.GetString() == u'classes' : self.check4.SetValue(False) self.check4.Enable(False) self.OnNorm(wx.EVT_CHECKBOX) @@ -2608,3 +2608,43 @@ class ExtractDialog ( wx.Dialog ): def __del__( self ): pass + +class FreqDialog(wx.Dialog): + def __init__(self, parent, ID, listcol, title, size) : + wx.Dialog.__init__(self, parent, ID, title, size=size, pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK ) + pre = wx.PreDialog() + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) + pre.Create(parent, ID, title, wx.DefaultPosition, size, wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK) + self.PostCreate(pre) + self.parent = parent + sizer = wx.BoxSizer(wx.VERTICAL) + #self.content = parent.content + self.header = listcol + #LABELLIST = [] + #for i in self.header: + # forme = i + # if len(forme) > 60 : + # LABELLIST.append(i[0:60]) + # else: + # LABELLIST.append(i) + self.list_box_1 = wx.ListBox(self, -1, choices=self.header, style=wx.LB_EXTENDED | wx.LB_HSCROLL) + sizer.Add(self.list_box_1, 0, 5) + + btnsizer = wx.BoxSizer(wx.HORIZONTAL) + + btn = wx.Button(self, wx.ID_CANCEL) + btn.SetHelpText("Annuler") + btnsizer.Add(btn) + + btn = wx.Button(self, wx.ID_OK) + btn.SetHelpText("Valider") + btn.SetDefault() + btnsizer.Add(btn) + + sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5) + self.SetSizer(sizer) + sizer.Fit(self) + self.SetTitle(u"Sélection") + + # end wxGlade + diff --git a/guifunct.py b/guifunct.py index ca8f66c..a12d169 100644 --- a/guifunct.py +++ b/guifunct.py @@ -247,7 +247,15 @@ class PrefSimi ( wx.Dialog ): choice3Choices = [ u"dynamique", u"statique", u"3D" ] self.choice3 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 ) self.choice3.SetSelection( 0 ) - fgSizer3.Add( self.choice3, 0, wx.ALL, 5 ) + + label_format = wx.StaticText(self.m_panel2, -1, u"Format de l'image") + self.choix_format = wx.Choice(self.m_panel2, -1, (100,50), choices = ['png', 'svg']) + self.choix_format.SetSelection( 0 ) + hsizer = wx.BoxSizer(wx.HORIZONTAL) + hsizer.Add(self.choice3, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + hsizer.Add(label_format, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + hsizer.Add(self.choix_format, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + fgSizer3.Add( hsizer, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) self.m_staticline296 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer3.Add( self.m_staticline296, 0, wx.EXPAND, 5 ) @@ -328,6 +336,26 @@ class PrefSimi ( wx.Dialog ): self.m_staticline2917 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer3.Add( self.m_staticline2917, 0, wx.EXPAND, 5 ) + bsizer34 = wx.BoxSizer(wx.HORIZONTAL) + + comtext = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Communauté", wx.DefaultPosition, wx.DefaultSize, 0 ) + comtext.Wrap( -1 ) + bsizer34.Add(comtext, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.comcheck = wx.CheckBox(self.m_panel2, -1) + bsizer34.Add(self.comcheck, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + fgSizer3.Add(bsizer34 , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + sizer54 = wx.BoxSizer(wx.HORIZONTAL) + self.comlist = ['edge.betweenness.community','fastgreedy.community','label.propagation.community','leading.eigenvector.community','multilevel.community','optimal.community', 'spinglass.community', 'walktrap.community'] + self.choix_com = wx.Choice( self.m_panel2, wx.ID_ANY, choices = self.comlist) + self.choix_com.SetSelection( 0 ) + self.halo = wx.CheckBox(self.m_panel2, wx.ID_ANY, u'halo') + sizer54.Add(self.choix_com , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + sizer54.Add(self.halo , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + fgSizer3.Add( sizer54, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + if 'bystar' in self.paramsimi : self.m_staticText40 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Sélectionner une variable", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText40.Wrap( -1 ) @@ -681,495 +709,14 @@ class PrefSimi ( wx.Dialog ): self.__set_properties() # Connect Events - if not self.paramsimi['first'] : - self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords ) - self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType ) - self.check2.Bind( wx.EVT_CHECKBOX, self.OnCheck2 ) - self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki ) - self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex ) - self.checkit.Bind( wx.EVT_CHECKBOX, self.OnCheckit ) - self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size ) - -# self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) -# -# bSizer16 = wx.BoxSizer( wx.HORIZONTAL ) -# if wordlist is not None : -# liscol = ListForSpec(dial, self, wordlist, ['forme', 'eff']) -# bSizer16.Add(liscol, 0, wx.ALL| wx.EXPAND, 5 ) -# -# self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) -# -# bSizer18 = wx.BoxSizer( wx.VERTICAL ) -# fgSizer5 = wx.FlexGridSizer( 0, 3, 0, 0 ) -# fgSizer5.SetFlexibleDirection( wx.BOTH ) -# fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer3.SetFlexibleDirection( wx.BOTH ) -# fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# #self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Sélectionner les colonnes", wx.DefaultPosition, wx.DefaultSize, 0 ) -# #self.m_staticText1.Wrap( -1 ) -# #fgSizer3.Add( self.m_staticText1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# #self.check_colch = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# #fgSizer3.Add( self.check_colch, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline29 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline29, 0, wx.EXPAND, 5 ) -# -# self.m_staticline291 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline291, 0, wx.EXPAND, 5 ) -# if not self.paramsimi['first'] : -# -# self.m_staticText271 = wx.StaticText( self, wx.ID_ANY, u"Utiliser les coordonnées\nprécédentes", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText271.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText271, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.check_coord = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# fgSizer3.Add( self.check_coord, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline36 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline36, 0, wx.EXPAND, 5 ) -# -# self.m_staticline37 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline37, 0, wx.EXPAND, 5 ) -# -# self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Indice", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText3.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# choice1Choices = [] -# self.choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.indices, 0 ) -# self.choice1.SetSelection( 0 ) -# fgSizer3.Add( self.choice1, 0, wx.ALL, 5 ) -# -# self.m_staticline293 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline293, 0, wx.EXPAND, 5 ) -# -# self.m_staticline292 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline292, 0, wx.EXPAND, 5 ) -# -# self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, u"Layout", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText4.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# choice2Choices = [u"random", u"cercle", u"fruchterman reingold", u"kamada kawai", u"graphopt"] -# self.choice2 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice2Choices, 0 ) -# self.choice2.SetSelection( 0 ) -# fgSizer3.Add( self.choice2, 0, wx.ALL, 5 ) -# -# self.m_staticline294 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline294, 0, wx.EXPAND, 5 ) -# -# self.m_staticline295 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline295, 0, wx.EXPAND, 5 ) -# -# self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, u"Type de graph", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText5.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# choice3Choices = [u"dynamique", u"statique", u"3D"] -# self.choice3 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 ) -# self.choice3.SetSelection( 0 ) -# fgSizer3.Add( self.choice3, 0, wx.ALL, 5 ) -# -# self.m_staticline296 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline296, 0, wx.EXPAND, 5 ) -# -# self.m_staticline297 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline297, 0, wx.EXPAND, 5 ) -# -# self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"Arbre maximum", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText8.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText8, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.check1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# fgSizer3.Add( self.check1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline298 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline298, 0, wx.EXPAND, 5 ) -# -# self.m_staticline299 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline299, 0, wx.EXPAND, 5 ) -# -# self.m_staticText91 = wx.StaticText( self, wx.ID_ANY, u"Graph à seuil", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText91.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText91, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# bSizer21 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.check_seuil = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer21.Add( self.check_seuil, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.spin_seuil = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 1 ) -# bSizer21.Add( self.spin_seuil, 0, wx.ALL, 5 ) -# -# fgSizer3.Add( bSizer21, 1, wx.EXPAND, 5 ) -# -# self.m_staticline2910 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2910, 0, wx.EXPAND, 5 ) -# -# self.m_staticline2911 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2911, 0, wx.EXPAND, 5 ) -# -# self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"Texte sur les sommets", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText19.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText19, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.check_vlab = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# fgSizer3.Add( self.check_vlab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline2912 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2912, 0, wx.EXPAND, 5 ) -# -# self.m_staticline2913 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2913, 0, wx.EXPAND, 5 ) -# -# self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"Indices sur les arêtes", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText20.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText20, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.check_elab = wx.CheckBox( self, 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_staticline2914 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2914, 0, wx.EXPAND, 5 ) -# -# self.m_staticline2915 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2915, 0, wx.EXPAND, 5 ) -# -# self.m_staticText27 = wx.StaticText( self, wx.ID_ANY, u"Taille du texte", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText27.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText27, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.spin_cex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 10 ) -# fgSizer3.Add( self.spin_cex, 0, wx.ALL, 5 ) -# -# self.m_staticline2916 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2916, 0, wx.EXPAND, 5 ) -# -# self.m_staticline2917 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline2917, 0, wx.EXPAND, 5 ) -# -# if 'bystar' in self.paramsimi : -# self.m_staticText40 = wx.StaticText( self, wx.ID_ANY, u"Sélectionner une variable", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText40.Wrap( -1 ) -# fgSizer3.Add( self.m_staticText40, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.check_bystar = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# fgSizer3.Add( self.check_bystar, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline3200 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline3200, 0, wx.EXPAND, 5 ) -# self.m_staticline3201 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer3.Add( self.m_staticline3201, 0, wx.EXPAND, 5 ) -# -# fgSizer5.Add( fgSizer3, 1, wx.EXPAND, 5 ) -# -# self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL ) -# self.m_staticline5.SetForegroundColour( wx.Colour( 0, 0, 0 ) ) -# -# fgSizer5.Add( self.m_staticline5, 0, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) -# -# fgSizer51 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer51.SetFlexibleDirection( wx.BOTH ) -# fgSizer51.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"Taille du graphique", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText6.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# fgSizer31 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer31.SetFlexibleDirection( wx.BOTH ) -# fgSizer31.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, u"hauteur", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText9.Wrap( -1 ) -# fgSizer31.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_height = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 10, 100000, 800 ) -# fgSizer31.Add( self.spin_height, 0, wx.ALL, 5 ) -# -# self.m_staticText10 = wx.StaticText( self, wx.ID_ANY, u"largeur", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText10.Wrap( -1 ) -# fgSizer31.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_width = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 10, 100000, 800 ) -# fgSizer31.Add( self.spin_width, 0, wx.ALL, 5 ) -# -# fgSizer51.Add( fgSizer31, 1, wx.EXPAND, 5 ) -# -# self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline3, 0, wx.EXPAND, 5 ) -# -# self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline4, 0, wx.EXPAND, 5 ) -# -# self.m_staticText101 = wx.StaticText( self, wx.ID_ANY, u"Taille des sommets \nproportionnelle à l'effectif\n(les scores sont normalisés)", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText101.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText101, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# bSizer7 = wx.BoxSizer( wx.HORIZONTAL ) -# -# bSizer9 = wx.BoxSizer( wx.VERTICAL ) -# -# self.check2 = wx.CheckBox( self, wx.ID_ANY, u"eff.", wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer9.Add( self.check2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# if 'sfromchi' in self.paramsimi : -# self.checki = wx.CheckBox( self, wx.ID_ANY, u"chi2", wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer9.Add( self.checki, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# bSizer7.Add( bSizer9, 0, wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# fgSizer7 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer7.SetFlexibleDirection( wx.BOTH ) -# fgSizer7.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText11.Wrap( -1 ) -# fgSizer7.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_tvmin = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer7.Add( self.spin_tvmin, 0, wx.ALL, 5 ) -# -# self.m_staticText12 = wx.StaticText( self, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText12.Wrap( -1 ) -# fgSizer7.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_tvmax = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer7.Add( self.spin_tvmax, 0, wx.ALL, 5 ) -# -# bSizer7.Add( fgSizer7, 1, wx.EXPAND, 5 ) -# -# fgSizer51.Add( bSizer7, 1, wx.EXPAND, 5 ) -# -# self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline31, 0, wx.EXPAND, 5 ) -# -# self.m_staticline32 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline32, 0, wx.EXPAND, 5 ) -# -# self.m_staticText1011 = wx.StaticText( self, wx.ID_ANY, u"Taille du texte des sommets \nproportionnelle à l'effectif\n(les scores sont normalisés)", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText1011.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText1011, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# bSizer71 = wx.BoxSizer( wx.HORIZONTAL ) -# -# bSizer8 = wx.BoxSizer( wx.VERTICAL ) -# -# self.check_vcex = wx.CheckBox( self, wx.ID_ANY, u"eff.", wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer8.Add( self.check_vcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# if 'cexfromchi' in self.paramsimi : -# -# self.checkit = wx.CheckBox( self, wx.ID_ANY, u"chi2", wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer8.Add( self.checkit, 0, wx.ALL, 5 ) -# -# bSizer71.Add( bSizer8, 0, wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# fgSizer71 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer71.SetFlexibleDirection( wx.BOTH ) -# fgSizer71.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# self.m_staticText111 = wx.StaticText( self, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText111.Wrap( -1 ) -# fgSizer71.Add( self.m_staticText111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_vcexmin = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer71.Add( self.spin_vcexmin, 0, wx.ALL, 5 ) -# -# self.m_staticText121 = wx.StaticText( self, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText121.Wrap( -1 ) -# fgSizer71.Add( self.m_staticText121, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_vcexmax = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer71.Add( self.spin_vcexmax, 0, wx.ALL, 5 ) -# -# bSizer71.Add( fgSizer71, 1, wx.EXPAND, 5 ) -# -# fgSizer51.Add( bSizer71, 1, wx.EXPAND, 5 ) -# -# self.m_staticline321 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline321, 0, wx.EXPAND, 5 ) -# -# self.m_staticline322 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline322, 0, wx.EXPAND, 5 ) -# -# self.m_staticText10111 = wx.StaticText( self, wx.ID_ANY, u"Largeur des arêtes\nproportionnelle à l'indice", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText10111.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText10111, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# bSizer711 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.check3 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer711.Add( self.check3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# fgSizer711 = wx.FlexGridSizer( 0, 2, 0, 0 ) -# fgSizer711.SetFlexibleDirection( wx.BOTH ) -# fgSizer711.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) -# -# self.m_staticText1111 = wx.StaticText( self, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText1111.Wrap( -1 ) -# fgSizer711.Add( self.m_staticText1111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_temin = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer711.Add( self.spin_temin, 0, wx.ALL, 5 ) -# -# self.m_staticText1211 = wx.StaticText( self, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText1211.Wrap( -1 ) -# fgSizer711.Add( self.m_staticText1211, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.spin_temax = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 ) -# fgSizer711.Add( self.spin_temax, 0, wx.ALL, 5 ) -# -# bSizer711.Add( fgSizer711, 1, wx.EXPAND, 5 ) -# -# fgSizer51.Add( bSizer711, 1, wx.EXPAND, 5 ) -# -# self.m_staticline33 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline33, 0, wx.EXPAND, 5 ) -# -# self.m_staticline34 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline34, 0, wx.EXPAND, 5 ) -# -# self.m_staticText28 = wx.StaticText( self, wx.ID_ANY, u"Gradiant de gris sur les textes en fonction \nde l'effectif (du chi2) (0=noir; 1=blanc)", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText28.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText28, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# bSizer10 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.m_checkBox14 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer10.Add( self.m_checkBox14, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# bSizer11 = wx.BoxSizer( wx.VERTICAL ) -# -# bSizer12 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.m_staticText31 = wx.StaticText( self, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText31.Wrap( -1 ) -# bSizer12.Add( self.m_staticText31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.m_spinCtrl14 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10, 0 ) -# bSizer12.Add( self.m_spinCtrl14, 0, wx.ALL, 5 ) -# -# bSizer11.Add( bSizer12, 1, wx.EXPAND, 5 ) -# -# bSizer13 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.m_staticText32 = wx.StaticText( self, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText32.Wrap( -1 ) -# bSizer13.Add( self.m_staticText32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# self.m_spinCtrl15 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10, 10 ) -# bSizer13.Add( self.m_spinCtrl15, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) -# -# bSizer11.Add( bSizer13, 1, wx.EXPAND, 5 ) -# -# bSizer10.Add( bSizer11, 1, wx.EXPAND, 5 ) -# -# fgSizer51.Add( bSizer10, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 ) -# -# self.m_staticline3311 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline3311, 0, wx.EXPAND |wx.ALL, 5 ) -# -# self.m_staticline33111 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline33111, 0, wx.EXPAND |wx.ALL, 5 ) -# bSizer5 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, u"Couleur des sommets", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText21.Wrap( -1 ) -# bSizer5.Add( self.m_staticText21, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.cols = wx.ColourPickerCtrl( self, wx.ID_ANY, wx.Colour( 255, 0, 0 ), wx.DefaultPosition, wx.Size( 10,10 ), wx.CLRP_DEFAULT_STYLE ) -# bSizer5.Add( self.cols, 0, wx.ALL, 5 ) -# -# fgSizer51.Add( bSizer5, 1, wx.EXPAND, 5 ) -# -# bSizer6 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.m_staticText22 = wx.StaticText( self, wx.ID_ANY, u"Couleur des arêtes", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText22.Wrap( -1 ) -# bSizer6.Add( self.m_staticText22, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.cola = wx.ColourPickerCtrl( self, wx.ID_ANY, wx.Colour( 208, 208, 208 ), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE ) -# bSizer6.Add( self.cola, 0, wx.ALL, 5 ) -# -# fgSizer51.Add( bSizer6, 1, wx.EXPAND, 5 ) -# -# self.m_staticline331 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline331, 0, wx.EXPAND, 5 ) -# -# self.m_staticline332 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline332, 0, wx.EXPAND, 5 ) -# -# self.m_staticText23 = wx.StaticText( self, wx.ID_ANY, u"Taille des sommets unique", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText23.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText23, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# bSizer72 = wx.BoxSizer( wx.HORIZONTAL ) -# -# self.check_s_size = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# bSizer72.Add( self.check_s_size, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.spin_tv = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 10 ) -# bSizer72.Add( self.spin_tv, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# fgSizer51.Add( bSizer72, 1, wx.EXPAND, 5 ) -# -# self.m_staticline333 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline333, 0, wx.EXPAND, 5 ) -# -# self.m_staticline334 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline334, 0, wx.EXPAND, 5 ) -# -# self.m_staticText24 = wx.StaticText( self, wx.ID_ANY, u"Transparence des sphères", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText24.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText24, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.slider_sphere = wx.Slider( self, wx.ID_ANY, 10, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL|wx.SL_LABELS ) -# fgSizer51.Add( self.slider_sphere, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline335 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline335, 0, wx.EXPAND, 5 ) -# -# self.m_staticline336 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline336, 0, wx.EXPAND, 5 ) -# -# self.m_staticText25 = wx.StaticText( self, wx.ID_ANY, u"Faire un film", wx.DefaultPosition, wx.DefaultSize, 0 ) -# self.m_staticText25.Wrap( -1 ) -# fgSizer51.Add( self.m_staticText25, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.film = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) -# fgSizer51.Add( self.film, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) -# -# self.m_staticline2918 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline2918, 0, wx.EXPAND, 5 ) -# -# self.m_staticline2919 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) -# fgSizer51.Add( self.m_staticline2919, 0, wx.EXPAND, 5 ) -# -# -# fgSizer51.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) -# -# m_sdbSizer2 = wx.StdDialogButtonSizer() -# self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK ) -# m_sdbSizer2.AddButton( self.m_sdbSizer2OK ) -# self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL ) -# m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel ) -# m_sdbSizer2.Realize(); -# fgSizer51.Add( m_sdbSizer2, 1, wx.EXPAND, 5 ) -# -# fgSizer5.Add( fgSizer51, 1, wx.EXPAND, 5 ) -# -# self.SetSizer( fgSizer5 ) -# self.__set_properties() -# -# self.Layout() -# fgSizer5.Fit( self ) -# -# self.Centre( wx.BOTH ) + # if not self.paramsimi['first'] : + # self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords ) + # self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType ) + # self.check2.Bind( wx.EVT_CHECKBOX, self.OnCheck2 ) + # self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki ) + # self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex ) + # self.checkit.Bind( wx.EVT_CHECKBOX, self.OnCheckit ) + # self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size ) # Connect Events if not self.paramsimi['first'] : @@ -1187,7 +734,7 @@ class PrefSimi ( wx.Dialog ): self.choice1.SetSelection(self.paramsimi['coeff']) self.choice2.SetSelection(self.paramsimi['layout']) self.choice3.SetSelection(self.paramsimi['type_graph']) - if self.paramsimi['type'] != 2 : + if self.paramsimi['type_graph'] != 2 : self.film.Enable(False) self.slider_sphere.Enable(False) else : @@ -1226,6 +773,9 @@ class PrefSimi ( wx.Dialog ): self.stars = self.paramsimi['stars'] self.slider_sphere.SetValue(self.paramsimi['alpha']) self.film.SetValue(self.paramsimi['film']) + self.comcheck.SetValue(self.paramsimi['com']) + self.choix_com.SetSelection(self.paramsimi['communities']) + self.halo.SetValue(self.paramsimi['halo']) def OnCheck_s_size(self, evt): if self.check_s_size.GetValue() : @@ -1394,7 +944,11 @@ class PrepSimi : 'first' : False, 'keep_coord' : keep_coord, 'alpha' : self.dial.slider_sphere.GetValue(), - 'film' : self.dial.film.GetValue() + 'film' : self.dial.film.GetValue(), + 'svg' : self.dial.choix_format.GetSelection(), + 'com' :self.dial.comcheck.GetValue(), + 'communities' : self.dial.choix_com.GetSelection(), + 'halo' : self.dial.halo.GetValue(), } if 'cexfromchi' in self.parametres : param['cexfromchi'] = self.dial.checkit.GetValue() diff --git a/iramuteq.py b/iramuteq.py index fd4c1ab..ed574e4 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -53,13 +53,13 @@ from tabverges import Verges #from textafcuci import AfcUci #from textchdalc import AnalyseAlceste from analysetxt import Alceste -from textdist import PamTxt +from textdist import AnalysePam from textstat import Stat from textaslexico import Lexico from textsimi import SimiTxt, SimiFromCluster from textwordcloud import WordCloud from profile_segment import ProfileSegment -from textcheckcorpus import checkcorpus +#from textcheckcorpus import checkcorpus from openanalyse import OpenAnalyse from corpus import BuildFromAlceste, Builder from sheet import MySheet @@ -240,7 +240,7 @@ class IraFrame(wx.Frame): analyse_menu.Append(ID_Chi2, u"Chi2") #analyse_menu.Append(ID_Student, u"t de Student") menu_classif = wx.Menu() - menu_classif.Append(ID_CHDAlceste, u"Méthode Alceste") + menu_classif.Append(ID_CHDAlceste, u"Méthode GNEPA") menu_classif.Append(ID_CHDSIM, u"Par matrice des distances") analyse_menu.AppendMenu(-1, u"Classification", menu_classif) analyse_menu.Append(ID_AFCM, u"AFCM") @@ -249,12 +249,12 @@ class IraFrame(wx.Frame): analyse_menu.Append(ID_RCODE, u"Code R...") text_menu = wx.Menu() - text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus") + #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus") text_menu.Append(ID_TEXTSTAT, u"Statistiques textuelles") text_menu.Append(ID_ASLEX, u"Spécificités et AFC") #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire") menu_classiftxt = wx.Menu() - menu_classiftxt.Append(ID_TEXTALCESTE, u"Méthode Alceste") + menu_classiftxt.Append(ID_TEXTALCESTE, u"Méthode GNEPA") menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances") text_menu.AppendMenu(-1, u"Classification", menu_classiftxt) text_menu.Append(ID_SimiTxt, u'Analyse de similitude') @@ -371,7 +371,7 @@ class IraFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.OnCHDAlceste, id=ID_CHDAlceste) self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM) self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE) - self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS) + #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS) self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT) self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX) self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM) @@ -887,11 +887,11 @@ Voulez-vous fermer quand même ?""" except: BugReport(self) - def OnCheckcorpus(self, evt): - try : - checkcorpus(self) - except : - BugReport(self) +# def OnCheckcorpus(self, evt): +# try : +# checkcorpus(self) +# except : +# BugReport(self) def OnTextStat(self, event, corpus = None): print 'PAS DE BUG SUR TEXT STAT' @@ -961,23 +961,26 @@ Voulez-vous fermer quand même ?""" except: BugReport(self) - def OnPamSimple(self, event): + def OnPamSimple(self, event, corpus = None): try: - self.Text = PamTxt(self) + if corpus is None : + corpus = self.tree.getcorpus() + self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = progressbar(self,6)) if self.Text.val == wx.ID_OK: PlaySound(self) except: BugReport(self) def OnSimi(self,evt): - try : + #try : #print 'ATTENTION !!!! VERGES' + print 'PLUS DE BUG SUR SIMI' self.res = DoSimi(self, param = None) #self.res = Verges(self) if self.res.val == wx.ID_OK : PlaySound(self) - except : - BugReport(self) + #except : + # BugReport(self) ################################################################# def OnHelp(self, event): diff --git a/layout.py b/layout.py index 8cfcd96..8efccbf 100644 --- a/layout.py +++ b/layout.py @@ -23,11 +23,12 @@ from listlex import * from Liste import * from search_tools import SearchFrame from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro -from guifunct import SelectColumn, PrepSimi +from guifunct import SelectColumn, PrepSimi, PrefSimi from corpus import Corpus import datetime import sys import tempfile +from time import sleep import shutil import codecs import logging @@ -877,51 +878,6 @@ class CopusPanel(wx.Panel) : text.Wrap( -1 ) self.fgSizer5.Add( text, 0, wx.ALL, 5 ) -class GraphPanelSimi(wx.Panel): - def __init__(self, parent, dico, list_graph): - wx.Panel.__init__(self,parent) - self.afcnb = 1 - self.Dict = dico - self.dirout = os.path.dirname(self.Dict['ira']) - self.parent = self.GetParent()#parent - self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier")) - self.labels = [] - self.listimg = [] - self.tabsimi = self.parent.GetParent() - self.ira = self.tabsimi.GetParent() - self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL) - afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() - self.butafc = wx.BitmapButton(self, -1, afc_img) - export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() - self.butexport = wx.BitmapButton(self, -1, export_img) - - for i in range(0,len(list_graph)): - if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) and list_graph[i][0] != '' : - self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) - self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1])) - - self.__set_properties() - self.__do_layout() - - def __set_properties(self): - self.panel_1.EnableScrolling(True,True) - #self.panel_1.SetSize((1000,1000)) - self.panel_1.SetScrollRate(20, 20) - - def __do_layout(self): - self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL) - self.sizer_2 = wx.BoxSizer(wx.VERTICAL) - self.sizer_3 = wx.BoxSizer(wx.VERTICAL) - self.sizer_2.Add(self.butafc, 0, 0, 0) - self.sizer_2.Add(self.butexport, 0, 0, 0) - for i in range(0, len(self.listimg)): - self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.panel_1.SetSizer(self.sizer_3) - self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0) - self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0) - self.SetSizer(self.sizer_1) - class DefaultTextLayout : def __init__(self, ira, corpus, parametres) : self.pathout = PathOut(dirout = parametres['pathout']) @@ -999,26 +955,306 @@ class SimiLayout(DefaultTextLayout) : pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True) check_Rresult(self.ira, pid) if self.parametres['type_graph'] == 1: + if self.parametres['svg'] : + filename, ext = os.path.splitext(script.filename) + fileout = filename + '.svg' + else : + fileout = script.filename 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]) + graph_simi.append([os.path.basename(fileout), script.txtgraph]) else : - graph_simi = [[os.path.basename(script.filename), script.txtgraph]] + graph_simi = [[os.path.basename(fileout), script.txtgraph]] print_liste(self.pathout['liste_graph'], graph_simi) DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira']) if self.parametres['type_graph'] == 1: - self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + if self.parametres['svg'] : + self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + else : + self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.graphpan.sizer_3.Fit(self.graphpan.panel_1) self.graphpan.Layout() self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) def export(self, evt) : + nb = 1 + while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')): + nb +=1 + fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')) + txt = """ + library(igraph) + load("%s") + fileout <- "%s" + graph <- graph.simi$graph + V(graph)$x <- graph.simi$layout[,1] + V(graph)$y <- graph.simi$layout[,2] + V(graph)$weight <- graph.simi$label.cex + V(graph)$colors <- cols + E(graph)$weigth <- graph.simi$we.width + write.graph(graph, fileout, format = 'graphml') + """ % (self.pathout['RData.RData'], fileout) + filetmp = tempfile.mktemp() + with open(filetmp, 'w') as f : + f.write(txt) + exec_rcode(self.ira.RPath, filetmp) + mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK) + mss.CenterOnParent() + mss.ShowModal() + mss.Destroy() + +class DefaultMatLayout : + def __init__(self, parent, tableau, parametres) : + self.pathout = PathOut(dirout = parametres['pathout']) + self.ira = parent + self.parent = parent + self.tableau = tableau + self.parametres = parametres + self.dolayout() + + def dolayout(self) : pass - # def read_result(self) : - # #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db']) - # #self.corpus.make_et_table() - # self.result = {} - # with open(os.path.join(self.pathout,'glob.txt'), 'r') as f : - # self.result['glob'] = f.read() +class SimiMatLayout(DefaultMatLayout) : + def dolayout(self): + self.pathout.basefiles(simipath) + self.indices = indices_simi + if os.path.exists(self.pathout['liste_graph']) : + list_graph = read_list_file(self.pathout['liste_graph']) + else : + list_graph = [['','']] + notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT + self.tabsimi = aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition) + self.tabsimi.SetAGWWindowStyleFlag(notebook_flags) + self.tabsimi.SetArtProvider(aui.ChromeTabArt()) + self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph) + self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc) + #self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport) + self.tabsimi.AddPage(self.graphpan, 'Graph') + self.tabsimi.parametres = self.parametres + self.parent.nb.AddPage(self.tabsimi, 'Analyse de graph') + self.parent.ShowTab(True) + self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1) + + def redosimi(self,evt) : + with open(self.pathout['selected.csv'],'r') as f : + selected = f.read() + selected = [int(val) for val in selected.splitlines()] + #if self.actives is None : + # with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f : + # self.actives = f.read() + # self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()] + actives = [[val, self.tableau.actives[val][0]] for val in self.tableau.actives] + #self.tableau.make_listactives() + actives = dict([[i, val] for i, val in enumerate(actives)]) + #dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) + self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives) + self.dial.CenterOnParent() + self.val = self.dial.ShowModal() + if self.val == wx.ID_OK : + last = self.dial.listcol.GetFirstSelected() + lastl = [self.dial.listcol.GetFirstSelected()] + indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)] + while self.dial.listcol.GetNextSelected(last) != -1: + last = self.dial.listcol.GetNextSelected(last) + lastl.append(last) + indexes.append(self.dial.listcol.getColumnText(last,0)) + self.column = [self.tableau.listactives.index(val) for val in indexes] + self.column.sort() + with open(self.pathout['selected.csv'], 'w') as f : + f.write('\n'.join([`val` for val in self.column])) + self.make_param() + self.dial.Destroy() + self.script = PrintSimiScript(self) + self.script.make_script() + self.tmpfile = self.script.scriptout + dlg = progressbar(self, maxi = 2) + self.DoR(dlg) + dlg.Destroy() + if self.parametres['type_graph'] == 1: + if self.parametres['svg'] : + filename, ext = os.path.splitext(self.script.filename) + fileout = filename + '.svg' + else : + fileout = self.script.filename + if os.path.exists(self.pathout['liste_graph']): + graph_simi = read_list_file(self.pathout['liste_graph']) + graph_simi.append([os.path.basename(fileout), self.script.txtgraph]) + else : + graph_simi = [[os.path.basename(fileout), self.script.txtgraph]] + print_liste(self.pathout['liste_graph'], graph_simi) + DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira']) + if self.parametres['type_graph'] == 1: + if self.parametres['svg'] : + self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + else : + self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, self.script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.graphpan.sizer_3.Fit(self.graphpan.panel_1) + self.graphpan.Layout() + self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) + else : + self.dial.Destroy() + + + def make_param(self) : + if self.parametres['first'] : + keep_coord = False + else : + keep_coord = self.dial.check_coord.GetValue() + #self.select = self.dial.check_colch.GetValue() + + paramsimi = {'coeff' : self.dial.choice1.GetSelection(), + 'layout' : self.dial.choice2.GetSelection(), + 'type_graph' : self.dial.choice3.GetSelection(), + 'arbremax' : self.dial.check1.GetValue(), + 'coeff_tv' : self.dial.check_s_size.GetValue(), + 'coeff_tv_nb' : self.dial.spin_tv.GetValue(), + 'tvprop' : self.dial.check2.GetValue(), + 'tvmin' : self.dial.spin_tvmin.GetValue(), + 'tvmax' : self.dial.spin_tvmax.GetValue(), + 'coeff_te' : self.dial.check3.GetValue(), + 'coeff_temin' : self.dial.spin_temin.GetValue(), + 'coeff_temax' : self.dial.spin_temax.GetValue(), + 'label_e' : self.dial.check_elab.GetValue(), + 'label_v' : self.dial.check_vlab.GetValue(), + 'vcex' : self.dial.check_vcex.GetValue(), + 'vcexmin' : self.dial.spin_vcexmin.GetValue(), + 'vcexmax' : self.dial.spin_vcexmax.GetValue(), + 'cex' : self.dial.spin_cex.GetValue(), + 'seuil_ok' : self.dial.check_seuil.GetValue(), + 'seuil' : self.dial.spin_seuil.GetValue(), + 'cols' : self.dial.cols.GetColour(), + 'cola' : self.dial.cola.GetColour(), + 'width' : self.dial.spin_width.GetValue(), + 'height' : self.dial.spin_height.GetValue(), + 'first' : False, + 'keep_coord' : keep_coord, + 'alpha' : self.dial.slider_sphere.GetValue(), + 'film' : self.dial.film.GetValue(), + 'svg' : self.dial.choix_format.GetSelection(), + 'halo' : self.dial.halo.GetValue(), + 'com' : self.dial.comcheck.GetValue(), + 'communities' : self.dial.choix_com.GetSelection(), + } + if 'cexfromchi' in self.parametres : + paramsimi['cexfromchi'] = self.dial.checkit.GetValue() + if 'sfromchi' in self.parametres : + paramsimi['sfromchi'] = self.dial.checki.GetValue() + if 'vlabcolor' in self.parametres : + paramsimi['vlabcolor'] = self.parametres['vlabcolor'] + if 'check_bystar' in dir(self.dial) : + paramsimi['bystar'] = self.dial.check_bystar.GetValue() + paramsimi['stars'] = self.parametres['stars'] + self.parametres.update(paramsimi) + + def DoR(self, dlg): + if self.parametres['type_graph'] == 1 : + graph = False + wait = False + else : + graph = True + wait = True + pid = exec_rcode(self.parent.RPath, self.tmpfile, wait = wait, graph = graph) + if self.parametres['type_graph'] == 1 : + while pid.poll() == None : + dlg.Pulse(u'R ...') + sleep(0.2) + check_Rresult(self.parent, pid) + + #return paramsimi + +# if self.openfromprof : +# if 'cexfromchi' not in self.paramsimi: +# self.paramsimi['cexfromchi'] = False +# self.paramsimi['sfromchi'] = False +# self.dial = PrefSimi(self.parent, -1, self.paramsimi, self.types) +# self.dial.CenterOnParent() +# val = self.dial.ShowModal() +# if val == wx.ID_OK : +# self.paramsimi = self.make_param() +# self.dial.Destroy() +# if self.paramsimi.get('bystar',False) : +# variables = treat_var_mod(self.paramsimi['stars']) +# dial = OptLexi(self.parent) +# dial.listet = self.paramsimi['stars'] +# var = [v for v in variables] +# dial.variables = var +# for et in var : +# dial.list_box_1.Append(et) +# dial.CenterOnParent() +# val = dial.ShowModal() +# if val == wx.ID_OK : +# if dial.choice.GetSelection() == 1 : +# listet = [dial.listet[i] for i in dial.list_box_1.GetSelections()] +# else : +# listet = variables[var[dial.list_box_1.GetSelections()[0]]] +# self.tableau.etline = self.Source.corpus.make_etline(listet) +# +# dlg = wx.ProgressDialog("Traitements", +# "Veuillez patienter...", +# maximum=2, +# parent=self.parent, +# style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT) +# dlg.Center() +# self.PrintScript() +# self.DoR(dlg) +# dlg.Destroy() +# self.make_ira() +# if self.paramsimi['type'] == 1: +# self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) +# self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1,self.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) +# self.graphpan.sizer_3.Fit(self.graphpan.panel_1) +# self.graphpan.Layout() +# self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) +# else : +# self.dial.Destroy() + + +class GraphPanelSimi(wx.Panel): + def __init__(self,parent, dico, list_graph): + wx.Panel.__init__(self,parent) + self.afcnb = 1 + self.Dict = dico + self.dirout = os.path.dirname(self.Dict['ira']) + self.parent = self.GetParent()#parent + self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier")) + self.labels = [] + self.listimg = [] + self.tabsimi = self.parent.GetParent() + self.ira = self.tabsimi.GetParent() + self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL) + afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() + self.butafc = wx.BitmapButton(self, -1, afc_img) + export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() + self.butexport = wx.BitmapButton(self, -1, export_img) + for i in range(0,len(list_graph)): + if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) : + filename, ext = os.path.splitext(list_graph[i][0]) + if ext == '.svg' : + self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0]))) + else : + self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) + self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1])) + + self.__set_properties() + self.__do_layout() + + def __set_properties(self): + self.panel_1.EnableScrolling(True,True) + #self.panel_1.SetSize((1000,1000)) + self.panel_1.SetScrollRate(20, 20) + + def __do_layout(self): + self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL) + self.sizer_2 = wx.BoxSizer(wx.VERTICAL) + self.sizer_3 = wx.BoxSizer(wx.VERTICAL) + self.sizer_2.Add(self.butafc, 0, 0, 0) + self.sizer_2.Add(self.butexport, 0, 0, 0) + for i in range(0, len(self.listimg)): + self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.panel_1.SetSizer(self.sizer_3) + self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0) + self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0) + self.SetSizer(self.sizer_1) diff --git a/openanalyse.py b/openanalyse.py index d24025a..22cf584 100644 --- a/openanalyse.py +++ b/openanalyse.py @@ -4,13 +4,13 @@ #Copyright (c) 2008-2012, Pierre Ratinaud #Lisense: GNU/GPL -from chemins import ChdTxtPathOut, StatTxtPathOut, construct_simipath, PathOut -from layout import OpenCHDS, dolexlayout, StatLayout, WordCloudLayout, OpenCorpus, SimiLayout +from chemins import ChdTxtPathOut, StatTxtPathOut, PathOut +from layout import OpenCHDS, dolexlayout, StatLayout, WordCloudLayout, OpenCorpus, SimiLayout, SimiMatLayout from corpus import Corpus, copycorpus from tableau import Tableau import os import shelve -from tabsimi import DoSimi +#from tabsimi import DoSimi from functions import BugReport, DoConf from tableau import Tableau import logging @@ -131,6 +131,9 @@ class OpenAnalyse(): self.parent.ShowMenu(_("Text analysis")) WordCloudLayout(self.parent, corpus, self.conf) elif self.conf['type'] == 'gnepamatrix' : - self.parent.ShowMenu(_("Spreadsheet analysis")) + #self.parent.ShowMenu(_("Spreadsheet analysis")) OpenCHDS(self.parent, corpus, self.conf, Alceste = False) + elif self.conf['type'] == 'simimatrix' : + #self.parent.ShowMenu(_("Spreadsheet analysis")) + SimiMatLayout(self.parent, corpus, self.conf) diff --git a/tabchdalc.py b/tabchdalc.py index 03d7a66..4f79e4b 100644 --- a/tabchdalc.py +++ b/tabchdalc.py @@ -110,10 +110,7 @@ class DoQuestAlceste(AnalyseMatrix): #CreateIraFile(self.dictpathout, self.clnb, corpname = os.path.basename(self.parent.filename), section = 'questionnaire') afc_graph_list = [[os.path.basename(self.dictpathout['AFC2DL_OUT']), u'Variables actives - coordonnées - facteurs 1 / 2'], [os.path.basename(self.dictpathout['AFC2DSL_OUT']), u'variables illustratives - coordonnées - facteurs 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCoul']), u'Variables actives - Corrélation - facteur 1/2'], - [os.path.basename(self.dictpathout['AFC2DCoulSup']), u'Variables illustratives - Corrélation - facteur 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCoulCl']), u'Classes - Corrélations - facteurs 1 / 2'], ] + [os.path.basename(self.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2'],] chd_graph_list = [[os.path.basename(self.dictpathout['dendro1']), u'dendrogramme à partir de chd1']] chd_graph_list.append([os.path.basename(self.dictpathout['arbre1']), u'chd1']) print_liste(self.dictpathout['liste_graph_afc'], afc_graph_list) @@ -198,23 +195,14 @@ class DoQuestAlceste(AnalyseMatrix): PARCEX<-%s """ % "0.9" txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) + xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) """ % (self.dictpathout['AFC2DL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (self.dictpathout['AFC2DSL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='coord', xlab = xlab, ylab = ylab) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (self.dictpathout['AFC2DCL_OUT']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoul']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=debet, fin=fin, xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoulSup']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='crl', xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoulCl']) txt += """ save.image(file="%s") """ % self.dictpathout['RData'] diff --git a/tabchddist.py b/tabchddist.py index 6010eaa..18864a1 100644 --- a/tabchddist.py +++ b/tabchddist.py @@ -8,7 +8,7 @@ import os #from rchdng import RchdFunct from chemins import ffr, ConstructPathOut,ChdTxtPathOut #from layout import PrintRapport -from openanalyse import OpenAnalyse +#from openanalyse import OpenAnalyse from ConfigParser import ConfigParser from functions import CreateIraFile, print_liste, exec_rcode, check_Rresult from dialog import CHDDialog, PrefQuestAlc, ClusterNbDialog diff --git a/tabfrequence.py b/tabfrequence.py index 925a1df..4eb42ee 100644 --- a/tabfrequence.py +++ b/tabfrequence.py @@ -13,47 +13,8 @@ from chemins import ffr, FFF import tempfile from time import sleep from functions import exec_rcode, check_Rresult +from dialog import FreqDialog -class FreqDialog(wx.Dialog): - def __init__( - self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, - style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK - ): - pre = wx.PreDialog() - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) - pre.Create(parent, ID, title, pos, size, style) - self.PostCreate(pre) - self.parent = parent - sizer = wx.BoxSizer(wx.VERTICAL) - self.content = parent.content - self.header = parent.tableau.get_colnames() - LABELLIST = [] - for i in self.header: - forme = i - if len(forme) > 60 : - LABELLIST.append(i[0:60]) - else: - LABELLIST.append(i) - self.list_box_1 = wx.ListBox(self, -1, choices=LABELLIST, style=wx.LB_EXTENDED | wx.LB_HSCROLL) - sizer.Add(self.list_box_1, 0, 5) - - btnsizer = wx.BoxSizer(wx.HORIZONTAL) - - btn = wx.Button(self, wx.ID_CANCEL) - btn.SetHelpText("Annuler") - btnsizer.Add(btn) - - btn = wx.Button(self, wx.ID_OK) - btn.SetHelpText("Valider") - btn.SetDefault() - btnsizer.Add(btn) - - sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5) - self.SetSizer(sizer) - sizer.Fit(self) - self.SetTitle(u"Sélection") - - # end wxGlade class Frequences(): def __init__(self, parent): @@ -64,8 +25,8 @@ class Frequences(): self.DICTFILE = {} self.RPath = parent.PathPath.get('PATHS', 'rpath') self.parent=parent - dlg = FreqDialog(parent, -1, u"Fréquences", size=(350, 200), - style=wx.DEFAULT_DIALOG_STYLE) + self.tableau = parent.tableau + dlg = FreqDialog(parent, -1, self.tableau.get_colnames(), u"Fréquences", size=(350, 200)) dlg.CenterOnParent() val = dlg.ShowModal() if val == wx.ID_OK : diff --git a/tableau.py b/tableau.py index 06f58e8..1deaa8e 100644 --- a/tableau.py +++ b/tableau.py @@ -210,9 +210,18 @@ class Tableau() : dc = dict(zip(listcol, listcol)) selcol = [[val for i, val in enumerate(row) if i in dc] for row in self.linecontent] return selcol + + def getactlistfromselection(self, listact) : + selcol = self.select_col(listact) + self.actives = self.make_dico(selcol) + return [[val, self.actives[val][0]] for val in self.actives] + + def make_listactives(self) : + self.listactives = [val for val in self.actives if val != 'NA' and self.actives[val] >= self.parametre['mineff']] def write01(self, fileout, dico, linecontent) : - self.listactives = [val for val in dico if val != 'NA' and dico[val] >= self.parametre['mineff']] + if self.listactives is None : + self.listactives = [val for val in dico if val != 'NA' and dico[val] >= self.parametre['mineff']] out = [['0' for forme in self.listactives] for line in linecontent] for i, forme in enumerate(self.listactives) : for line in dico[forme][1] : diff --git a/tabsimi.py b/tabsimi.py index 91d2230..d2facad 100644 --- a/tabsimi.py +++ b/tabsimi.py @@ -4,16 +4,18 @@ #Copyright (c) 2009-2010 Pierre Ratinaud #Lisense: GNU/GPL -from chemins import ConstructPathOut, construct_simipath, ffr +from chemins import ConstructPathOut, simipath, ffr from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod -from dialog import SelectColDial, OptLexi +from dialog import SelectColDial, FreqDialog from guifunct import PrefSimi +from analysematrix import AnalyseMatrix +from PrintRScript import PrintSimiScript from listlex import * import wx -if wx.__version__ >= '2.11' : - import wx.lib.agw.aui as aui -else : - import aui +#if wx.__version__ >= '2.11' : +# import wx.lib.agw.aui as aui +#else : +# import aui import os import tempfile import datetime @@ -22,7 +24,7 @@ from time import sleep from uuid import uuid4 -class DoSimi(): +class DoSimi(AnalyseMatrix): def __init__(self, parent, param = None, isopen = False, fromprof = False, pathout = False, filename ='', gparent = False, wordgraph = False, listactives = False, actives = False, cmd = False, openfromprof=False): #------------------------------------------------------------------- self.fromprof = fromprof @@ -62,8 +64,12 @@ class DoSimi(): 'keep_coord' : False, 'alpha' : 10, 'film' : False, + 'svg' : 0, + 'halo' : 0, + 'com' : 0, + 'communities' : 0, } - self.types = indices_simi + self.indices = indices_simi if fromprof : self.parent = parent.parent self.Source = parent @@ -78,103 +84,122 @@ class DoSimi(): else : self.tableau = parent.tableau self.tableau.parametre['mineff'] = 0 - self.dial = PrefSimi(parent, -1, self.paramsimi, self.types) - self.dial.CenterOnParent() - self.val = self.dial.ShowModal() - if self.val == wx.ID_OK : - self.paramsimi = self.make_param() - self.dial.Destroy() - if self.paramsimi.get('bystar', False) : - variables = treat_var_mod(self.tableau.listet) - dial = OptLexi(self.parent) - dial.listet = self.tableau.listet - var = [v for v in variables] - dial.variables = var - for et in var : - dial.list_box_1.Append(et) - dial.CenterOnParent() - val = dial.ShowModal() - if val == wx.ID_OK : - if dial.choice.GetSelection() == 1 : - listet = [self.tableau.listet[i] for i in dial.list_box_1.GetSelections()] - else : - listet = variables[var[dial.list_box_1.GetSelections()[0]]] - dial.Destroy() - self.tableau.etline = self.Source.corpus.make_etline(listet) - - dlg = wx.ProgressDialog("Traitements", - "Veuillez patienter...", - maximum=4, - parent=self.parent, - style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME - ) - dlg.Center() - count = 1 - keepGoing = dlg.Update(count) - #------------------------------------------------------------------- - self.DictForme = {} - self.Min = 10 - self.Linecontent = [] - #----------------------------------------------------------- - count += 1 - if not fromprof : - self.pathout = ConstructPathOut(parent.tableau.parametre['filename'], 'Simi') - self.DictPathOut = construct_simipath(self.pathout) - self.parent.tableau.dictpathout = self.DictPathOut - dlg.Update(count, u"passage en O/1") - self.parent.tableau.make_01_from_selection(range(0,self.parent.tableau.colnb)) - #self.Linecontent = parent.table - #self.ListTo01Form() + dialcol = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Sélectionnez les colonnes", size=(600, 250)) + dialcol.CenterOnParent() + res = dialcol.ShowModal() + if res == wx.ID_OK : + self.tableau.selected_col = dialcol.list_box_1.GetSelections() + actives = self.tableau.getactlistfromselection(self.tableau.selected_col) + self.tableau.make_listactives() + actives = dict([[i, val] for i, val in enumerate(actives)]) + self.dial = PrefSimi(parent, -1, self.paramsimi, self.indices, wordlist = actives) + self.dial.CenterOnParent() + self.val = self.dial.ShowModal() + if self.val == wx.ID_OK : + last = self.dial.listcol.GetFirstSelected() + lastl = [self.dial.listcol.GetFirstSelected()] + indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)] + while self.dial.listcol.GetNextSelected(last) != -1: + last = self.dial.listcol.GetNextSelected(last) + lastl.append(last) + indexes.append(self.dial.listcol.getColumnText(last,0)) + self.column = [self.tableau.listactives.index(val) for val in indexes] + self.column.sort() + self.paramsimi = self.make_param() + self.parametres = self.paramsimi + self.parametres['type'] = 'simimatrix' + self.parametres['pathout'] = ConstructPathOut(self.tableau.parametre['filename'], 'SimiMatrix') + self.parametres['filename'] = self.tableau.parametres['filename'] + self.dial.Destroy() + dlg = wx.ProgressDialog("Traitements", + "Veuillez patienter...", + maximum=4, + parent=self.parent, + style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME + ) + dlg.Center() + AnalyseMatrix.__init__(self, parent, self.tableau, self.paramsimi, dlg = dlg) else : - self.pathout = pathout - self.DictPathOut = construct_simipath(self.pathout) - self.DictPathOut['mat01'] = fromprof - self.PrintScript() - count += 1 - dlg.Update(count, u"R...") - self.DoR(dlg) - self.make_ira() - count += 1 - dlg.Update(count, u"") - dlg.Destroy() - #self.dial.Destroy() - #self.dolayout() - from openanalyse import OpenAnalyse - if self.fromprof : - fromprof = True - else: - fromprof = False - OpenAnalyse(self.parent, self.DictPathOut['ira'], False, simifromprof=fromprof) - else: - self.dial.Destroy() - else : - self.tableau = gparent.tableau - if 'corpus' in dir(gparent) : - self.Source = gparent - self.tableau.parametre['mineff'] = 0 - self.DictPathOut = construct_simipath(os.path.abspath(os.path.dirname(filename))) - self.dolayout() - self.paramsimi['first'] = False - self.paramsimi['coeff'] = int(param.get('simi', 'indice')) - self.paramsimi['layout'] = int(param.get('simi', 'layout')) - self.paramsimi['seuil_ok'] = param.getboolean('simi', 'seuil_ok') - self.paramsimi['seuil'] = int(param.get('simi', 'seuil')) - if param.get('simi', 'wordgraph') == 'False' : - self.wordgraph = False + self.dial.Destroy() else : - self.wordgraph = param.get('simi', 'wordgraph') - if 'listet' in dir(self.tableau) : - self.paramsimi['stars'] = self.tableau.listet - self.paramsimi['bystar'] = False - self.paramsimi['cexfromchi'] = True - self.paramsimi['tvprop'] = False - self.paramsimi['sfromchi'] = False - self.paramsimi['coeff_te'] = True - self.paramsimi['coeff_tv'] = True - self.paramsimi['coeff_tv_nb'] = 0 - self.paramsimi['label_e'] = False - self.paramsimi['width'] = 1000 - self.paramsimi['height'] = 1000 + dialcol.Destroy() + + def doanalyse(self) : + + self.pathout.basefiles(simipath) + with open(self.pathout['selected.csv'], 'w') as f : + f.write('\n'.join([`val` for val in self.column])) + + count = 1 + keepGoing = self.dlg.Update(count) + #---------------------------------------------------------------- + self.DictForme = {} + self.Min = 10 + self.Linecontent = [] + #-------------------------------------------------------- + count += 1 + #if not self.fromprof : + #self.pathout = ConstructPathOut(self.tableau.parametre['filename'], 'Simi') + #self.DictPathOut = construct_simipath(self.pathout) + self.parent.tableau.dictpathout = self.pathout + self.dlg.Update(count, u"passage en O/1") + self.parent.tableau.make_01_from_selection(self.tableau.selected_col) + #self.Linecontent = parent.table + #self.ListTo01Form() + #else : + #self.pathout = pathout + #self.DictPathOut = construct_simipath(self.pathout) + self.DictPathOut = self.pathout + #self.DictPathOut['mat01'] = fromprof + self.script = PrintSimiScript(self) + self.script.make_script() + #self.PrintScript() + count += 1 + self.dlg.Update(count, u"R...") + #self.DoR(script.scriptout, dlg = self.dlg, message = 'R...') + self.tmpfile = self.script.scriptout + self.DoR(self.dlg) + self.addgraph() + self.tableau.save_tableau(self.pathout['db']) + #self.make_ira() + count += 1 + self.dlg.Update(count, u"") + self.dlg.Destroy() + #self.dial.Destroy() + #self.dolayout() + if self.fromprof : + fromprof = True + else: + fromprof = False + #OpenAnalyse(self.parent, self.DictPathOut['ira'], False, simifromprof=fromprof) +# else : +# self.tableau = gparent.tableau +# if 'corpus' in dir(gparent) : +# self.Source = gparent +# self.tableau.parametre['mineff'] = 0 +# self.DictPathOut = construct_simipath(os.path.abspath(os.path.dirname(filename))) +# self.dolayout() +# self.paramsimi['first'] = False +# self.paramsimi['coeff'] = int(param.get('simi', 'indice')) +# self.paramsimi['layout'] = int(param.get('simi', 'layout')) +# self.paramsimi['seuil_ok'] = param.getboolean('simi', 'seuil_ok') +# self.paramsimi['seuil'] = int(param.get('simi', 'seuil')) +# if param.get('simi', 'wordgraph') == 'False' : +# self.wordgraph = False +# else : +# self.wordgraph = param.get('simi', 'wordgraph') +# if 'listet' in dir(self.tableau) : +# self.paramsimi['stars'] = self.tableau.listet +# self.paramsimi['bystar'] = False +# self.paramsimi['cexfromchi'] = True +# self.paramsimi['tvprop'] = False +# self.paramsimi['sfromchi'] = False +# self.paramsimi['coeff_te'] = True +# self.paramsimi['coeff_tv'] = True +# self.paramsimi['coeff_tv_nb'] = 0 +# self.paramsimi['label_e'] = False +# self.paramsimi['width'] = 1000 +# self.paramsimi['height'] = 1000 def make_param(self) : @@ -182,7 +207,7 @@ class DoSimi(): keep_coord = False else : keep_coord = self.dial.check_coord.GetValue() - self.select = self.dial.check_colch.GetValue() + #self.select = self.dial.check_colch.GetValue() paramsimi = {'coeff' : self.dial.choice1.GetSelection(), 'layout' : self.dial.choice2.GetSelection(), @@ -211,7 +236,11 @@ class DoSimi(): 'first' : False, 'keep_coord' : keep_coord, 'alpha' : self.dial.slider_sphere.GetValue(), - 'film' : self.dial.film.GetValue() + 'film' : self.dial.film.GetValue(), + 'svg' : self.dial.choix_format.GetSelection(), + 'halo' : self.dial.halo.GetValue(), + 'com' : self.dial.comcheck.GetValue(), + 'communities' :self.dial.choix_com.GetSelection(), } if 'cexfromchi' in self.paramsimi : paramsimi['cexfromchi'] = self.dial.checkit.GetValue() @@ -224,403 +253,38 @@ class DoSimi(): paramsimi['stars'] = self.paramsimi['stars'] return paramsimi - def make_ira(self): - self.tableau.save_tableau(self.DictPathOut['db']) - conf = RawConfigParser() - conf.read(self.DictPathOut['ira']) - if not 'simi' in conf.sections() : - conf.add_section('simi') - date = datetime.datetime.now().ctime() - if self.fromprof : - conf.set('simi', 'corpus', self.Source.corpus.parametres['uuid']) - conf.set('simi', 'uuid', str(uuid4())) - conf.set('simi', 'date', str(date)) - conf.set('simi', 'indice', self.paramsimi['coeff']) - conf.set('simi','layout', self.paramsimi['layout']) - conf.set('simi', 'seuil_ok', self.paramsimi['seuil_ok']) - conf.set('simi', 'seuil', str(self.paramsimi['seuil'])) - conf.set('simi', 'wordgraph', self.wordgraph) - fileout = open(self.DictPathOut['ira'], 'w') - conf.write(fileout) - fileout.close() - - def PrintScript(self): - if self.select : - if self.listactives : - lactives = self.listactives - else : - lactives = self.tableau.listactives - if self.actives : - acts = self.actives - else : - acts = self.tableau.actives - dictcol = [[i, [active, acts[active][0]]] for i, active in enumerate(lactives)] - dictcol = dict(dictcol) - dlg = SelectColDial(self.parent) - listcol = ListForSpec(dlg, self, dictcol, ['forme', 'eff']) - dlg.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 ) - dlg.m_sdbSizer2.AddButton( dlg.m_sdbSizer2OK ) - dlg.m_sdbSizer2.Realize() - dlg.bSizer2.Add( dlg.m_sdbSizer2, 0, wx.EXPAND, 5 ) - dlg.Layout() - if not 'selected_col' in dir(self.tableau) : - for row in xrange(listcol.list.GetItemCount()): - listcol.list.Select(row) - else : - for row in self.tableau.selected_col : - listcol.list.Select(row) - dlg.CenterOnParent() - val = dlg.ShowModal() - datas = [listcol.getColumnText(listcol.list.GetFirstSelected(),0)] - last = listcol.list.GetFirstSelected() - lastl = [listcol.list.GetFirstSelected()] - while listcol.list.GetNextSelected(last) != -1: - last = listcol.list.GetNextSelected(last) - lastl.append(last) - datas.append(listcol.getColumnText(last,0)) - dlg.Destroy() - datas = [lactives.index(val) for val in datas] - self.tableau.selected_col = lastl - self.tableau.datas = datas - datas = str(tuple(datas)) - elif not self.select and 'selected_col' in dir(self.tableau) : - datas = str(tuple(self.tableau.datas)) - elif self.wordgraph : - col = self.tableau.listactives.index(self.wordgraph) - - tmpchi = False - if (self.fromprof or self.openfromprof) and (self.paramsimi.get('cexfromchi', False) or self.paramsimi.get('sfromchi', False)): - if 'lchi' in dir(self.tableau) : - tmpchi = tempfile.mktemp(dir=self.parent.TEMPDIR) - with open(tmpchi, 'w') as f: - f.write('\n'.join([str(val) for val in self.tableau.lchi])) - - active_file = tempfile.mktemp(dir=self.parent.TEMPDIR) - if self.listactives : - lactives = self.listactives - else : - lactives = self.tableau.listactives - self.tableau.listactives = lactives - with open(active_file, 'w') as f: - f.write('\n'.join(lactives)) - - txt = '#script genere par Iramuteq' - txt += """ - library('igraph') - library('proxy') - library('Matrix') - """ - if os.path.exists(self.DictPathOut['RData']) : - txt += """ - load("%s") - """ % self.DictPathOut['RData'] - if not self.paramsimi['keep_coord'] : - #FIXME : beurk!! - i = 0 - market = False - with open(self.DictPathOut['mat01'],'r') as f : - for line in f.readlines() : - if 'MatrixMarket' in line : - market = True - break - elif i >= 1 : - market = False - break - i += 1 - print market - #if (self.fromprof or 'fromtxt' in self.tableau.parametre or self.openfromprof) and not self.actives : - if market : - txt += """ - dm <-readMM("%s") - """ % self.DictPathOut['mat01'] - else : - txt += """ - dm <- read.csv2("%s") - """ % self.DictPathOut['mat01'] - txt += """ - dm <- as.matrix(dm) - #dml <- apply(dm, 2, as.logical) - """ - if not self.paramsimi['keep_coord'] : - txt += """ - cn <- read.csv("%s", sep='\t', quote='"', headers = FALSE) - colnames(dm) <- cn[,1] - #colnames(dml) <- cn[,1] - """ % ffr(active_file) - if 'selected_col' in dir(self.tableau) and not self.paramsimi['keep_coord']: - txt += """ - #dml <- dml[, c%s+1] - dm <- dm[, c%s+1] - """ % (datas, datas) - txt += """ - source("%s") - source("%s") - """ % (self.parent.RscriptsPath['simi'],self.parent.RscriptsPath['Rgraph']) - - self.txtgraph = '' - self.txtgraph += self.types[self.paramsimi['coeff']] - if not self.paramsimi['keep_coord'] : - if self.paramsimi['coeff'] == 0 : - method = 'cooc' - txt += """ - method <- 'cooc' - mat <- make.a(dm) - """ - elif self.paramsimi['coeff'] == 1 : - method = 'prcooc' - txt += """ - method <- 'Russel' - mat <- simil(dm, method = 'Russel', diag = TRUE, upper = TRUE, by_rows = FALSE) - """ - elif self.types[self.paramsimi['coeff']] == 'binomial' : - method = 'binomial' - txt += """ - method <- 'binomial' - mat <- binom.sim(dm) - """ - else : - method = self.types[self.paramsimi['coeff']] - txt += """ - method <-"%s" - mat <- simil(dm, method = method, diag = TRUE, upper = TRUE, by_rows = FALSE) - """ % self.types[self.paramsimi['coeff']] - txt += """ - mat <- as.matrix(stats::as.dist(mat,diag=TRUE,upper=TRUE)) - mat[is.na(mat)] <- 0 - mat[is.infinite(mat)] <- 0 - """ - if self.types[self.paramsimi['coeff']] not in ['cooccurrence', 'Chi-squared', 'Mozley', 'Stiles'] : - txt += """ - mat <- mat * 100 - """ - if self.wordgraph : - txt += """ - mat <- graph.word(mat, %i) - """ % (col + 1) - txt += """ - eff <- colSums(dm) - x <- list(mat = mat, eff = eff) - """ - else : - method = '' - if self.paramsimi['layout'] == 0 : layout = 'random' - if self.paramsimi['layout'] == 1 : layout = 'circle' - if self.paramsimi['layout'] == 2 : layout = 'frutch' - if self.paramsimi['layout'] == 3 : layout = 'kawa' - if self.paramsimi['layout'] == 4 : layout = 'graphopt' - - self.filename='' - if self.paramsimi['type_graph'] == 0 : type = 'tkplot' - if self.paramsimi['type_graph'] == 1 : - graphnb = 1 - type = 'nplot' - dirout = os.path.dirname(self.DictPathOut['mat01']) - while os.path.exists(os.path.join(dirout,'graph_simi_'+str(graphnb)+'.png')): - graphnb +=1 - self.filename = ffr(os.path.join(dirout,'graph_simi_'+str(graphnb)+'.png')) - if self.paramsimi['type_graph'] == 2 : type = 'rgl' - - if self.paramsimi['arbremax'] : - arbremax = 'TRUE' - self.txtgraph += ' - arbre maximum' - else : arbremax = 'FALSE' - - if self.paramsimi['coeff_tv'] : - coeff_tv = self.paramsimi['coeff_tv_nb'] - tvminmax = 'c(NULL,NULL)' - elif not self.paramsimi['coeff_tv'] or self.paramsimi.get('sformchi', False) : - coeff_tv = 'NULL' - tvminmax = 'c(%i, %i)' %(self.paramsimi['tvmin'], self.paramsimi['tvmax']) - txt += """ - minmaxeff <- %s - """ % tvminmax - - if self.paramsimi['coeff_te'] : coeff_te = 'c(%i,%i)' % (self.paramsimi['coeff_temin'], self.paramsimi['coeff_temax']) - else : coeff_te = 'NULL' - - if self.paramsimi['vcex'] or self.paramsimi.get('cexfromchi', False) : - vcexminmax = 'c(%i/10,%i/10)' % (self.paramsimi['vcexmin'],self.paramsimi['vcexmax']) - else : - vcexminmax = 'c(NULL,NULL)' - - txt += """ - vcexminmax <- %s - """ % vcexminmax - - txt += """ - cex = %i/10 - """ % self.paramsimi['cex'] - - if not self.paramsimi['label_v'] : label_v = 'FALSE' - else : label_v = 'TRUE' - - if not self.paramsimi['label_e'] : label_e = 'FALSE' - else : label_e = 'TRUE' - - if self.paramsimi['seuil_ok'] : seuil = str(self.paramsimi['seuil']) - else : seuil = 'NULL' - - if self.paramsimi['film'] : - txt += """ - film <- "%s" - """ % self.DictPathOut['film'] - else : - txt += """ - film <- NULL - """ - - txt += """ - seuil <- %s - """ % seuil - - txt += """ - label.v <- %s - label.e <- %s - """ % (label_v, label_e) - - cols = str(self.paramsimi['cols']).replace(')',', max=255)') - cola = str(self.paramsimi['cola']).replace(')',',max=255)') - - txt += """ - cols <- rgb%s - cola <- rgb%s - """ % (cols, cola) - - txt += """ - width <- %i - height <- %i - """ % (self.paramsimi['width'], self.paramsimi['height']) - - if self.paramsimi['keep_coord'] : - txt += """ - coords <- try(coords, TRUE) - if (!is.matrix(coords)) { - coords<-NULL - } - """ - else : - txt += """ - coords <- NULL - """ - txt += """ - alpha <- %i/100 - """ % self.paramsimi['alpha'] - - if self.paramsimi.get('bystar',False) : - txt += """ - et <- list() - """ - for i,et in enumerate(self.tableau.etline) : - txt+= """ - et[[%i]] <- c(%s) - """ % (i+1, ','.join(et[1:])) - txt+= """ - unetoile <- c('%s') - """ % ("','".join([val[0] for val in self.tableau.etline])) - txt += """ - fsum <- NULL - rs <- rowSums(dm) - for (i in 1:length(unetoile)) { - print(unetoile[i]) - tosum <- et[[i]] - if (length(tosum) > 1) { - fsum <- cbind(fsum, colSums(dm[tosum,])) - } else { - fsum <- cbind(fsum, dm[tosum,]) - } - } - source("%s") - lex <- AsLexico2(fsum, chip=TRUE) - dcol <- apply(lex[[4]],1,which.max) - toblack <- apply(lex[[4]],1,max) - gcol <- rainbow(length(unetoile)) - #gcol[2] <- 'orange' - vertex.label.color <- gcol[dcol] - vertex.label.color[which(toblack <= 3.84)] <- 'black' - leg <- list(unetoile=unetoile, gcol=gcol) - cols <- vertex.label.color - chivertex.size <- norm.vec(toblack, vcexminmax[1], vcexminmax[2]) - - """ % (self.parent.RscriptsPath['chdfunct']) - else : - txt += """ - vertex.label.color <- 'black' - chivertex.size <- 1 - leg<-NULL - """ - #if not self.paramsimi['keep_coord'] : - txt += """ - graph.simi <- do.simi(x, method='%s', seuil = seuil, p.type = '%s', layout.type = '%s', max.tree = %s, coeff.vertex=%s, coeff.edge = %s, minmaxeff = minmaxeff, vcexminmax = vcexminmax, cex = cex, coords = coords) - """ % (method, type, layout, arbremax, coeff_tv, coeff_te) - #txt += """ - if self.paramsimi.get('bystar',False) : - if self.paramsimi.get('cexfromchi', False) : - txt+=""" - label.cex<-chivertex.size - """ - else : - txt+=""" - label.cex <- NULL - """ - if self.paramsimi.get('sfromchi', False) : - txt += """ - vertex.size <- norm.vec(toblack, minmaxeff[1], minmaxeff[2]) - """ +# def make_ira(self): +# self.tableau.save_tableau(self.DictPathOut['db']) +# conf = RawConfigParser() +# conf.read(self.DictPathOut['ira']) +# if not 'simi' in conf.sections() : +# conf.add_section('simi') +# date = datetime.datetime.now().ctime() +# if self.fromprof : +# conf.set('simi', 'corpus', self.Source.corpus.parametres['uuid']) +# conf.set('simi', 'uuid', str(uuid4())) +# conf.set('simi', 'date', str(date)) +# conf.set('simi', 'indice', self.paramsimi['coeff']) +# conf.set('simi','layout', self.paramsimi['layout']) +# conf.set('simi', 'seuil_ok', self.paramsimi['seuil_ok']) +# conf.set('simi', 'seuil', str(self.paramsimi['seuil'])) +# conf.set('simi', 'wordgraph', self.wordgraph) +# fileout = open(self.DictPathOut['ira'], 'w') +# conf.write(fileout) +# fileout.close() +# + def addgraph(self) : + if self.parametres['type_graph'] == 1: + if self.parametres['svg'] : + filename, ext = os.path.splitext(self.script.filename) + fileout = filename + '.svg' else : - txt += """ - vertex.size <- NULL - """ - else : - if tmpchi : - txt += """ - lchi <- read.table("%s") - lchi <- lchi[,1] - """ % ffr(tmpchi) - if 'selected_col' in dir(self.tableau) : - txt += """ - lchi <- lchi[c%s+1] - """ % datas - if tmpchi and self.paramsimi.get('cexfromchi', False) : - txt += """ - label.cex <- norm.vec(lchi, vcexminmax[1], vcexminmax[2]) - """ - else : - txt += """ - if (is.null(vcexminmax[1])) { - label.cex <- NULL - } else { - label.cex <- graph.simi$label.cex - } - """ - if tmpchi and self.paramsimi.get('sfromchi', False) : - txt += """ - vertex.size <- norm.vec(lchi, minmaxeff[1], minmaxeff[2]) - """ - else : - txt += """ - if (is.null(minmaxeff[1])) { - vertex.size <- NULL - } else { - vertex.size <- graph.simi$eff - } - """ - txt += """ vertex.size <- NULL """ - txt += """ - coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = cols, 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) - save.image(file="%s") - """ % (type, self.filename, self.DictPathOut['RData']) - - self.tmpfile = tempfile.mktemp(dir=self.parent.TEMPDIR) - tmpscript = open(self.tmpfile, 'w') - tmpscript.write(txt) - tmpscript.close() - - if type == 'nplot': + fileout = self.script.filename if os.path.exists(self.DictPathOut['liste_graph']): graph_simi = read_list_file(self.DictPathOut['liste_graph']) - graph_simi.append([os.path.basename(self.filename), self.txtgraph]) + graph_simi.append([os.path.basename(fileout), self.script.txtgraph]) else : - graph_simi = [[os.path.basename(self.filename), self.txtgraph]] + graph_simi = [[os.path.basename(fileout), self.script.txtgraph]] print_liste(self.DictPathOut['liste_graph'], graph_simi) def DoR(self, dlg): @@ -640,141 +304,4 @@ class DoSimi(): sleep(0.2) check_Rresult(self.parent, pid) - def dolayout(self): - if os.path.exists(self.DictPathOut['liste_graph']) : - list_graph = read_list_file(self.DictPathOut['liste_graph']) - else : - list_graph = [['','']] - notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT - self.tabsimi = aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition) - self.tabsimi.SetAGWWindowStyleFlag(notebook_flags) - self.tabsimi.SetArtProvider(aui.ChromeTabArt()) - if 'corpus' in dir(self.Source) : - self.tabsimi.corpus = self.Source.corpus - self.graphpan = GraphPanelSimi(self.tabsimi, self.DictPathOut, list_graph) - self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc) - self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport) - self.tabsimi.AddPage(self.graphpan, 'Graph') - self.parent.nb.AddPage(self.tabsimi, 'Analyse de graph') - self.parent.ShowTab(True) - self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1) - - def export(self, evt) : - fileout = os.path.join(os.path.dirname(self.DictPathOut['ira']), "graphout") - format_graph = 'gml' - i=1 - while os.path.exists(fileout + '_%i.' % i + format_graph) : - i += 1 - fileout_graph = fileout + '_%i.' % i + format_graph - fileout_table = fileout + '_table_%i.csv' % i - Rtxt = """ - library(igraph) - load("%s") - fileout <- "%s" - fileout.table <- "%s" - format <- "%s" - id <- (1:length(graph.simi$mat.eff)) - 1 - id <- paste(id, '.0', sep='') - table.out <- cbind(Id=id, Label=id, Name=graph.simi$v.label, labelcex=graph.simi$label.cex, eff=graph.simi$mat.eff) - write.graph(graph.simi$graph, fileout, format=format) - write.csv2(table.out, file = fileout.table, row.names=FALSE) - """ % (self.DictPathOut['RData'], ffr(fileout_graph), ffr(fileout_table), format_graph) - tmpfile = tempfile.mktemp(dir=self.parent.TEMPDIR) - with open(tmpfile, 'w') as f : - f.write(Rtxt) - res = exec_rcode(self.RPath, tmpfile, wait = False) - check_Rresult(self.parent,res) - print 'export', Rtxt - - def redosimi(self,evt) : - if self.openfromprof : - if 'cexfromchi' not in self.paramsimi: - self.paramsimi['cexfromchi'] = False - self.paramsimi['sfromchi'] = False - self.dial = PrefSimi(self.parent, -1, self.paramsimi, self.types) - self.dial.CenterOnParent() - val = self.dial.ShowModal() - if val == wx.ID_OK : - self.paramsimi = self.make_param() - self.dial.Destroy() - if self.paramsimi.get('bystar',False) : - variables = treat_var_mod(self.paramsimi['stars']) - dial = OptLexi(self.parent) - dial.listet = self.paramsimi['stars'] - var = [v for v in variables] - dial.variables = var - for et in var : - dial.list_box_1.Append(et) - dial.CenterOnParent() - val = dial.ShowModal() - if val == wx.ID_OK : - if dial.choice.GetSelection() == 1 : - listet = [dial.listet[i] for i in dial.list_box_1.GetSelections()] - else : - listet = variables[var[dial.list_box_1.GetSelections()[0]]] - self.tableau.etline = self.Source.corpus.make_etline(listet) - - dlg = wx.ProgressDialog("Traitements", - "Veuillez patienter...", - maximum=2, - parent=self.parent, - style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT) - dlg.Center() - self.PrintScript() - self.DoR(dlg) - dlg.Destroy() - self.make_ira() - if self.paramsimi['type'] == 1: - self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1,self.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.graphpan.sizer_3.Fit(self.graphpan.panel_1) - self.graphpan.Layout() - self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) - else : - self.dial.Destroy() - - -class GraphPanelSimi(wx.Panel): - def __init__(self,parent, dico, list_graph): - wx.Panel.__init__(self,parent) - self.afcnb = 1 - self.Dict = dico - self.dirout = os.path.dirname(self.Dict['ira']) - self.parent = self.GetParent()#parent - self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier")) - self.labels = [] - self.listimg = [] - self.tabsimi = self.parent.GetParent() - self.ira = self.tabsimi.GetParent() - self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL) - afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() - self.butafc = wx.BitmapButton(self, -1, afc_img) - export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() - self.butexport = wx.BitmapButton(self, -1, export_img) - - for i in range(0,len(list_graph)): - if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) : - self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) - self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1])) - - self.__set_properties() - self.__do_layout() - - def __set_properties(self): - self.panel_1.EnableScrolling(True,True) - #self.panel_1.SetSize((1000,1000)) - self.panel_1.SetScrollRate(20, 20) - def __do_layout(self): - self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL) - self.sizer_2 = wx.BoxSizer(wx.VERTICAL) - self.sizer_3 = wx.BoxSizer(wx.VERTICAL) - self.sizer_2.Add(self.butafc, 0, 0, 0) - self.sizer_2.Add(self.butexport, 0, 0, 0) - for i in range(0, len(self.listimg)): - self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.panel_1.SetSizer(self.sizer_3) - self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0) - self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0) - self.SetSizer(self.sizer_1) diff --git a/textaslexico.py b/textaslexico.py index 5ff4c37..de0f181 100644 --- a/textaslexico.py +++ b/textaslexico.py @@ -32,88 +32,6 @@ class Lexico(AnalyseText) : self.dlg.Destroy() except : pass -# def __init__(self, parent, cmd = False): -# self.parent = parent -# self.cmd = False -# self.ConfigPath = parent.ConfigPath -# self.DictPath = parent.DictPath -# self.KeyConf = RawConfigParser() -# self.KeyConf.read(self.ConfigPath['key']) -# -# page = getPage(self.parent) -# if page is not None : -# self.corpus = getCorpus(page) -# if self.corpus is not None : -# pathout = ConstructPathOut(self.corpus.parametre['openpath'], 'lexico') -# self.dictpathout = StatTxtPathOut(pathout) -# self.val = wx.ID_OK -# #print self.corpus.lems -# self.make_lexico() -# -# else : -# self.corpus = Corpus(parent) -# self.corpus.content = self.parent.content -# self.corpus.parametre['encodage'] = parent.corpus_encodage -# self.corpus.parametre['lang'] = parent.corpus_lang -# self.corpus.parametre['filename'] = parent.filename -# dial = StatDialog(self, self.parent) -# dial.check_uce.SetValue(True) -# dial.check_uce.Enable(False) -# dial.OnCheckUce(wx.EVT_MENU) -# self.val = dial.ShowModal() -## dial = LexDialog(self.parent) -## dial.CenterOnParent() -## res = dial.ShowModal() -# if self.val == wx.ID_OK : -# #if dial.m_radioBox2.GetSelection() == 0 : self.corpus.parametre['lem'] = True -# if dial.radio_lem.GetSelection() == 0 : self.corpus.parametre['lem'] = True -# else : self.corpus.parametre['lem'] = False -# #if dial.m_radioBox21.GetSelection() == 0 : self.corpus.parametre['expressions'] = True -# if dial.exp.GetSelection() == 0 : self.corpus.parametre['expressions'] = True -# else : self.corpus.parametre['expressions'] = False -# self.make_uce = dial.check_uce.GetValue() -# self.corpus.parametre['nbforme_uce'] = dial.spin_ctrl_4.GetValue() -# self.corpus.parametre['max_actives'] = dial.spin_max_actives.GetValue() -# self.corpus.parametre['eff_min_uce'] = self.corpus.parametre['nbforme_uce'] -# dial.Destroy() -# pathout = ConstructPathOut(self.corpus.parametre['filename'], 'lexico') -# self.dictpathout = StatTxtPathOut(pathout) -# self.make_corpus() -# #print self.corpus.ucis -# self.make_lexico() -# -# def make_corpus(self) : -# print 'make corpus' -# if not self.cmd : -# dlg = progressbar(self, maxi = 6) -# self.corpus.supplementaires = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "2"] -# self.corpus.typeactive = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "1"] -# ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = dlg, cmd = self.cmd) -# del ucis_txt -# -# if not self.cmd : -# dlg.Update(5, '%i ucis - Construction des uces' % len(ucis_paras_txt)) -# self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = self.make_uce) -# del ucis_paras_txt -# -# if self.corpus.para_coords != [[] for val in self.corpus.para_coords] : -# self.corpus.parametre['para'] = True -# else : -# self.corpus.parametre['para'] = False -# self.corpus.make_etoiles(self.corpus.para_coords) -# -# print 'len(ucis_paras_uces)', len(self.corpus.ucis_paras_uces) -# -# if not self.cmd : -# dlg.Update(6, u'Dictionnaires') -# uces, orderuces = self.corpus.make_forms_and_uces() -# self.corpus.make_lems(self.parent.lexique) -## if not self.corpus.parametre['lem'] : -## formes = self.corpus.formes -## else : -## formes = self.corpus.make_lem_eff() -# if not self.cmd : -# dlg.Destroy() def DoR(self): nbligne = 5 @@ -209,10 +127,6 @@ class Lexico(AnalyseText) : tmpscript.write(txt) tmpscript.close() self.doR(tmpfile, dlg = self.dlg, message = 'R...') - #pid = exec_rcode(self.parent.RPath, tmpfile, wait = False) - #while pid.poll() == None : - # sleep(0.2) - #check_Rresult(self.parent, pid) def preferences(self) : listet = self.corpus.make_etoiles() @@ -238,10 +152,6 @@ class Lexico(AnalyseText) : else : self.parametres['indice'] = 'chi2' self.parametres['clnb'] = len(ListEt) - #if dial.checklem.GetValue() : - # self.parametres['lem'] = 1 - #else : - # self.parametres['lem'] = 0 dial.Destroy() return self.parametres else : @@ -249,33 +159,6 @@ class Lexico(AnalyseText) : return None def make_lexico(self) : -# listet = self.corpus.make_etoiles() -# listet.sort() -# variables = treat_var_mod(listet) -# var = [v for v in variables] -# if self.dlg : -# dial = OptLexi(self.parent) -# dial.listet = listet -# dial.variables = var -# for et in var : -# dial.list_box_1.Append(et) -# dial.CenterOnParent() -# val = dial.ShowModal() -# if val == wx.ID_OK : -# if dial.choice.GetSelection() == 1 : -# ListEt = [listet[i] for i in dial.list_box_1.GetSelections()] -# else : -# ListEt = variables[var[dial.list_box_1.GetSelections()[0]]] -# mineff = dial.spin.GetValue() -# if dial.choice_indice.GetSelection() == 0 : -# indice = 'hypergeo' -# else : -# indice = 'chi2' -# self.parametres = {'indice' : indice} -# dial.Destroy() -# else : -# dial.Destroy() -# else : mineff = self.parametres['mineff'] #dlg = progressbar(self, maxi = 3) tabout = self.corpus.make_lexitable(mineff, self.listet) @@ -306,8 +189,4 @@ class Lexico(AnalyseText) : [os.path.basename(self.dictpathout['afct_col']), u'colonnes']] print_liste(self.dictpathout['liste_graph_afcf'],afcf_graph_list) print_liste(self.dictpathout['liste_graph_afct'],afct_graph_list) - #CreateIraFile(self.dictpathout, 0, corpname = os.path.basename(self.corpus.parametre['filename']), section = 'lexico') DoConf().makeoptions(['spec'],[self.parametres], self.dictpathout['ira']) - #OpenAnalyse(self.parent, self.dictpathout['ira']) - #dolayout(self) - #dlg.Destroy() diff --git a/textdist.py b/textdist.py index c7fc133..07818e2 100644 --- a/textdist.py +++ b/textdist.py @@ -7,6 +7,7 @@ from chemins import ConstructPathOut, ConstructAfcUciPath, ChdTxtPathOut from corpus import Corpus from OptionAlceste import OptionPam +from analysetxt import AnalyseText import wx import os from ConfigParser import * @@ -18,38 +19,49 @@ from openanalyse import OpenAnalyse from time import time, sleep -class AnalysePam: - def __init__(self, parent, corpus, cmd = False): - t1 = time() - self.parent = parent - self.corpus = corpus - self.cmd = cmd +class AnalysePam(AnalyseText) : +# def __init__(self, parent, corpus, cmd = False): + def doanalyse(self) : + self.parametres['type'] = 'pamtxt' + self.pathout.basefiles(ChdTxtPathOut) + self.actives, lim = self.corpus.make_actives_nb(self.parametres['max_actives'], 1) + self.parametres['eff_min_forme'] = lim + self.parametres['nbactives'] = len(self.actives) + if self.parametres['classif_mode'] == 0 : + self.corpus.make_and_write_sparse_matrix_from_uces(self.actives, self.pathout['TableUc1'], self.pathout['listeuce1']) + elif self.parametres['classif_mode'] == 1 : + self.corpus.make_and_write_sparse_matrix_from_uci(self.actives, self.pathout['TableUc1'], self.pathout['listeuce1']) + RPamTxt(self.corpus, self.parent.RscriptsPath) + #t1 = time() + #self.parent = parent + #self.corpus = corpus + #self.cmd = cmd if not self.cmd : self.dlg = progressbar(self, 9) - else : - self.dlg = None - ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = self.dlg, cmd = self.cmd) - self.corpus.make_len_uce(self.corpus.get_tot_occ_from_ucis_txt(ucis_txt)) - del ucis_txt - if not self.cmd : - self.dlg.Update(5, '%i ucis - Construction des uces' % len(self.corpus.ucis)) - if self.corpus.parametre['type'] == 0 : - self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = True) - else : - self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = False) - del ucis_paras_txt + #else : + # self.dlg = None + #ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = self.dlg, cmd = self.cmd) + #self.corpus.make_len_uce(self.corpus.get_tot_occ_from_ucis_txt(ucis_txt)) + #del ucis_txt + #if not self.cmd : + # self.dlg.Update(5, '%i ucis - Construction des uces' % len(self.corpus.ucis)) + #if self.corpus.parametre['type'] == 0 : + # self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = True) + #else : + # self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = False) + #del ucis_paras_txt - if not self.cmd : - self.dlg.Update(6, u'Dictionnaires') - uces, orderuces = self.corpus.make_forms_and_uces() - self.corpus.ucenb = len(uces) - self.corpus.make_lems(self.parent.lexique) - self.corpus.min_eff_formes() - self.corpus.make_var_actives() - self.corpus.make_var_supp() + #if not self.cmd : + # self.dlg.Update(6, u'Dictionnaires') + #uces, orderuces = self.corpus.make_forms_and_uces() + #self.corpus.ucenb = len(uces) + #self.corpus.make_lems(self.parent.lexique) + #self.corpus.min_eff_formes() + #self.corpus.make_var_actives() + #self.corpus.make_var_supp() - if not self.cmd : - self.dlg.Update(7, u'Creation des tableaux') + #if not self.cmd : + # self.dlg.Update(7, u'Creation des tableaux') if self.corpus.parametre['type'] == 0: tabuc1 = self.corpus.make_table_with_uce(orderuces) uc1 = None @@ -63,58 +75,61 @@ class AnalysePam: self.corpus.write_tab(tabuc1,self.corpus.dictpathout['TableUc1']) self.corpus.lenuc1 = len(tabuc1) del tabuc1, uc1 - RPamTxt(self.corpus, self.parent.RscriptsPath) - pid = exec_rcode(self.parent.RPath,self.corpus.dictpathout['Rchdtxt'], wait = False) - while pid.poll() == None : - if not self.cmd : - self.dlg.Pulse(u'CHD...') - sleep(0.2) - else : - pass - check_Rresult(self.parent, pid) - ucecl = self.corpus.read_uce_from_R(self.corpus.dictpathout['uce']) - ucecl0 = [cl for uce,cl in ucecl if cl != 0] - clnb = len(list(set(ucecl0))) - classes = [cl for uce, cl in ucecl] - uces1 = [val for val, i in uces1] - self.corpus.make_lc(uces1, classes, clnb) - self.corpus.build_profile(clnb, classes, self.corpus.actives, self.corpus.dictpathout['Contout']) + RPamTxt(self, self.parent.RscriptsPath) + self.DoR(self.pathout['Rchdtxt'], dlg = self.dlg, message = 'R...') + #pid = exec_rcode(self.parent.RPath,self.pathout['Rchdtxt'], wait = False) + #while pid.poll() == None : + # if not self.cmd : + # self.dlg.Pulse(u'CHD...') + # sleep(0.2) + # else : + # pass + #check_Rresult(self.parent, pid) + self.corpus.make_ucecl_from_R(self.pathout['uce']) + #ucecl0 = [cl for uce,cl in ucecl if cl != 0] + #clnb = len(list(set(ucecl0))) + #classes = [cl for uce, cl in ucecl] + #uces1 = [val for val, i in uces1] + #self.corpus.make_lc(uces1, classes, clnb) + #self.corpus.build_profile(clnb, classes, self.corpus.actives, self.corpus.dictpathout['Contout']) + self.corpus.make_and_write_profile(self.actives, self.corpus.lc, self.pathout['Contout']) + self.sup, lim = self.corpus.make_actives_nb(self.parametres['max_actives'], 2) + self.corpus.make_and_write_profile(self.sup, self.corpus.lc, self.pathout['ContSupOut']) + self.corpus.make_and_write_profile_et(self.corpus.lc, self.pathout['ContEtOut']) + self.clnb = len(self.corpus.lc) + self.parametres['clnb'] = self.clnb #passives = [lem for lem in self.corpus.lems if lem not in self.corpus.actives] - self.corpus.build_profile(clnb, classes, self.corpus.supp, self.corpus.dictpathout['ContSupOut']) - self.corpus.make_etoiles(self.corpus.para_coords) - self.corpus.build_profile_et(clnb, classes, uces1, self.corpus.dictpathout['ContEtOut']) - AlcesteTxtProf(self.corpus.dictpathout, self.parent.RscriptsPath, clnb, '0.9') - pid = exec_rcode(self.parent.RPath, self.corpus.dictpathout['RTxtProfGraph'], wait = False) - while pid.poll() == None : - if not self.cmd : - self.dlg.Pulse(u'AFC...') - sleep(0.2) - else : - pass - check_Rresult(self.parent, pid) - temps = time() - t1 - self.corpus.minutes, self.corpus.seconds = divmod(temps, 60) - self.corpus.hours, self.corpus.minutes = divmod(self.corpus.minutes, 60) - PrintRapport(self.corpus, 'txt') - CreateIraFile(self.corpus.dictpathout, clnb, os.path.basename(self.corpus.parametre['filename'])) + #self.corpus.build_profile(clnb, classes, self.corpus.supp, self.corpus.dictpathout['ContSupOut']) + #self.corpus.make_etoiles(self.corpus.para_coords) + #self.corpus.build_profile_et(clnb, classes, uces1, self.corpus.dictpathout['ContEtOut']) + AlcesteTxtProf(self.pathout, self.parent.RscriptsPath, clnb, '0.9') + self.doR(self.pathout['RTxtProfGraph'], dlg = self.dlg, message = 'profils et A.F.C. ...') + #pid = exec_rcode(self.parent.RPath, self.corpus.dictpathout['RTxtProfGraph'], wait = False) + #while pid.poll() == None : + # if not self.cmd : + # self.dlg.Pulse(u'AFC...') + # sleep(0.2) + # else : + # pass + #check_Rresult(self.parent, pid) + #temps = time() - t1 + #self.corpus.minutes, self.corpus.seconds = divmod(temps, 60) + #self.corpus.hours, self.corpus.minutes = divmod(self.corpus.minutes, 60) + PrintRapport(self, self.corpus, self.parametres) + #CreateIraFile(self.corpus.dictpathout, clnb, os.path.basename(self.corpus.parametre['filename'])) self.corpus.save_corpus(self.corpus.dictpathout['db']) afc_graph_list = [[os.path.basename(self.corpus.dictpathout['AFC2DL_OUT']), u'Variables actives - coordonnées - facteurs 1 / 2'], [os.path.basename(self.corpus.dictpathout['AFC2DSL_OUT']), u'variables supplémentaires - coordonnées - facteurs 1 / 2'], [os.path.basename(self.corpus.dictpathout['AFC2DEL_OUT']), u'Variables illustratives - Coordonnées - facteur 1 / 2'], - [os.path.basename(self.corpus.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2'], - [os.path.basename(self.corpus.dictpathout['AFC2DCoul']), u'Variables actives - Corrélation - facteur 1/2'], - [os.path.basename(self.corpus.dictpathout['AFC2DCoulSup']), u'Variables supplémentaires - Corrélation - facteur 1 / 2'], - [os.path.basename(self.corpus.dictpathout['AFC2DCoulEt']), u'Variables illustratives - Corrélations - facteur 1 / 2'], - [os.path.basename(self.corpus.dictpathout['AFC2DCoulCl']), u'Classes - Corrélations - facteurs 1 / 2'],] + [os.path.basename(self.corpus.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2']] chd_graph_list = [[os.path.basename(self.corpus.dictpathout['arbre1']), u'résultats de la classification']] - print_liste(self.corpus.dictpathout['liste_graph_afc'],afc_graph_list) - print_liste(self.corpus.dictpathout['liste_graph_chd'],chd_graph_list) - if not self.cmd : - self.dlg.Update(9, u'fin') - self.dlg.Destroy() - OpenAnalyse(self.parent, self.corpus.dictpathout['ira']) - print 'fini' + print_liste(self.pathout['liste_graph_afc'],afc_graph_list) + print_liste(self.pathout['liste_graph_chd'],chd_graph_list) + #if not self.cmd : + # self.dlg.Update(9, u'fin') + # self.dlg.Destroy() + #print 'fini' diff --git a/textsimi.py b/textsimi.py index 0bebb95..acb85a3 100644 --- a/textsimi.py +++ b/textsimi.py @@ -108,6 +108,10 @@ class SimiTxt(AnalyseText): 'keep_coord' : True, 'alpha' : 20, 'film': False, + 'svg' : 0, + 'com' : 0, + 'communities' : 0, + 'halo' : 0, #'ira' : self.pathout['Analyse.ira'] } self.parametres.update(self.paramsimi) @@ -159,11 +163,16 @@ class SimiFromCluster(SimiTxt) : if not self.doR(script.scriptout, dlg = self.dlg, message = 'R ...') : return False if self.parametres['type_graph'] == 1: + if self.parametres['svg'] : + filename, ext = os.path.splitext(script.filename) + fileout = filename + '.svg' + else : + fileout = self.script.filename 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]) + graph_simi.append([os.path.basename(fileout), script.txtgraph]) else : - graph_simi = [[os.path.basename(script.filename), script.txtgraph]] + graph_simi = [[os.path.basename(fileout), script.txtgraph]] print_liste(self.pathout['liste_graph'], graph_simi) else : return False @@ -175,169 +184,3 @@ class SimiFromCluster(SimiTxt) : 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 -# self.tableau.parametre['fromtxt'] = True -# self.corpus.lems_eff = dict([[lem,[self.corpus.lems[lem].freq]] for lem in self.actives]) -# #print('ATTENTION ETOILES') -# #self.paramsimi['bystar'] = True -# self.tableau.listet = copy(self.listet) -# #self.paramsimi['cexfromchi'] = True -# #self.paramsimi['vlabcolor'] = True -# self.tableau.actives = copy(self.corpus.lems_eff) -# DoSimi(self, fromprof = self.pathout['mat01.csv'], param = self.paramsimi, pathout = self.pathout.dirout) - -#class SimiTxt : -# def __init__(self, parent, cmd = False, param = None): -# self.parent = parent -# self.cmd = cmd -# self.ConfigPath = parent.ConfigPath -# self.DictPath = parent.DictPath -# self.KeyConf = RawConfigParser() -# self.KeyConf.read(self.ConfigPath['key']) -# self.indices = indices_simi -# self.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' : 1, -# 'cexfromchi' : False, -# 'vcexmin' : 10, -# 'vcexmax' : 25, -# 'cex' : 10, -# 'seuil_ok' : 0, -# 'seuil' : 1, -# 'cols' : (255,0,0), -# 'cola' : (200,200,200), -# 'width' : 1000, -# 'height' : 1000, -# 'bystar' : False, -# 'first' : True, -# 'keep_coord' : True, -# 'alpha' : 20, -# 'film': False, -# } -# page = getPage(self.parent) -# if page is not None : -# self.corpus = getCorpus(page) -# if self.corpus is not None : -# self.pathout = ConstructPathOut(self.corpus.parametre['openpath'], 'simitxt') -# self.dictpathout = construct_simipath(self.pathout) -# self.val = wx.ID_OK -# self.make_table() -# self.make_simi() -# else : -# self.corpus = Corpus(parent) -# self.corpus.content = self.parent.content -# self.corpus.parametre['encodage'] = parent.corpus_encodage -# self.corpus.parametre['lang'] = parent.corpus_lang -# self.corpus.parametre['filename'] = parent.filename -# self.corpus.parametre['eff_min_uce'] = None -# self.pathout = ConstructPathOut(self.corpus.parametre['filename'], 'simitxt') -# self.dictpathout = construct_simipath(self.pathout) -# dial = StatDialog(self, self.parent) -# dial.check_uce.SetValue(True) -# dial.check_uce.Enable(False) -# dial.OnCheckUce(wx.EVT_MENU) -# self.val = dial.ShowModal() -# if self.val == wx.ID_OK : -# with open(self.parent.ConfigPath['key'], 'w') as f: -# self.KeyConf.write(f) -# if dial.radio_lem.GetSelection() == 0 : lem = True -# else : lem = False -# if dial.exp.GetSelection() == 0 : exp = True -# else : exp = False -# dial.Destroy() -# self.corpus.parametre['lem'] = lem -# self.corpus.parametre['expressions'] = exp -# self.corpus.parametre['nbforme_uce'] = dial.spin_ctrl_4.GetValue() -# self.corpus.parametre['eff_min_forme'] = dial.spin_ctrl_5.GetValue() -# self.corpus.parametre['max_actives'] = dial.spin_max_actives.GetValue() -# self.make_corpus() -# self.make_table() -# self.make_simi() -# else : -# dial.Destroy() -# -# def make_corpus(self) : -# print 'make corpus' -# if not self.cmd : -# dlg = progressbar(self, maxi = 6) -# self.corpus.supplementaires = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "2"] -# self.corpus.typeactive = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "1"] -# ucis_txt, ucis_paras_txt = self.corpus.start_analyse(self.parent, dlg = dlg, cmd = self.cmd) -# del ucis_txt -# -# if not self.cmd : -# dlg.Update(5, '%i ucis - Construction des uces' % len(ucis_paras_txt)) -# self.corpus.make_ucis_paras_uces(ucis_paras_txt, make_uce = True) -# del ucis_paras_txt -# -# if self.corpus.para_coords != [[] for val in self.corpus.para_coords] : -# self.corpus.parametre['para'] = True -# else : -# self.corpus.parametre['para'] = False -# self.corpus.make_etoiles(self.corpus.para_coords) -# print 'len(ucis_paras_uces)', len(self.corpus.ucis_paras_uces) -# -# if not self.cmd : -# dlg.Update(6, u'Dictionnaires') -# uces, self.orderuces = self.corpus.make_forms_and_uces() -# self.corpus.ucenb = len(uces) -# self.corpus.make_lems(self.parent.lexique) -# -# self.corpus.make_var_actives() -# self.corpus.make_var_supp() -# self.corpus.lems_eff = self.corpus.make_lem_eff() -# -# #variables = treat_var_mod(listet) -# #print(variables) -# #self.corpus.write_etoiles(self.dictpathout['etoiles']) -# if not self.cmd : -# dlg.Destroy() -# -# def make_table(self) : -# if 'orderuces' not in dir(self) : -# self.orderuces = [(i,j,k) for i, uci in enumerate(self.corpus.ucis_paras_uces) for j, para in enumerate(uci) for k, uce in enumerate(para)] -# self.orderuces = dict([[val, i] for i, val in enumerate(self.orderuces)]) -# self.corpus.ucenb = len(self.orderuces) -# #tabuc1 = self.corpus.make_table_with_uce(self.orderuces) -# #tabuc1.insert(0,self.corpus.actives) -# #tabuc1 = self.corpus.make_sparse_matrix_with_uce(self.orderuces) -# #self.corpus.write_sparse_matrix(self.dictpathout['mat01'], tabuc1, self.corpus.ucenb, len(self.corpus.actives)) -# if self.corpus.actives is None : -# self.corpus.typeactive = [option for option in self.KeyConf.options('KEYS') if self.KeyConf.get('KEYS', option) == "1"] -# self.corpus.min_eff_formes() -# self.corpus.make_var_actives() -# self.corpus.make_and_write_sparse_matrix_from_uce(self.orderuces, self.dictpathout['mat01']) -# #self.corpus.write_tab(tabuc1,self.dictpathout['mat01']) -# -# def make_simi(self) : -# self.tableau = Tableau(self.parent, '') -# self.tableau.listactives = self.corpus.actives -# self.tableau.parametre['fromtxt'] = True -# if 'lems_eff' not in dir(self.corpus) : -# self.corpus.lems_eff = self.corpus.make_lem_eff() -# #print('ATTENTION ETOILES') -# #self.paramsimi['bystar'] = True -# self.listet = self.corpus.get_unique_etoiles() -# self.listet.sort() -# self.tableau.listet = copy(self.listet) -# self.paramsimi['stars'] = copy(self.listet) -# #self.paramsimi['cexfromchi'] = True -# self.paramsimi['sfromchi'] = False -# #self.paramsimi['vlabcolor'] = True -# self.tableau.actives = dict([[lem, self.corpus.lems_eff[lem]] for lem in self.corpus.actives]) -# self.corpus.save_corpus(self.dictpathout['corpus']) -# DoSimi(self, fromprof = self.dictpathout['mat01'], param = self.paramsimi, pathout = self.pathout) diff --git a/tree.py b/tree.py index e9ab091..07576de 100644 --- a/tree.py +++ b/tree.py @@ -340,7 +340,7 @@ class LeftTree(CT.CustomTreeCtrl): stat = menu.Append(wx.ID_ANY, u"Statistiques") spec = menu.Append(wx.ID_ANY, u"Spécificté et AFC") classification = wx.Menu() - alceste = classification.Append(wx.ID_ANY, u"Méthode ALCESTE") + alceste = classification.Append(wx.ID_ANY, u"Méthode GNEPA") pam = classification.Append(wx.ID_ANY, u"Par matrice des distances") menu.AppendMenu(-1, u"Classification", classification) simi = menu.Append(wx.ID_ANY, u"Analyse de similitude") @@ -422,7 +422,7 @@ class LeftTree(CT.CustomTreeCtrl): self.parent.OnTextAlceste(evt, self.getcorpus()) def OnPam(self, evt) : - print 'rien' + self.parent.OnPamSimple(evt, self.getcorpus()) def OnSimiTxt(self, evt) : self.parent.OnSimiTxt(evt, self.getcorpus())