Merge branch 'master' of http://www.netdig.org/git/iramuteq
authorpierre <ratinaud@univ-tlse2.fr>
Mon, 28 Jan 2013 23:08:23 +0000 (00:08 +0100)
committerpierre <ratinaud@univ-tlse2.fr>
Mon, 28 Jan 2013 23:08:23 +0000 (00:08 +0100)
33 files changed:
OptionAlceste.py
PrintRScript.py
ProfList.py
Rscripts/CHD.R
Rscripts/Rgraph.R
Rscripts/afc_graph.R
Rscripts/anacor.R
Rscripts/chdquest.R
Rscripts/chdtxt.R
Rscripts/simi.R
analysematrix.py
analysetxt.py
checkinstall.py
chemins.py
configuration/alceste.cfg
corpus.py
dialog.py
functions.py
guifunct.py
iracmd.py
iramuteq.py
layout.py
openanalyse.py
tabchdalc.py
tabchddist.py
tabfrequence.py
tableau.py
tabsimi.py
textaslexico.py
textdist.py
textsimi.py
textstat.py
tree.py

index 49ff0f1..3d52b42 100755 (executable)
@@ -20,19 +20,21 @@ class OptionAlc(wx.Dialog):
         self.DictPath = parametres['pathout']
         self.AlcesteConf = parametres
         self.choose = False
-        
+        self.svdmethod = ['svdR', 'irlba']
+        if self.parent.pref.getboolean('iramuteq','libsvdc') :
+            self.svdmethod.append('svdlibc')
         #self.label_1 = wx.StaticText(self, -1, u"Lemmatisation")
         #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)       
@@ -42,6 +44,10 @@ analysée (2 = automatique)"""
         self.spin_ctrl_5 = wx.SpinCtrl(self, -1, "",size = (100,30), min=2, max=1000)
         self.label_max_actives =  wx.StaticText(self, -1, u"Nombre maximum de formes analysées")
         self.spin_max_actives = wx.SpinCtrl(self, -1, "",size = (100,30), min=20, max=10000)
+        self.label_svd = wx.StaticText(self, -1, u"Méthode pour svd")
+        self.choicesvd = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.svdmethod, 0 )
+        self.label_patate =  wx.StaticText(self, -1, u"Mode patate (+ rapide, - précis)")
+        self.check_patate = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
         #self.label_4 = wx.StaticText(self, -1, u"Configuration \ndes clés d'analyse")
         #self.button_5 = wx.Button(self, wx.ID_PREFERENCES, "")
         self.button_1 = wx.Button(self, wx.ID_CANCEL, "")
@@ -72,6 +78,15 @@ analysée (2 = automatique)"""
         self.spin_ctrl_5.Disable()
         self.spin_max_actives.SetValue(int(self.parametres['max_actives']))
         self.spin_nbcl.SetValue(int(self.parametres['nbcl_p1']))
+        if 'svdmethod' in self.parametres :
+            self.choicesvd.SetSelection(self.svdmethod.index(self.parametres['svdmethod']))
+        else :
+            self.choicesvd.SetSelection(1)
+        if 'mode.patate' in self.parametres :
+            self.check_patate.SetValue(self.parametres['mode.patate'])
+        else :
+             self.check_patate.SetValue(False)
+
 
     def __do_layout(self):
         sizer_1 = wx.BoxSizer(wx.VERTICAL)
@@ -122,10 +137,15 @@ analysée (2 = automatique)"""
         grid_sizer2.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 1)
         grid_sizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.ALL, 1)
        
-        #grid_sizer2.Add(self.label_4, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
-        #grid_sizer2.Add(self.button_5, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
-        #grid_sizer2.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 1)
-        #grid_sizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.ALL, 1)
+        grid_sizer2.Add(self.label_svd, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
+        grid_sizer2.Add(self.choicesvd, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
+        grid_sizer2.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 1)
+        grid_sizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.ALL, 1)
+
+        grid_sizer2.Add(self.label_patate, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
+        grid_sizer2.Add(self.check_patate, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 0)
+        grid_sizer2.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 1)
+        grid_sizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.ALL, 1)
         
         grid_button.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
         grid_button.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
index 9a92096..b29f813 100644 (file)
@@ -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])
@@ -109,7 +109,7 @@ class Alceste2(PrintRScript) :
 #
 
 
-def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False, libsvdc_path = None, R_max_mem = False):
+def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'svdR', libsvdc = False, libsvdc_path = None, R_max_mem = False, mode_patate = False):
     txt = """
     source("%s")
     source("%s")
@@ -124,17 +124,30 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False
     txt += """
     nbt <- %i
     """ % nbt
-    if libsvdc :
+    if svdmethod == 'svdlibc' and libsvdc :
         txt += """
-        libsvdc <- TRUE
+        svd.method <- 'svdlibc'
         libsvdc.path <- "%s"
         """ % ffr(libsvdc_path)
+    elif svdmethod == 'irlba' :
+        txt += """
+        library(irlba)
+        svd.method <- 'irlba'
+        libsvdc.path <- NULL
+        """
     else :
         txt += """
-        libsvdc <- FALSE
+        svd.method = 'svdR'
         libsvdc.path <- NULL
         """
-
+    if mode_patate :
+        txt += """
+        mode.patate = TRUE
+        """
+    else :
+        txt += """
+        mode.patate = FALSE
+        """
     txt +="""
     library(Matrix)
     data1 <- readMM("%s")
@@ -148,14 +161,13 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False
         data2 <- as(data2, "dgCMatrix")
         row.names(data2) <- 1:nrow(data2)
         """ % DicoPath['TableUc2']
-    #log.info('ATTENTION ############# MODEPATATE ####################')
     txt += """
-    chd1<-CHD(data1, x = nbt, mode.patate = FALSE, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
+    chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)
     """
     
     if classif_mode == 0:
         txt += """
-    chd2<-CHD(data2, x = nbt, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
+    chd2<-CHD(data2, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)
     """
     else:
         txt += """
@@ -181,11 +193,18 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False
         rm(data2)
         """
     txt += """
-    chd.result <- Rchdtxt("%s",mincl=%i,classif_mode=%i, nbt = nbt)
+    classif_mode <- %i
+    mincl <- %i
+    uceout <- "%s"
+    if (classif_mode == 0) {
+        chd.result <- Rchdtxt(uceout, chd1, chd2 = chd2, mincl = mincl,classif_mode = classif_mode, nbt = nbt)
+    } else {
+        chd.result <- Rchdtxt(uceout, chd1, chd2 = chd1, mincl = mincl,classif_mode = classif_mode, nbt = nbt)
+    }
     n1 <- chd.result$n1
     classeuce1 <- chd.result$cuce1
     classeuce2 <- chd.result$cuce2
-    """ % (DicoPath['uce'], mincl, classif_mode)
+    """ % (classif_mode, mincl, DicoPath['uce'])
     
     txt += """
     tree.tot1 <- make_tree_tot(chd1)
@@ -232,8 +251,8 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False
     fileout.close()
 
 def RPamTxt(corpus, RscriptPath):
-    DicoPath = corpus.dictpathout
-    param = corpus.parametre
+    DicoPath = corpus.pathout
+    param = corpus.parametres
     print param
     txt = """
     source("%s")
@@ -290,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 += """
@@ -366,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)
@@ -686,18 +690,67 @@ 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"
             selected.col <- "%s"
             """ % (self.pathout['mat01.csv'], self.pathout['actives.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 <-readMM(dm.path)
-            cn <- read.table(cn.path, sep=';', quote='"')
+            cn <- read.table(cn.path, sep='\t', quote='"')
             colnames(dm) <- cn[,1]
-            sel.col <- read.csv2(selected.col)
-            dm <- dm[, sel.col[,1] + 1]
+            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)
+            }
+            """
+        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 += """
@@ -740,8 +793,39 @@ class PrintSimiScript(PrintRScript) :
             txt += """
             mat <- as.matrix(stats::as.dist(mat,diag=TRUE,upper=TRUE))
             mat[is.na(mat)] <- 0
-            mat[is.infinite(mat)] <- 0
+            if (length(which(mat == Inf))) {
+                infp <- which(mat == Inf)
+                mat[infp] <- NA
+                maxmat <- max(mat, na.rm = TRUE)
+                if (maxmat > 0) {
+                maxmat <- maxmat + 1
+                } else {
+                    maxmat <- 0
+                }
+                mat[infp] <- maxmat
+            }
+            if (length(which(mat == -Inf))) {
+                infm <- which(mat == -Inf)
+                mat[infm] <- NA
+                minmat <- min(mat, na.rm = TRUE)
+                if (maxmat < 0) {
+                minmat <- minmat - 1
+                } else {
+                    minmat <- 0
+                }
+                mat[infm] <- minmat
+            }
             """
+        if 'word' in self.parametres and not self.parametres['keep_coord'] :
+            txt += """
+            mat <- graph.word(mat, index)
+            cs <- colSums(mat)
+            if (length(cs)) mat <- mat[,-which(cs==0)]
+            rs <- rowSums(mat)
+            if (length(rs)) mat <- mat[-which(rs==0),]
+            if (length(cs)) dm <- dm[, -which(cs==0)]
+            """
+
         if self.parametres['layout'] == 0 : layout = 'random'
         if self.parametres['layout'] == 1 : layout = 'circle'
         if self.parametres['layout'] == 2 : layout = 'frutch'
@@ -907,10 +991,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) :
@@ -931,18 +1027,15 @@ class PrintSimiScript(PrintRScript) :
                 vertex.size <- NULL
                 """
         else :
