AFC
[iramuteq] / PrintRScript.py
index 1bb0af1..36fd860 100644 (file)
@@ -148,8 +148,9 @@ 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, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
+    chd1<-CHD(data1, x = nbt, mode.patate = TRUE, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
     """
     
     if classif_mode == 0:
@@ -417,6 +418,9 @@ def write_afc_graph(self):
     if self.param['do_select_chi'] : do_select_chi = 'TRUE'
     else : do_select_chi = 'FALSE'
 
+    if self.param['do_select_chi_classe'] : do_select_chi_classe = 'TRUE'
+    else : do_select_chi_classe = 'FALSE'
+
     if self.param['cex_txt'] : cex_txt = 'TRUE'
     else : cex_txt = 'FALSE'
 
@@ -438,6 +442,8 @@ def write_afc_graph(self):
     self.param['select_nb'],  \
     do_select_chi, \
     self.param['select_chi'], \
+    do_select_chi_classe, \
+    self.param['nbchic'], \
     cex_txt, \
     self.param['txt_min'], \
     self.param['txt_max'], \
@@ -460,10 +466,12 @@ def print_simi3d(self):
         movie = "'" + ffr(os.path.dirname(self.DictPathOut['RData'])) + "'"
     else :
         movie = 'NULL'
-    if self.section == 'chd_dist_quest' :
-        header = 'TRUE'
-    else :
-        header = 'FALSE'
+    
+    #if self.corpus.parametres['type'] == 'corpus' :
+    #    header = 'TRUE'
+    #else :
+    #    header = 'FALSE'
+    header = 'FALSE'
     txt += """
     dm<-read.csv2("%s",row.names=1,header = %s)
     load("%s")
@@ -781,7 +789,8 @@ class PrintSimiScript(PrintRScript) :
             txt += """
             et <- list()
             """
-            for i,et in enumerate(self.tableau.etline) :
+            print self.parametres
+            for i,et in enumerate(self.parametres['stars']) :
                 txt+= """
                 et[[%i]] <- c(%s)
                 """ % (i+1, ','.join(et[1:]))
@@ -919,12 +928,17 @@ class WordCloudRScript(PrintRScript) :
         txt = """
         act <- read.csv2("%s", header = FALSE, row.names=1, sep='\t')
         selected.col <- read.table("%s")
-        toprint <- act[selected.col[,1] + 1,]
+        toprint <- as.matrix(act[selected.col[,1] + 1,])
+        rownames(toprint) <- rownames(act)[selected.col[,1] + 1]
+        maxword <- %i
+        if (nrow(toprint) > maxword) {
+            toprint <- as.matrix(toprint[order(toprint[,1], decreasing=TRUE),])
+            toprint <- as.matrix(toprint[1:maxword,])
+        }
         open_file_graph("%s", width = %i, height = %i)
         par(bg=rgb%s)
         wordcloud(row.names(toprint), toprint[,1], scale=c(%f,%f), random.order=FALSE, colors=rgb%s)
         dev.off()
-        """ % (ffr(self.analyse.pathout['actives_eff.csv']), ffr(self.analyse.pathout['selected.csv']),
-                ffr(self.parametres['graphout']), self.parametres['width'], self.parametres['height'], bg_col, self.parametres['maxcex'], self.parametres['mincex'], txt_col)
+        """ % (ffr(self.analyse.pathout['actives_eff.csv']), ffr(self.analyse.pathout['selected.csv']), self.parametres['maxword'], ffr(self.parametres['graphout']), self.parametres['width'], self.parametres['height'], bg_col, self.parametres['maxcex'], self.parametres['mincex'], txt_col)
         self.add(txt)
         self.write()