-            #FIXME
-            tmpchi = False
-            if tmpchi :
+            if self.parametres['type'] == 'clustersimitxt' : 
                 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.parametres.get('cexfromchi', False) :
+                """ % ffr(self.parametres['tmpchi'])
+                txt += """
+                    lchi <- lchi[sel.col]
+                    """
+            if self.parametres['type'] == 'clustersimitxt' and self.parametres.get('cexfromchi', False) :
                 txt += """ 
                 label.cex <- norm.vec(lchi, vcexminmax[1], vcexminmax[2])
                 """
@@ -954,21 +1047,38 @@ class PrintSimiScript(PrintRScript) :
                 label.cex <- graph.simi$label.cex
             }
             """
-            if tmpchi and self.parametres.get('sfromchi', False) :
+            if self.parametres['type'] == 'clustersimitxt' and self.parametres.get('sfromchi', False) :
                 txt += """ 
                 vertex.size <- norm.vec(lchi, minmaxeff[1], minmaxeff[2])
+                if (!length(vertex.size)) vertex.size <- 0
                 """
             else :
                 txt += """
             if (is.null(minmaxeff[1])) {
-                vertex.size <- NULL
+                vertex.size <- 0
             } else {
                 vertex.size <- graph.simi$eff
             }
             """
-        txt += """ vertex.size <- NULL """
+        #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)
+        vertex.col <- cols
+        if (!is.null(graph.simi$com)) {
+            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)]
+            }
+        }
+        coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, svg = svg)
         save.image(file="%s")
         """ % (type, self.filename, self.pathout['RData'])
         
index 600dbcf..09b30a2 100644 (file)
@@ -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
@@ -74,6 +74,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             self.la = []
             self.lchi = []
             self.lfreq = []
+        self.tmpchi = None
             
         #adding some art
         self.il = wx.ImageList(16, 16)
@@ -375,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')
@@ -406,13 +411,13 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
     def quest_simi(self, evt) :
         tableau = self.Source.tableau
         tab = tableau.make_table_from_classe(self.cl, self.la)
-        pathout = ConstructPathOut(self.Source.pathout+'/', 'simi_classe_%i' %self.cl)
+        pathout = ConstructPathOut(os.path.join(self.Source.pathout.dirout, 'simi_classe_%i' %self.cl), 'simi_classe_%i' %self.cl)
         self.filename = os.path.join(pathout,'mat01.csv')
         tableau.printtable(self.filename, tab)
         del tab
         paramsimi = {'coeff' : 0,
                           'layout' : 2,
-                          'type' : 1,
+                          'type_graph' : 1,
                           'arbremax' : 1,
                           'coeff_tv' : 1,
                           'coeff_tv_nb' : 0,
@@ -440,6 +445,9 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
                           'keep_coord' : True,
                           'alpha' : 20,
                           'film': False,
+                          'com' : 0,
+                          'communities' : 0,
+                          'halo' : 0
                           }
 #        self.tableau.actives = {}
 #        self.tableau.lchi = self.lchi
@@ -449,66 +457,42 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 #            self.tableau.chi[val] = [self.lchi[i]]
                           
         act = {}
-        self.tableau.chi = {}
-        self.tableau.lchi = self.lchi
-        self.tableau.parametre['fromprof'] = True
+        tableau.chi = {}
+        tableau.lchi = self.lchi
+        tableau.parametre['fromprof'] = True
         for i, val in enumerate(self.la) :
             act[val] = [self.lfreq[i]]
-            self.tableau.chi[val] = [self.lchi[i]]
-        DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout, listactives = self.la, actives = act)
+            tableau.chi[val] = [self.lchi[i]]
+        self.parent.SimiCluster(parametres = paramsimi, fromprof = ffr(self.filename), pathout = pathout, listactives = self.la, actives = act, tableau = tableau)
 
     def onwordgraph(self, evt):
         word = self.getColumnText(self.GetFirstSelected(), 6)
-        dlg = progressbar(self, 2)
-        corpus = self.Source.corpus
-        uces = corpus.lc[self.cl-1]
-        dlg.Update(1, u'Tableau...')
-        #tab = corpus.make_table_with_classe(uces, self.la)
-        pathout = ConstructPathOut(self.Source.pathout.dirout + '/' , 'simi_%s' % word)
-        self.filename = os.path.join(pathout,'mat01.csv')
-        dlg.Update(2, u'Ecriture...')
-        #corpus.write_tab(tab, self.filename)
-        #del tab
-        corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
-        dlg.Destroy()
-        paramsimi = {'coeff' : 0,
-                          'layout' : 2,
-                          'type' : 1,
-                          'arbremax' : 0,
-                          '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,
-                          'vcexmin' : 10,
-                          'vcexmax' : 25, 
-                          'cex' : 10,
-                          'seuil_ok' : 1,
-                          'seuil' : 1,
-                          'cols' : (255,0,0),
-                          'cola' : (200,200,200),
-                          'width' : 600,
-                          'height' : 600,
-                          'first' : True,
-                          'keep_coord' : True,
-                          'alpha' : 20,
-                          'film': False,
-                          }
-        self.tableau = Tableau(self.parent, '')
-        self.tableau.listactives = self.la
-        self.tableau.actives = {}
-        for i, val in enumerate(self.la) :
-            self.tableau.actives[val] = [self.lfreq[i]]
-        DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout, wordgraph = word)
+        if self.tmpchi is None :
+            self.tmpchi = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
+            with open(self.tmpchi, 'w') as f:
+                f.write('\n'.join([str(val) for val in self.lchi]))
+        index = self.la.index(word)
+        parametres = {'type' : 'clustersimitxt', 
+                        'pathout' : self.Source.parametres['pathout'],
+                        'word' : index ,
+                        'lem' : self.Source.parametres['lem'],
+                        'tmpchi' : self.tmpchi}
+        #try :
+        self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = parametres, dlg = progressbar(self, 4))
+        #except :
+        #    print 'not acitve'
 
     def on_graph(self, evt):
-        self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = {'type' : 'clustersimitxt', 'pathout' : self.Source.parametres['pathout']}, dlg = progressbar(self, 4))
+        if self.tmpchi is None :
+            self.tmpchi = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
+            with open(self.tmpchi, 'w') as f:
+                f.write('\n'.join([str(val) for val in self.lchi]))
+        parametres = {'type' : 'clustersimitxt', 
+                        'pathout' : self.Source.parametres['pathout'],
+                        'lem' : self.Source.parametres['lem'],
+                        'tmpchi' : self.tmpchi}
+
+        self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = parametres, dlg = progressbar(self, 4))
         #dlg = progressbar(self, 2)
         #corpus = self.Source.corpus
         #uces = corpus.lc[self.cl-1]
index 049d5c7..974e901 100644 (file)
@@ -41,7 +41,11 @@ find.max <- function(dtable, chitable, compte, rmax, maxinter, sc, TT) {
     res
 }  
 
-CHD<-function(data.in, x=9, mode.patate = FALSE, libsvdc=FALSE, libsvdc.path=NULL){
+
+
+
+
+CHD<-function(data.in, x=9, mode.patate = FALSE, svd.method, libsvdc.path=NULL){
 #      sink('/home/pierre/workspace/iramuteq/dev/findchi2.txt')
        dataori <- data.in
     row.names(dataori) <- rownames(data.in)
@@ -78,7 +82,7 @@ CHD<-function(data.in, x=9, mode.patate = FALSE, libsvdc=FALSE, libsvdc.path=NUL
                #extraction du premier facteur de l'afc
                print('afc')
                pp('taille dtable dans boucle (col/row)',c(ncol(dtable),nrow(dtable)))
-               afc<-boostana(dtable, nd=1, libsvdc=libsvdc, libsvdc.path=libsvdc.path)
+               afc<-boostana(dtable, nd=1, svd.method = svd.method, libsvdc.path=libsvdc.path)
                pp('SV',afc$singular.values)
                pp('V.P.', afc$eigen.values)
                coordrow <- as.matrix(afc$row.scores[,1])
@@ -103,7 +107,7 @@ CHD<-function(data.in, x=9, mode.patate = FALSE, libsvdc=FALSE, libsvdc.path=NUL
         rmax <- NULL
 
         inert <- find.max(dtable, chitable, compte, rmax, maxinter, sc, TT)
-               print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
+        print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
                pp('max inter phase 1', inert$maxinter/TT)#max(listinter))
                print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
         ordert <- ordert[order(ordert[,3]),]
index b0b555c..a4dd0da 100644 (file)
@@ -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) {
index d067c16..5b12163 100644 (file)
@@ -51,6 +51,7 @@ if ( qui == 3 ) {
     if ( what == 0 ) table.in <- afc$colcoord
     if ( what == 1 ) table.in <- afc$colcrl
     rownames(table.in) <- afc$colnames
+    eff <- afc$colmass
     if (typegraph == 0) {
         table.in<-table.in[,c(x,y)]
     } else {
@@ -76,21 +77,27 @@ if ( qui == 3 ) {
         ry <- range(table.in[,2], na.rm = TRUE)
         rz <- range(table.in[,3], na.rm = TRUE)
     }
+    if (exists(afctable)) {
+        eff <- rowSums(afctable)
+    } else {
+        eff <- afctable$rowmass
+    }
+
     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 +106,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)]
         }
     }
         
@@ -132,7 +139,11 @@ if ( qui == 3 ) {
     infp <-  which(is.infinite(maxchi) & maxchi > 0)
     if (length(infp)) {
         maxchi[infp] <- NA
-        valmax <- max(maxchi, na.rm = TRUE)
+        if (!length(infp) == length(maxchi)) {
+            valmax <- max(maxchi, na.rm = TRUE)
+        } else {
+            valmax <- 8
+        }
         maxchi[infp] <- valmax + 2
     } 
     if (cex.txt) {
index c68df77..a1441b9 100644 (file)
@@ -1,4 +1,3 @@
-print('NEW SVD')
 #################################################################################
 #http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg01513.html
 
@@ -53,7 +52,7 @@ my.svd <- function(x, nu, nv, libsvdc.path=NULL, sparse.path=NULL) {
 ###################################################################################
 
 #from anacor package
-boostana<-function (tab, ndim = 2, libsvdc = FALSE, libsvdc.path=NULL) 
+boostana<-function (tab, ndim = 2, svd.method = 'svdR', libsvdc.path=NULL) 
 {
     #tab <- as.matrix(tab)
     if (ndim > min(dim(tab)) - 1) 
@@ -76,7 +75,7 @@ boostana<-function (tab, ndim = 2, libsvdc = FALSE, libsvdc.path=NULL)
     z1 <- t(tab)/sqrt(c)
     z2 <- tab/sqrt(r)
     z <- t(z1) * z2
-    if (libsvdc) {
+    if (svd.method == 'svdlibc') {
         #START NEW SVD
         z <- as(z, "dgCMatrix")
         tmpmat <- tempfile(pattern='sparse')
@@ -85,10 +84,14 @@ boostana<-function (tab, ndim = 2, libsvdc = FALSE, libsvdc.path=NULL)
         print('do svd')
         sv <- my.svd(z, qdim, qdim, libsvdc.path=libsvdc.path, sparse.path=tmpmat)
         #END NEW SVD
-    } else {
+    } else if (svd.method == 'svdR') {
         print('start R svd')
         sv <- svd(z, nu = qdim, nv = qdim) 
         print('end svd')
+    } else if (svd.method == 'irlba') {
+        print('irlba')
+        sv <- irlba(z, qdim, qdim)
+        print('end irlba')
     }
     sigmavec <- (sv$d)[2:qdim]
        x <- ((sv$u)/sqrt(r))[, -1]
index 0bbe0d8..e8ad294 100644 (file)
@@ -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)]<length(classeuce[,i][classeuce[,i]==classes])) {
-                       poids[(classes-1)]<-length(classeuce[,i][classeuce[,i]==classes])
-                   }
-               }
-           }
-           poids
-       }
+#      makepoids<-function(classeuce,poids) {
+#          for (classes in 2:(tcl + 1)){
+#              for (i in 1:ncol(classeuce)) {
+#                  if (poids[(classes-1)]<length(classeuce[,i][classeuce[,i]==classes])) {
+#                      poids[(classes-1)]<-length(classeuce[,i][classeuce[,i]==classes])
+#                  }
+#              }
+#          }
+#          poids
+#      }
+    makepoids <- function(classeuce, poids) {
+        cl1 <- 0
+        cl2 <- 1
+        for (i in 1:nbt) {
+            cl1 <- cl1 + 2
+            cl2 <- cl2 + 2
+            poids[cl1 - 1] <- length(which(classeuce[,i] == cl1))
+            poids[cl2 - 1] <- length(which(classeuce[,i] == cl2))
+        }
+        poids
+    }
+    
        poids1<-makepoids(classeuce1,poids1)
        poids2<-poids1
 
-       croise=matrix(ncol=tcl,nrow=tcl)
-       #production du tableau de contingence
-       for (i in 1:ncol(classeuce1)) {
-           #poids[i]<-length(classeuce1[,i][x==classes])
-           for (j in 1:ncol(classeuce2)) {
-               tablecroise<-table(classeuce1[,i],classeuce2[,j])
-               tabcolnames<-as.numeric(colnames(tablecroise))
-               #tabcolnames<-c(tabcolnames[(length(tabcolnames)-1)],tabcolnames[length(tabcolnames)])
-               tabrownames<-as.numeric(rownames(tablecroise))
-               #tabrownames<-c(tabrownames[(length(tabrownames)-1)],tabrownames[length(tabrownames)])
-               for (k in (ncol(tablecroise)-1):ncol(tablecroise)) {
-                   for (l in (nrow(tablecroise)-1):nrow(tablecroise)) {
-                       croise[(tabrownames[l]-1),(tabcolnames[k]-1)]<-tablecroise[l,k]
-                   }
-               }
-           }
-           tablecroise
-       }
+#      croise=matrix(ncol=tcl,nrow=tcl)
+#      #production du tableau de contingence
+#      for (i in 1:ncol(classeuce1)) {
+#          #poids[i]<-length(classeuce1[,i][x==classes])
+#          for (j in 1:ncol(classeuce2)) {
+#              tablecroise<-table(classeuce1[,i],classeuce2[,j])
+#              tabcolnames<-as.numeric(colnames(tablecroise))
+#              #tabcolnames<-c(tabcolnames[(length(tabcolnames)-1)],tabcolnames[length(tabcolnames)])
+#              tabrownames<-as.numeric(rownames(tablecroise))
+#              #tabrownames<-c(tabrownames[(length(tabrownames)-1)],tabrownames[length(tabrownames)])
+#              for (k in (ncol(tablecroise)-1):ncol(tablecroise)) {
+#                  for (l in (nrow(tablecroise)-1):nrow(tablecroise)) {
+#                      croise[(tabrownames[l]-1),(tabcolnames[k]-1)]<-tablecroise[l,k]
+#                  }
+#              }
+#          }
+#          tablecroise
+#      }
+    croise <- croiseeff( matrix(ncol=tcl,nrow=tcl), classeuce1, classeuce2)
     if (mincl == 2) {
            mincl<-round(nrow(classeuce1)/(nbt+1)) #valeur a calculer nbuce/nbt
     }
@@ -128,47 +169,69 @@ Rchdquest<-function(tableuc1,listeuce1,uceout ,nbt = 9, mincl = 2) {
        print(chicroise)
        #determination des chi2 les plus fort
        chicroiseori<-chicroise
-       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
-       }
+    doxy <- function(chicroise) {
+        listx <- NULL
+        listy <- NULL
+        listxy <- which(chicroise > 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=' ')
index a6c2d4c..436d0ba 100644 (file)
@@ -6,39 +6,9 @@
 #fonction pour la double classification
 #cette fonction doit etre splitter en 4 ou 5 fonctions
 
-#Rchdtxt<-function(tableuc1,tableuc2,listeuce1,listeuce2,arbre1,arbre2,uceout) {
-       #source('/home/pierre/workspace/iramuteq/Rscripts/CHD.R')
-
-       #lecture des tableaux
-#      data1<-read.csv2(tableuc1)
-#      data2<-read.csv2(tableuc2)
-
-       #analyse des tableaux avec la fonction CHD qui doit etre sourcee avant
-#      chd1<-CHD(data1)
-#      chd2<-CHD(data2)
-
-       #lecture des uce
-#      listuce1<-read.csv2(listeuce1)
-#      listuce2<-read.csv2(listeuce2)
-
-       #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) {
     print('assigne classe -> uce')
-    out<-matrix(nrow=nrow(listuce),ncol=ncol(chd))
-    for (j in 1:ncol(chd)) {
-        out[listuce[,1]+1, j] <- chd[listuce[,2]+1, j]
-    }
-    out
+    chd[listuce[,2]+1,]
 }
 
 fille<-function(classe,classeuce) {
@@ -47,8 +17,77 @@ fille<-function(classe,classeuce) {
        listf<-unique(listf)
        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
+}
+
+addallfille <- function(lf) {
+    nlf <- list()
+    for (i in 1:length(lf)) {
+        if (! is.null(lf[[i]])) {
+            nlf[[i]] <- lf[[i]]
+            filles <- lf[[i]]
+            f1 <- filles[1]
+            f2 <- filles[2]
+            if (f1 > length(lf)) {
+                for (j in (length(lf) + 1):f2) {
+                    nlf[[j]] <- 0
+                }
+            }
+        } else {
+            nlf[[i]] <- 0
+        }
+    }
+nlf
+}
+
+getfille <- function(nlf, classe, pf) {
+    if (length(nlf[[classe]]) == 1) {
+        return(pf)
+    } else {
+        pf <- c(pf, nlf[[classe]])
+        c1 <- nlf[[classe]][1]
+        c2 <- nlf[[classe]][2]
+        pf <- getfille(nlf, c1, pf)
+        pf <- getfille(nlf, c2, pf)
+    }
+    return(pf)
+}
+
+getmere <- function(list_mere, classe) {
+    i <- classe
+    pf <- NULL
+    while (i != 1 ) {
+        pf <- c(pf, list_mere[[i]])
+        i <- list_mere[[i]]
+    }
+    pf
+}
+
+getfillemere <- function(list_fille, list_mere, classe) {
+    return(c(getfille(list_fille, classe, NULL), getmere(list_mere, classe)))
+}
+
 #nbt nbcl = nbt+1 tcl=((nbt+1) *2) - 2  n1[,ncol(n1)], nchd1[,ncol(nchd1)]
-Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
+Rchdtxt<-function(uceout, chd1, chd2 = NULL, mincl=0, classif_mode=0, nbt = 9) {
        #FIXME: le nombre de classe peut etre inferieur
     nbcl <- nbt + 1
     tcl <- ((nbt+1) * 2) - 2
@@ -62,16 +101,29 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
 
        #calcul des poids (effectifs)
 
-       makepoids<-function(classeuce,poids) {
-           for (classes in 2:(tcl + 1)){
-               for (i in 1:ncol(classeuce)) {
-                   if (poids[(classes-1)]<length(classeuce[,i][classeuce[,i]==classes])) {
-                       poids[(classes-1)]<-length(classeuce[,i][classeuce[,i]==classes])
-                   }
-               }
-           }
-           poids
-       }
+    makepoids <- function(classeuce, poids) {
+        cl1 <- 0
+        cl2 <- 1
+        for (i in 1:nbt) {
+            cl1 <- cl1 + 2
+            cl2 <- cl2 + 2
+            poids[cl1 - 1] <- length(which(classeuce[,i] == cl1))
+            poids[cl2 - 1] <- length(which(classeuce[,i] == cl2))
+        }
+        poids
+    }
+
+#      makepoids<-function(classeuce,poids) {
+#          for (classes in 2:(tcl + 1)){
+#                  for (i in 1:ncol(classeuce)) {
+#                      if (poids[(classes-1)]<length(classeuce[,i][classeuce[,i]==classes])) {
+#                          poids[(classes-1)]<-length(classeuce[,i][classeuce[,i]==classes])
+#                      }
+#                  }
+#          }
+#          poids
+#      }
+    print('make poids')
        poids1<-vector(mode='integer',length = tcl)
        poids1<-makepoids(classeuce1,poids1)
        if (classif_mode==0) {
@@ -80,29 +132,35 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
        } else {
                poids2<-poids1
        }
+    
+    print('croisement classif')
 
-       croise=matrix(ncol=tcl,nrow=tcl)
-       #production du tableau de contingence
-       for (i in 1:ncol(classeuce1)) {
-           #poids[i]<-length(classeuce1[,i][x==classes])
-           for (j in 1:ncol(classeuce2)) {
-               tablecroise<-table(classeuce1[,i],classeuce2[,j])
-               tabcolnames<-as.numeric(colnames(tablecroise))
-               #tabcolnames<-c(tabcolnames[(length(tabcolnames)-1)],tabcolnames[length(tabcolnames)])
-               tabrownames<-as.numeric(rownames(tablecroise))
-               #tabrownames<-c(tabrownames[(length(tabrownames)-1)],tabrownames[length(tabrownames)])
-               for (k in (ncol(tablecroise)-1):ncol(tablecroise)) {
-                   for (l in (nrow(tablecroise)-1):nrow(tablecroise)) {
-                       croise[(tabrownames[l]-1),(tabcolnames[k]-1)]<-tablecroise[l,k]
-                   }
-               }
-           }
-           tablecroise
-       }
+#    croise=matrix(ncol=tcl,nrow=tcl)
+#
+#    docroise <- function(croise, classeuce1, classeuce2) {
+#      #production du tableau de contingence
+#      for (i in 1:ncol(classeuce1)) {
+#          #poids[i]<-length(classeuce1[,i][x==classes])
+#          for (j in 1:ncol(classeuce2)) {
+#                  tablecroise<-table(classeuce1[,i],classeuce2[,j])
+#                  tabcolnames<-as.numeric(colnames(tablecroise))
+#                  #tabcolnames<-c(tabcolnames[(length(tabcolnames)-1)],tabcolnames[length(tabcolnames)])
+#                  tabrownames<-as.numeric(rownames(tablecroise))
+#                  #tabrownames<-c(tabrownames[(length(tabrownames)-1)],tabrownames[length(tabrownames)])
+#                  for (k in (ncol(tablecroise)-1):ncol(tablecroise)) {
+#                      for (l in (nrow(tablecroise)-1):nrow(tablecroise)) {
+#                          croise[(tabrownames[l]-1),(tabcolnames[k]-1)]<-tablecroise[l,k]
+#                      }
+#                  }
+#          }
+#      }
+#        croise
+#    }
+    croise <- croiseeff( matrix(ncol=tcl,nrow=tcl), classeuce1, classeuce2)
     if (classif_mode == 0) {ind <- (nbcl * 2)} else {ind <- nbcl}
        if (mincl==0){
                mincl<-round(nrow(classeuce1)/ind)
-       }#valeur a calculer nbuce/20
+       }
        if (mincl<3){
                mincl<-3
        }
@@ -110,73 +168,129 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
        #print('table1')
        #print(croise)
        #tableau des chi2 signes
-       chicroise<-croise
-       for (i in 1:nrow(croise)) {
-           for (j in 1:ncol(croise)) {
-               if (croise[i,j]==0) {
-                   chicroise[i,j]<-0
-               } else if (croise[i,j]<mincl) { 
-                   chicroise[i,j]<-0
-               } else {
-               chitable<-matrix(ncol=2,nrow=2)
-               chitable[1,1]<-croise[i,j]
-               chitable[1,2]<-poids1[i]-chitable[1,1]
-               chitable[2,1]<-poids2[j]-chitable[1,1]
-               chitable[2,2]<-nrow(classeuce1)-poids2[j]-chitable[1,2]
-               chitest<-chisq.test(chitable,correct=FALSE)
-               if ((chitable[1,1]-chitest$expected)<0) {
-                   chicroise[i,j]<--round(chitest$statistic,digits=7)
-               } else {
-                   chicroise[i,j]<-round(chitest$statistic,digits=7)
-               #print(chitest)
-               }
-               }
-           }   
-       }
+    print('croise chi2')
+       #chicroise<-croise
+
+#    nr <- nrow(classeuce1)
+#    newchicroise <- function(croise, mincl, nr, poids1, poids2) {
+#        chicroise <- croise
+#        chicroise[which(croise < mincl)] <- 0
+#        tocompute <- which(chicroise > 0, arr.ind = TRUE)
+#        for (i in 1:nrow(tocompute)) {
+#            chitable <- matrix(ncol=2,nrow=2)
+#            chitable[1,1] <- croise[tocompute[i,1],  tocompute[i,2]]
+#            chitable[1,2] <- poids1[tocompute[i,1]] - chitable[1,1]
+#            chitable[2,1] <- poids2[tocompute[i,2]] - chitable[1,1]
+#            chitable[2,2] <- nr - poids2[tocompute[i,2]] - chitable[1,2]
+#            chitest<-chisq.test(chitable,correct=FALSE)
+#            chicroise[tocompute[i,1],  tocompute[i,2]] <- ifelse(chitable[1,1] > chitest$expected[1,1], round(chitest$statistic,digits=7), -round(chitest$statistic,digits=7))
+#        }
+#        chicroise
+#    }
+#
+        
+
+       dochicroise <- function(croise, mincl) {
+        chicroise <- croise
+        for (i in 1:nrow(croise)) {
+               for (j in 1:ncol(croise)) {
+                   if (croise[i,j]==0) {
+                       chicroise[i,j]<-0
+                   } else if (croise[i,j]<mincl) { 
+                       chicroise[i,j]<-0
+                   } else {
+                       chitable<-matrix(ncol=2,nrow=2)
+                       chitable[1,1]<-croise[i,j]
+                       chitable[1,2]<-poids1[i]-chitable[1,1]
+                       chitable[2,1]<-poids2[j]-chitable[1,1]
+                       chitable[2,2]<-nrow(classeuce1)-poids2[j]-chitable[1,2]
+                       chitest<-chisq.test(chitable,correct=FALSE)
+                       if ((chitable[1,1]-chitest$expected[1,1])<0) {
+                           chicroise[i,j]<--round(chitest$statistic,digits=7)
+                       } else {
+                           chicroise[i,j]<-round(chitest$statistic,digits=7)
+               #print(chitest)
+                       }
+                   }
+               }   
+           }
+        chicroise
+    }
+    chicroise <- dochicroise(croise, mincl)
+    print('fin croise')
        #print(chicroise)
        #determination des chi2 les plus fort
        chicroiseori<-chicroise
-       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
-       }
+
+    doxy <- function(chicroise) {
+        listx <- NULL
+        listy <- NULL
+        listxy <- which(chicroise > 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
+#        #coord <- arrayInd(maxi[i], dim(chicroise))
+#        #x.co <- coord[1,2]
+#        #y.co <- coord[1,1]
+#          x.co<-ceiling(maxi[i]/c.len)
+#          y.co<-maxi[i]-(x.co-1)*c.len
+#        #print(x.co)
+#        #print(y.co)
+#        #print(arrayInd(maxi[i], dim(chicroise)))
+#          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=' ')
@@ -191,75 +305,172 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
            unique(unlist(chd[chd[,classe%/%2]==classe,]))
        }
 
+
+#----------------------------------------------------------------------
+    findbestcoord <- function(classeuce1, classeuce2) {
+        #fillemere1 <- NULL
+        #fillemere2 <- NULL
+
+        #fillemere1 <- unique(classeuce1)
+        #if (classif_mode == 0) {
+        #    fillemere2 <- unique(classeuce2)
+        #} else {
+        #    fillemere2 <- fillemere1
+        #}
+
+        #
+        listcoordok <- list()
+        maxcl <- 0
+        nb <- 0
+        lf1 <- addallfille(chd1$list_fille) 
+        if (classif_mode == 0) {
+            lf2 <- addallfille(chd2$list_fille)
+        } else {
+            lf2 <- lf1
+        }
+        lme1 <- chd1$list_mere
+        if (classif_mode == 0) {
+            lme2 <- chd2$list_mere
+        } else {
+            lme2 <- lme1
+        }
+        for (first in 1:length(listx)) {
+            coordok <- NULL
+            f1 <- NULL
+            f2 <- NULL
+            listxp<-listx
+           listyp<-listy
+            
+           #listxp<-listx[first:length(listx)]
+           #listxp<-c(listxp,listx[1:(first-1)])
+           #listyp<-listy[first:length(listy)]
+           #listyp<-c(listyp,listy[1:(first-1)])
+            listxp <- listxp[order(listx, decreasing = TRUE)]
+            listyp <- listyp[order(listx, decreasing = TRUE)]
+            #listxp<-c(listxp[first:length(listx)], listx[1:(first-1)])
+            #listyp<-c(listyp[first:length(listy)], listy[1:(first-1)])
+            for (i in 1:length(listx)) {
+                if( (!(listxp[i]+1) %in% f1) & (!(listyp[i]+1) %in% f2) ) {
+                    #print(listyp[i]+1)
+                    #print('not in')
+                    #print(f2)
+                    coordok <- rbind(coordok, c(listyp[i] + 1,listxp[i] + 1))
+                    #print(c(listyp[i] + 1,listxp[i] + 1))
+                    un1 <- getfillemere(lf2, chd2$list_mere, listxp[i] + 1)
+                    f1 <- c(f1, un1)
+                    f1 <- c(f1, listxp[i] + 1)
+                    un2 <- getfillemere(lf1, chd1$list_mere, listyp[i] + 1)
+                    f2 <- c(f2, un2)
+                    f2 <- c(f2, listyp[i] + 1)
+                }
+                #print(coordok)
+            }
+            #if (nrow(coordok) > maxcl) {
+                nb <- 1
+            #    listcoordok <- list()
+                listcoordok[[nb]] <- coordok
+            #    maxcl <- nrow(coordok)
+            #} else if (nrow(coordok) == maxcl) {
+                nb <- nb + 1
+            #    listcoordok[[nb]] <- coordok
+            #}
+        }
+        listcoordok <- unique(listcoordok)
+        print(listcoordok)
+        best <- 1
+        if (length(listcoordok) > 1) {
+            maxchi <- 0
+            for (i in 1:length(listcoordok)) {
+                chi <- NULL
+                uce <- NULL
+                for (j in 1:nrow(listcoordok[[i]])) {
+                    chi<-c(chi,croise[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+                    uce<-c(uce,chicroiseori[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+                }
+               if (maxchi < sum(chi)) {
+                   maxchi <- sum(chi)
+                   suce <- sum(uce)
+                   best <- i
+               }
+            }
+        print(suce/nrow(classeuce1))
+        }
+        listcoordok[[best]]
+    }
+#---------------------------------------------------------------------------------   
        #pour trouver une valeur dans une liste
        #is.element(elem, list)
        #== elem%in%list
-
-       coordok<-NULL
-       trouvecoordok<-function(first) {
-           fillemere1<-NULL
-           fillemere2<-NULL
-           listxp<-listx
-           listyp<-listy
-           listxp<-listx[first:length(listx)]
-           listxp<-c(listxp,listx[1:(first-1)])
-       #    listxp<-listxp[-first]
-           listyp<-listy[first:length(listy)]
-           listyp<-c(listyp,listy[1:(first-1)])
-       #    listyp<-listyp[-first]
-           for (i in 1:length(listxp)) {
-              if (!(listxp[i]+1)%in%fillemere1) {
-                 if (!(listyp[i]+1)%in%fillemere2) {
-                 coordok<-rbind(coordok,c(listyp[i]+1,listxp[i]+1))
-                 fillemere1<-c(fillemere1,trouvefillemere(listxp[i]+1,chd2$n1))
-                 fillemere2<-c(fillemere2,trouvefillemere(listyp[i]+1,chd1$n1))
-                 }
-              }
-           }
+    oldfindbestcoord <- function(listx, listy) {
+       coordok<-NULL
+       trouvecoordok<-function(first) {
+           fillemere1<-NULL
+           fillemere2<-NULL
+           listxp<-listx
+           listyp<-listy
+           listxp<-listx[first:length(listx)]
+           listxp<-c(listxp,listx[1:(first-1)])
+           listyp<-listy[first:length(listy)]
+           listyp<-c(listyp,listy[1:(first-1)])
+           for (i in 1:length(listxp)) {
+               if (!(listxp[i]+1)%in%fillemere1) {
+                       if (!(listyp[i]+1)%in%fillemere2) {
+                           coordok<-rbind(coordok,c(listyp[i]+1,listxp[i]+1))
+                           fillemere1<-c(fillemere1,trouvefillemere(listxp[i]+1,chd2$n1))
+                           fillemere2<-c(fillemere2,trouvefillemere(listyp[i]+1,chd1$n1))
+                       }
+              }
+           }
+           coordok
+       }
+    #fonction pour trouver le nombre maximum de classes
+       findmaxclasse<-function(listx,listy) {
+           listcoordok<-list()
+           maxcl<-0
+           nb<-1
+           for (i in 1:length(listy)) {
+                       coordok<-trouvecoordok(i)
+                       if (maxcl <= nrow(coordok)) {
+                           maxcl<-nrow(coordok)
+                           listcoordok[[nb]]<-coordok
+                           nb<-nb+1
+                       }
+           }
+           listcoordok<-unique(listcoordok)
+            print(listcoordok)
+               #si plusieurs ensemble avec le meme nombre de classe, on conserve
+               #la liste avec le plus fort chi2
+           if (length(listcoordok)>1) {
+                   maxchi<-0
+                   best<-NULL
+                   for (i in 1:length(listcoordok)) {
+                       chi<-NULL
+                       uce<-NULL
+                       if (nrow(listcoordok[[i]])==maxcl) {
+                           for (j in 1:nrow(listcoordok[[i]])) {
+                               chi<-c(chi,croise[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+                               uce<-c(uce,chicroiseori[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
+                           }
+                           if (maxchi < sum(chi)) {
+                               maxchi <- sum(chi)
+                               suce <- sum(uce)
+                               best <- i
+                           } 
+                       }
+                   }
+           }
+           print((maxchi/nrow(classeuce1)*100))
+           listcoordok[[best]]
+       }
+        print('cherche max')
+           coordok<-findmaxclasse(listx,listy)
            coordok
-       }
-#fonction pour trouver le nombre maximum de classes
-       findmaxclasse<-function(listx,listy) {
-           listcoordok<-list()
-           maxcl<-0
-           nb<-1
-           for (i in 1:length(listy)) {
-                       coordok<-trouvecoordok(i)
-                       if (maxcl <= nrow(coordok)) {
-                           maxcl<-nrow(coordok)
-                           listcoordok[[nb]]<-coordok
-                           nb<-nb+1
-                       }
-           }
-           listcoordok<-unique(listcoordok)
-               #si plusieurs ensemble avec le meme nombre de classe, on conserve
-               #la liste avec le plus fort chi2
-           if (length(listcoordok)>1) {
-               maxchi<-0
-               best<-NULL
-               for (i in 1:length(listcoordok)) {
-                   chi<-NULL
-                   uce<-NULL
-                   if (nrow(listcoordok[[i]])==maxcl) {
-                       for (j in 1:nrow(listcoordok[[i]])) {
-                           chi<-c(chi,croise[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
-                           uce<-c(uce,chicroiseori[(listcoordok[[i]][j,1]-1),(listcoordok[[i]][j,2]-1)])
-                       }
-                       if (maxchi < sum(chi)) {
-                           maxchi<-sum(chi)
-                           suce<-sum(uce)
-                           best<-i
-                       } 
-                   }
-               }
-           }
-           print((suce/nrow(classeuce1)*100))
-           listcoordok[[best]]
-       }
+    }
        #findmaxclasse(listx,listy)
        #coordok<-trouvecoordok(1)
-       coordok<-findmaxclasse(listx,listy)
-       print(coordok)
+    #coordok <- oldfindbestcoord(listx, listy)
+    coordok <- findbestcoord(listx, listy)
+
 
        lfilletot<-function(classeuce,x) {
            listfille<-NULL
@@ -268,7 +479,7 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
                        listfille
            }
        }
-
+    print('listfille')
        listfille1<-lfilletot(classeuce1,1)
        listfille2<-lfilletot(classeuce2,2)
 
@@ -284,27 +495,17 @@ Rchdtxt<-function(uceout,mincl=0,classif_mode=0, nbt = 9) {
        }
        print('commence assigne new classe')
        nchd1<-Assignclasse(classeuce1,1)
-       if (classif_mode==0)
+       if (classif_mode==0) {
                nchd2<-Assignclasse(classeuce2,2)
-       else
+       } else {
                nchd2<-nchd1
+    }
        print('fini assign new classe')
        #croisep<-matrix(ncol=nrow(coordok),nrow=nrow(coordok))
     nchd2[which(nchd1[,ncol(nchd1)]==0),] <- 0
     nchd2[which(nchd1[,ncol(nchd1)]!=nchd2[,ncol(nchd2)]),] <- 0
     nchd1[which(nchd2[,ncol(nchd2)]==0),] <- 0
 
-#      for (i in 1:nrow(nchd1)) {
-#          if (nchd1[i,ncol(nchd1)]==0) {
-#              nchd2[i,]<-nchd2[i,]*0
-#          }
-#          if (nchd1[i,ncol(nchd1)]!=nchd2[i,ncol(nchd2)]) {
-#              nchd2[i,]<-nchd2[i,]*0
-#          }
-#          if (nchd2[i,ncol(nchd2)]==0) {
-#              nchd1[i,]<-nchd1[i,]*0
-#          }
-#      }
        print('fini croise')
        elim<-which(nchd1[,ncol(nchd1)]==0)
        keep<-which(nchd1[,ncol(nchd1)]!=0)
index 98bacf7..a582ec2 100644 (file)
@@ -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,27 +122,36 @@ 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 {
+            invw <- 1 - weori
+        }
                E(g1)$weight<-invw
                g.max<-minimum.spanning.tree(g1)
-               E(g.max)$weight<-1/E(g.max)$weight
+        if (method == 'cooc') {
+                   E(g.max)$weight<-1 / E(g.max)$weight
+        } else {
+            E(g.max)$weight<-1 - E(g.max)$weight
+        }
                g.toplot<-g.max
        }
 
     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 +196,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 +263,23 @@ 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 {
+            if (graph.simi$halo) {
+                mark.groups <- communities(graph.simi$com)
+            } else {
+                mark.groups <- NULL
+            }
+            plot(com, g.toplot,vertex.label='', edge.width=we.width, vertex.size=vertex.size, vertex.color=vertex.col, vertex.label.color='white', edge.label=we.label, edge.label.cex=cex, edge.color=edge.col, vertex.label.cex = 0, layout=lo, mark.groups = mark.groups)
+        }
         #txt.layout <- lo
         txt.layout <- layout.norm(lo, -1, 1, -1, 1, -1, 1)
         #txt.layout <- txt.layout[order(label.cex),]
@@ -271,10 +311,12 @@ plot.simi <- function(graph.simi, p.type = 'tkplot',filename=NULL, vertex.col =
                library('rgl')
         #rgl.open()
         #par3d(cex=0.8)
-               rglplot(g.toplot,vertex.label= vire.nonascii(v.label), edge.width=we.width/10, vertex.size=0.01, vertex.color=vertex.col, vertex.label.color="black", edge.color = edge.col, layout=lo)
-        los <- layout.norm(lo, -1, 1, -1, 1, -1, 1)
-        rgl.spheres(los, col = vertex.col, radius = vertex.size/100, alpha = alpha)
-               rgl.bg(color = c('white','black'))
+        lo <- layout.norm(lo, -10, 10, -10, 10, -10, 10)
+               rglplot(g.toplot,vertex.label='', edge.width=we.width/10, vertex.size=0.01, vertex.color=vertex.col, vertex.label.color="black", edge.color = edge.col, layout=lo, rescale = FALSE)
+        #los <- layout.norm(lo, -1, 1, -1, 1, -1, 1)
+               text3d(lo[,1], lo[,2], lo[,3], vire.nonascii(v.label), col = vertex.label.color, alpha = 1, cex = vertex.label.cex)
+        rgl.spheres(lo, col = vertex.col, radius = vertex.size/100, alpha = alpha)
+        rgl.bg(color = c('white','black'))
         if (!is.null(movie)) {
             require(tcltk)
             ReturnVal <- tkmessageBox(title="RGL 3 D",message="Cliquez pour commencer le film",icon="info",type="ok")
@@ -297,4 +339,9 @@ graph.word <- function(mat.simi, index) {
     nm[,index] <- mat.simi[,index]
     nm[index,] <- mat.simi[index,]
     nm
+#    cs <- colSums(nm)
+#    if (cs) nm <- nm[,-which(cs==0)]
+#    rs <- rowSums(nm)
+#    if (rs) nm <- nm[-which(rs==0),]
+#    nm
 }
index 1a14c4a..2a3c88d 100644 (file)
@@ -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)
+    
index 4770f6b..2811a7e 100644 (file)
@@ -19,18 +19,19 @@ from time import time
 log = logging.getLogger('iramuteq.analyse')
 
 class AnalyseText :
-    def __init__(self, ira, corpus, parametres = None, dlg = False) :
+    def __init__(self, ira, corpus, parametres = None, dlg = False, lemdial = True) :
         self.corpus = corpus
         self.ira = ira
         self.parent = ira
         self.dlg = dlg
         self.dialok = True
         self.parametres = parametres
+        self.lemdial = lemdial
         self.val = False
         if not 'pathout' in self.parametres :
             self.pathout = PathOut(corpus.parametres['originalpath'], analyse_type = parametres['type'], dirout = corpus.parametres['pathout'])
         else :
-            self.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['name'])
+            self.pathout = PathOut(filename = corpus.parametres['originalpath'], dirout = self.parametres['pathout'], analyse_type = self.parametres['type'])
         self.parametres = self.lemparam()
         if self.parametres is not None :
             self.parametres = self.make_config(parametres)
@@ -77,7 +78,7 @@ class AnalyseText :
         pass
 
     def lemparam(self) :
-        if self.dlg :
+        if self.dlg and self.lemdial:
             dial = StatDialog(self, self.parent)
             dial.CenterOnParent()
             val = dial.ShowModal()
@@ -117,7 +118,7 @@ class AnalyseText :
         log.info('R code...')
         pid = exec_rcode(self.ira.RPath, Rscript, wait = wait)
         while pid.poll() is None :
-            if dlg is not None :
+            if dlg :
                 self.dlg.Pulse(message)
                 sleep(0.2)
             else :
@@ -143,6 +144,7 @@ class Alceste(AnalyseText) :
             self.corpus.make_and_write_sparse_matrix_from_uci(self.actives, self.pathout['TableUc1'], self.pathout['listeuce1'])
         Rscript = self.printRscript()
         self.doR(Rscript, dlg = self.dlg, message = 'CHD...')
+
         self.corpus.make_ucecl_from_R(self.pathout['uce'])
         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)
@@ -174,16 +176,19 @@ class Alceste(AnalyseText) :
             parametres['nbcl_p1'] = self.dial.spin_nbcl.GetValue()
             parametres['max_actives'] = self.dial.spin_max_actives.GetValue()
             parametres['corpus'] = ''
+            parametres['svdmethod'] = self.dial.svdmethod[self.dial.choicesvd.GetSelection()]
             parametres['pathout'] = self.pathout.dirout
+            parametres['mode.patate'] = self.dial.check_patate.GetValue()
             DoConf(self.parent.ConfigPath['alceste']).makeoptions(['ALCESTE'], [parametres])
             self.dial.Destroy()
+            print parametres
             return parametres
         else :
             self.dial.Destroy()
             return None
 
     def printRscript(self) :
-        RchdTxt(self.pathout, self.parent.RscriptsPath, self.parametres['mincl'], self.parametres['classif_mode'], nbt = self.parametres['nbcl_p1'] - 1, libsvdc = self.parent.pref.getboolean('iramuteq','libsvdc'), libsvdc_path = self.parent.pref.get('iramuteq','libsvdc_path'), R_max_mem = False)
+        RchdTxt(self.pathout, self.parent.RscriptsPath, self.parametres['mincl'], self.parametres['classif_mode'], nbt = self.parametres['nbcl_p1'] - 1, svdmethod = self.parametres['svdmethod'], libsvdc = self.parent.pref.getboolean('iramuteq','libsvdc'), libsvdc_path = self.parent.pref.get('iramuteq','libsvdc_path'), R_max_mem = False, mode_patate = self.parametres['mode.patate'])
         return self.pathout['Rchdtxt']
 
     def printRscript2(self) :
index 385eb27..927f847 100644 (file)
@@ -137,7 +137,7 @@ def install_textometrieR(self) :
     dlg.Destroy()
 
 def CheckRPackages(self):
-    listdep = ['ca', 'gee', 'ape', 'igraph','proxy', 'wordcloud', 'textometrieR']
+    listdep = ['ca', 'gee', 'ape', 'igraph','proxy', 'wordcloud', 'irlba', 'textometrieR']
     nolib = []
     i=0
     dlg = wx.ProgressDialog("Test des librairies de R", "test en cours...", maximum = len(listdep), parent=self, style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT)
index b441a32..57e31c9 100644 (file)
@@ -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',
index 42891ff..6b9c954 100644 (file)
@@ -21,6 +21,10 @@ minforme = 2
 expressions = True
 #nbre de classe terminale de la phase 1
 nbcl_p1 = 10
+#methode pour svd
+svdmethod = irlba
+#mode patate (+ rapide et - precis)
+mode.patate = 0
 \r
 [IMAGE]\r
 #non utilise
index 7cc9306..ec27764 100644 (file)
--- a/corpus.py
+++ b/corpus.py
@@ -210,6 +210,28 @@ class Corpus :
     def getucesfrometoile(self, etoile) :
         return [uce.ident for uci in self.ucis for uce in uci.uces if etoile in uci.etoiles]
 
+    def getetoileuces(self) :
+        log.info('get uces etoiles')
+        etoileuces = {}
+        idpara = 0
+        for uci in self.ucis :
+            etoiles = uci.etoiles[1:]
+            for et in etoiles :
+                if et in etoileuces :
+                    etoileuces[et] += [uce.ident for uce in uci.uces]
+                else :
+                    etoileuces[et] = [uce.ident for uce in uci.uces]
+            if uci.paras != [] :
+                for et in uci.paras :
+                    if et in etoileuces :
+                        etoileuces[et] += [uce.ident for uce in uci.uces if uce.para == idpara]
+                    else :
+                        etoileuces[et] = [uce.ident for uce in uci.uces if uce.para == idpara]
+                    idpara += 1
+            else :
+                idpara += 1
+        return etoileuces
+
     def getucefromid(self, uceid) :
         if self.iduces is None : self.make_iduces()
         return self.iduces[uceid]
@@ -259,8 +281,8 @@ class Corpus :
         for uci in self.ucis :
             get = list(set(uci.etoiles).intersection(etoiles))
             if len(get) > 1 :
-                return '2 variables sur la meme ligne'
-            elif get != [] :
+                log.info('2 variables sur une ligne')
+            if get != [] :
                 etuces[etoiles.index(get[0])] += [uce.ident for uce in uci.uces]
         etuces = [set(val) for val in etuces]
         tab = []
@@ -530,7 +552,7 @@ class Corpus :
     def make_etoiles(self) :
         etoiles = set([])
         for uci in self.ucis :
-            etoiles.update(uci.etoiles[1:] + uci.paras)
+            etoiles.update(uci.etoiles[1:])
         return list(etoiles)
 
     def make_etoiles_dict(self) :
@@ -541,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
@@ -564,13 +586,16 @@ class Corpus :
             elif get != [] :
                 etuces[listet.index(get[0])] += [uce.ident for uce in uci.uces]
         return etuces
-            
 
     def make_and_write_profile_et(self, ucecl, fileout) :
         log.info('etoiles/classes')
-        etoiles = self.make_etoiles()
+        etoileuces = self.getetoileuces()
+        etoileuces = dict([[et, etoileuces[et]] for et in etoileuces if len(etoileuces[et]) > 1])
         with open(fileout, 'w') as f :
-            f.write('\n'.join([';'.join([etoile] + [`len(set(self.getucesfrometoile(etoile)).intersection(classe))` for classe in ucecl]) for etoile in etoiles]).encode(self.parametres['syscoding']))
+            f.write('\n'.join([';'.join([et] + [`len(set(etoileuces[et]).intersection(classe))` for classe in ucecl]) for et in etoileuces]).encode(self.parametres['syscoding']))
+        #etoiles = self.make_etoiles()
+        #with open(fileout, 'w') as f :
+        #    f.write('\n'.join([';'.join([etoile] + [`len(set(self.getucesfrometoile(etoile)).intersection(classe))` for classe in ucecl]) for etoile in etoiles]).encode(self.parametres['syscoding']))
 
     def make_colored_corpus(self) :
         ucecl = {}
@@ -1091,7 +1116,6 @@ class BuildFromAlceste(BuildCorpus) :
                                     log.info(u'Empty text : %i' % linenb)
                                     iduci -= 1
                                     self.corpus.ucis.pop()
-                                    #raise Exception("EmptyText %i" % linenb)
                             self.corpus.ucis.append(Uci(iduci, line))
                         if self.dlg is not None :
                             if not (iduci + 1) % 10 :
@@ -1104,19 +1128,24 @@ class BuildFromAlceste(BuildCorpus) :
                             idpara += 1
                             self.corpus.ucis[-1].paras.append(line.split()[0])
                         else :
-                            raise Exception('paragrapheOT')
+                            raise Exception('paragrapheOT %i' % linenb)
                     elif line.strip() != '' and iduci != -1 :
                         txt.append(line)
             if txt != [] and iduci != -1 :
                 iduce, idpara = self.treattxt(txt, iduce, idpara, iduci)
                 del(txt)
             else :
-                raise Exception("EmptyText")
+                if iduci != -1 :
+                    iduci -= 1
+                    self.corpus.ucis.pop()
+                    log.info(Exception("Empty text %i" % linenb))
+                else :
+                    raise Exception('EmptyText %i' % linenb)
             if iduci != -1  and iduce != -1:
                 self.backup_uce()
             else : 
                 log.info(_(u"No Text in corpora. Are you sure of the formatting ?"))
-                raise Exception('TextBeforeTextMark')
+                raise Exception('TextBeforeTextMark %i' % linenb)
         except UnicodeDecodeError :
             raise Exception("CorpusEncoding")
 
index 3a6917a..d918538 100755 (executable)
--- 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
+
index 82b08bd..28d648e 100644 (file)
@@ -212,7 +212,9 @@ class BugDialog(wx.Dialog):
         kwds["style"] = wx.DEFAULT_DIALOG_STYLE
         kwds["size"] = wx.Size(500, 200)
         wx.Dialog.__init__(self, *args, **kwds)
+        self.SetTitle(kwds['title'])
         self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
+        self.text_ctrl_1.SetBackgroundColour('#DDE8EB')
         self.button_1 = wx.Button(self, wx.ID_OK, "")
 
         self.__set_properties()
@@ -221,7 +223,6 @@ class BugDialog(wx.Dialog):
 
     def __set_properties(self):
         # begin wxGlade: MyDialog.__set_properties
-        self.SetTitle("Bug")
         self.SetMinSize(wx.Size(500, 200))
         self.text_ctrl_1.SetMinSize(wx.Size(500, 200))
         
@@ -404,21 +405,41 @@ def decoupercharact(chaine, longueur, longueurOptimale, separateurs = None) :
     # si on a rien trouvé
     return False, chaine.split(), ''
 
+
+exceptions = {'paragrapheOT' : u"Un problème de formatage (présence d'un marqueur de paragraphe (-*) en dehors d'un texte) est survenu à la ligne ",
+              'EmptyText' : u"Texte vide (probablement un problème de formatage du corpus). Le problème est apparu à la ligne ",
+              'CorpusEncoding' : u"Problème d'encodage.",
+              'TextBeforeTextMark' : u"Problème de formatage : du texte avant le premier marqueur de texte (****). Le problème est survenu à la ligne ",
+}
+
 def BugReport(parent, error = None):
     for ch in parent.GetChildren():
         if "<class 'wx._windows.ProgressDialog'>" == str(type(ch)):
             ch.Destroy()   
     excName, exc, excTb = formatExceptionInfo()
     if excName == 'Exception' :
-        txt = 'Message :\n'
+        print exc
+        if len(exc.split()) == 2 :
+            mss, linenb = exc.split()
+            if mss in exceptions :
+                txt = exceptions[mss] + linenb
+            else :
+                txt = exc
+        else :
+            if exc in exceptions :
+                txt = exceptions[mss]
+            else :
+                txt = exc
+        title = "Information"
     else :
         txt = u'            !== BUG ==!       \n'
         txt += u'*************************************\n'
         txt += '\n'.join(excTb).replace('    ', ' ')
         txt += excName + '\n'
-    txt += exc
+        txt += exc
+        title = "Bug"
 
-    dial = BugDialog(parent)
+    dial = BugDialog(parent, **{'title' : title})
     if 'Rerror' in dir(parent) :
         txt += parent.Rerror
         parent.Rerror = ''
@@ -551,19 +572,15 @@ def check_Rresult(parent, pid) :
             except :
                 BugReport(parent)
             return False
-            #except :
-            #    BugReport(parent)
         else :
             return True
     else :
         if pid != 0 :
-            BugReport(parent)
+            try :
+                raise Exception(u'Erreur R')
+            except :
+                BugReport(parent)
             return False
-            #try :
-            #raise Exception(u'Erreur R')
-            #return False
-            #except :
-            #    BugReport(parent)
         else :
             return True
 
index ca8f66c..a12d169 100644 (file)
@@ -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()
index cec02e9..8c000cb 100644 (file)
--- a/iracmd.py
+++ b/iracmd.py
@@ -12,7 +12,7 @@ import locale
 import codecs
 sys.setdefaultencoding(locale.getpreferredencoding())
 from chemins import ConstructConfigPath, ConstructDicoPath, ConstructRscriptsPath
-from functions import ReadLexique, DoConf, History
+from functions import ReadLexique, DoConf, History, ReadDicoAsDico
 from ConfigParser import *
 #######################################
 #from textchdalc import AnalyseAlceste
index d3ae6f3..20db754 100644 (file)
@@ -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
@@ -239,7 +239,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")
@@ -248,12 +248,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') 
@@ -370,7 +370,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)
@@ -421,6 +421,22 @@ class IraFrame(wx.Frame):
         if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
         self.type = ''
 
+##############################################################@
+        self.DisEnSaveTabAs(False)
+        self.ShowMenu(_("View"), False)
+        self.ShowMenu(_("Spreadsheet analysis"), False)
+        self.ShowMenu(_("Text analysis"), False)
+   
+        self._mgr.Update()
+
+        self.DataPop = False
+        self.DataTxt = False
+        self.Text = ''
+
+        self.lexique = None
+        self.corpus = None
+
+    def finish_init(self) :
         try :
             self.pref.read(self.ConfigPath['preferences'])
             if IsNew(self) :
@@ -433,6 +449,9 @@ class IraFrame(wx.Frame):
             UpgradeConf(self)
             self.pref.read(self.ConfigPath['preferences'])
             New = True
+        self.sound = self.pref.getboolean('iramuteq', 'sound')
+        self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
+        self.version = ConfigGlob.get('DEFAULT', 'version')
         #configuration des chemins de R
         self.PathPath = ConfigParser()
         self.PathPath.read(ConfigPath['path'])
@@ -466,21 +485,7 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences."""
             if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
                  evt.Veto()
             dlg.Destroy()
-        self.DataPop = False
-        self.DataTxt = False
-        self.Text = ''
-        self.sound = self.pref.getboolean('iramuteq', 'sound')
-        self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
-        self.version = ConfigGlob.get('DEFAULT', 'version')
-        self.lexique = None
-        self.corpus = None
-##############################################################@
-        self.DisEnSaveTabAs(False)
-        self.ShowMenu(_("View"), False)
-        self.ShowMenu(_("Spreadsheet analysis"), False)
-        self.ShowMenu(_("Text analysis"), False)
-   
-        self._mgr.Update()
+
 
     def OnVerif(self, evt) :
         pack = CheckRPackages(self)
@@ -881,11 +886,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'
@@ -955,23 +960,29 @@ 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 SimiCluster(self, parametres = {}, fromprof = False, pathout = '', listactives = [], actives = [], tableau = None) :
+        DoSimi(self, param = parametres, fromprof =  fromprof, pathout = pathout, listactives = listactives, actives = actives, tableau = tableau)
     
     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):
@@ -1147,6 +1158,7 @@ class MySplashScreen(wx.SplashScreen):
     def ShowMain(self):
         frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(1100, 800))
         frame.Show()
+        frame.finish_init()
         frame.Upgrade()
         frame.OnOpenFromCmdl()
 #        if self.fc.IsRunning():
index 2a30f5c..b2eeb4e 100644 (file)
--- 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
@@ -250,7 +251,7 @@ class GraphPanel(wx.ScrolledWindow):
         self.Dict = dico
         self.txt = txt
         self.parent = parent
-        self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
+        self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD, 0, "courier"))
         self.labels = []
         self.listimg = []
         self.dirout = os.path.dirname(self.Dict['ira'])
@@ -561,11 +562,10 @@ def PrintRapport(self, corpus, parametres, istxt = True):
 
 
 """ % datetime.datetime.now().ctime()
-    print istxt
     if istxt :
         totocc = corpus.gettotocc()
-        txt += u'nombre d\'uci: %i%s' % (corpus.getucinb(), sep)
-        txt += u'nombre d\'uce: %i%s' % (corpus.getucenb(), sep)
+        txt += u'nombre de textes: %i%s' % (corpus.getucinb(), sep)
+        txt += u'nombre de segments de textes: %i%s' % (corpus.getucenb(), sep)
         txt += u'nombre de formes: %i%s' % (len(corpus.formes), sep)
         txt += u'nombre d\'occurrences: %i%s' % (totocc, sep)
         txt += u'moyenne d\'occurrences par forme: %f%s' % (float(totocc) / float(len(self.corpus.formes)), sep)
@@ -575,10 +575,8 @@ def PrintRapport(self, corpus, parametres, istxt = True):
         txt += u'nombre de formes actives de fréquence >= %i: %i%s' % (parametres['eff_min_forme'], parametres['nbactives'], sep)
         txt += u'moyenne d\'occurrences par uce :%f%s' % (float(totocc) / float(corpus.getucenb()), sep)
         if 'tailleuc1' in parametres :
-            if parametres['classif_mode'] != 0 :
-                txt += u'taille uc1 : %i\n' % parametres['tailleuc1']
-            else:
-                txt += u'taille uc1 / uc2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
+            if parametres['classif_mode'] == 0 :
+                txt += u'taille rst1 / rst2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
     else :
         self.Ucenb = self.nbind
         txt += u'nombre d\'individus : %i%s' % (self.nbind, sep)
@@ -586,9 +584,9 @@ def PrintRapport(self, corpus, parametres, istxt = True):
     if istxt :
         txt += u'nombre de classes : %i%s' % (parametres['clnb'], sep)
         if parametres['classif_mode'] == 0 or parametres['classif_mode'] == 1 :
-            txt += u'%i uce classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucenb(), (float(sum([len(cl) for cl in corpus.lc])) / float(corpus.getucenb())) * 100, sep)
+            txt += u'%i segments classés sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucenb(), (float(sum([len(cl) for cl in corpus.lc])) / float(corpus.getucenb())) * 100, sep)
         elif self.parametres['classif_mode'] == 2 :
-            txt += u'%i uci classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucinb(), (float(sum([len(cl) for cl in corpus.lc]))) / float(corpus.getucinb()) * 100, sep)
+            txt += u'%i textes classés sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucinb(), (float(sum([len(cl) for cl in corpus.lc]))) / float(corpus.getucinb()) * 100, sep)
     else :
         txt += u'%i uce classées sur %i (%.2f%%)%s' % (self.ucecla, self.Ucenb, (float(self.ucecla) / float(self.Ucenb)) * 100, sep)
  
@@ -692,12 +690,13 @@ class GraphPanelDendro(wx.Panel):
         self.dirout = os.path.dirname(self.dictpathout['ira'])
         self.list_graph = list_graph
         self.parent = self.GetParent()#parent
-        self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
+        self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
         self.labels = []
         self.listimg = []
         self.tabchd = self.parent.GetParent()
         self.ira = self.tabchd.GetParent()
         self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
+        self.panel_1.SetBackgroundColour('white')
         self.deb = wx.StaticText(self.panel_1, -1, txt)
         dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
         self.butdendro = wx.BitmapButton(self, -1, dendro_img)
@@ -879,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'])
@@ -1001,26 +955,284 @@ 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 <- vertex.label.color
+        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)
+    
+    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 <- vertex.label.color
+        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 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) 
index 2cf40c8..22cf584 100644 (file)
@@ -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
@@ -103,7 +103,7 @@ class OpenAnalyse():
     def openanalyse(self) :
         if self.conf['corpus'] in self.parent.history.openedcorpus :
             log.info('corpus is already opened 2')
-            corpus = self.parent.history.openedcorpus[self.conf['corpus']]
+            corpus = copycorpus(self.parent.history.openedcorpus[self.conf['corpus']])
         else :
             if os.path.exists(self.parent.history.history[self.parent.history.ordercorpus[self.conf['corpus']]]['ira']) :
                 corpus = Corpus(self, parametres = DoConf(self.parent.history.history[self.parent.history.ordercorpus[self.conf['corpus']]]['ira']).getoptions('corpus'), read = self.parent.history.history[self.parent.history.ordercorpus[self.conf['corpus']]]['ira'])
@@ -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)
         
index 03d7a66..4f79e4b 100644 (file)
@@ -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']
index 6010eaa..18864a1 100644 (file)
@@ -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
index 925a1df..4eb42ee 100644 (file)
@@ -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 :
index 06f58e8..1deaa8e 100644 (file)
@@ -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] :
index 8a5ca35..081b2fa 100644 (file)
@@ -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,8 +24,8 @@ from time import sleep
 from uuid import uuid4
 
 
-class DoSimi():
-    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):
+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, tableau = None):
 #------------------------------------------------------------------- 
         self.fromprof = fromprof
         self.wordgraph = wordgraph
@@ -62,119 +64,152 @@ class DoSimi():
                           'keep_coord' : False,
                           'alpha' : 10,
                           'film' : False,
+                          'svg' : 0,
+                          'halo' : 0,
+                          'com' : 0,
+                          'communities' : 0,
                           }
-        self.types = indices_simi
-        if fromprof :
-            self.parent = parent.parent
-            self.Source = parent
-        else :
-            self.parent = parent   
-            self.Source = None
+        self.indices = indices_simi
+        #if fromprof :
+        #    self.parent = parent.parent
+        #    self.Source = parent
+        #else :
+        self.parent = parent   
+        self.Source = None
            
         self.RPath = self.parent.PathPath.get('PATHS', 'rpath')
         if not isopen :
-            if not fromprof :
-                self.tableau = self.parent.tableau
-            else :
+            #if not fromprof :
+            #    self.tableau = self.parent.tableau
+            #else :
+            #    self.tableau = parent.tableau
+            if tableau is not None :
+                self.tableau = tableau
+            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()
+            if not fromprof :
+                dialcol = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Sélectionnez les colonnes", size=(600, 250))
+                dialcol.CenterOnParent()            
+                res = dialcol.ShowModal()
+            else :
+                res = wx.ID_OK
+            if res == wx.ID_OK :
+                if not self.actives :
+                    self.tableau.selected_col = dialcol.list_box_1.GetSelections()
+                    actives = self.tableau.getactlistfromselection(self.tableau.selected_col)
                 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
+                    actives = self.actives
+                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.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 +217,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 +246,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 +263,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.table("%s", sep=';', quote='"')
-                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
-                    """
+#    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+="""
-                label.cex <- NULL
-                """
-            if self.paramsimi.get('sfromchi', False) :
-                txt += """
-                vertex.size <- norm.vec(toblack, minmaxeff[1], minmaxeff[2])
-                """
-            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 +314,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) 
index 5ff4c37..de0f181 100644 (file)
@@ -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()
index c7fc133..07818e2 100644 (file)
@@ -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'
         
 
 
index 8650be1..0dfaea7 100644 (file)
@@ -52,11 +52,16 @@ class SimiTxt(AnalyseText):
                 log.info('Problem')
                 return False
             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)
         else : 
             return False
@@ -108,6 +113,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)
@@ -121,14 +130,12 @@ class SimiTxt(AnalyseText):
         with open(self.pathout['actives.csv'], 'w') as f :
             f.write('\n'.join(self.actives).encode(self.ira.syscoding))
 
-
-
 class SimiFromCluster(SimiTxt) :
     def __init__(self, ira, corpus, actives, numcluster, parametres = None, dlg = False) :
         self.actives = actives
         self.numcluster = numcluster
         parametres['name'] = 'simi_classe_%i' % (numcluster + 1)
-        SimiTxt.__init__(self, ira, corpus, parametres, dlg)
+        SimiTxt.__init__(self, ira, corpus, parametres, dlg, lemdial = False)
     
     def preferences(self) :
         return self.parametres
@@ -161,11 +168,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 = 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
@@ -177,169 +189,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)
index afc9ff1..2618c51 100644 (file)
@@ -81,12 +81,17 @@ class Stat(AnalyseText) :
         txt = """
         source("%s")
         tot <- read.csv2("%s", header = FALSE, row.names = 1)
-        hapax <- read.csv2("%s", header = FALSE, row.names = 1)
-        tot <- rbind(tot, hapax)
+        """ % (self.parent.RscriptsPath['Rgraph'], self.pathout['total.csv'])
+        if len(hapax) :
+            txt += """
+            hapax <- read.csv2("%s", header = FALSE, row.names = 1)
+            tot <- rbind(tot, hapax)
+            """ % self.pathout['hapax.csv']
+        txt += """
         open_file_graph("%s", width = 400, height = 400)
         plot(log(tot[,1]), log = 'x', xlab='log(rangs)', ylab = 'log(frequences)', col = 'red', pch=16)
         dev.off()
-        """ % (self.parent.RscriptsPath['Rgraph'], self.pathout['total.csv'], self.pathout['hapax.csv'], self.pathout['zipf.png'])
+        """ % (self.pathout['zipf.png'])
         tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
         with open(tmpscript, 'w') as f :
             f.write(txt)
diff --git a/tree.py b/tree.py
index e9ab091..07576de 100644 (file)
--- 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())