From 208fc7cb65f13b9d4fa6f29b7d3933d534aa10b9 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 4 Nov 2014 01:25:19 +0100 Subject: [PATCH] ... --- PrintRScript.py | 56 ++++++++++++++++++++++++++++---------------------------- layout.py | 2 +- tabchdalc.py | 28 ++++++++++++++-------------- textaslexico.py | 22 +++++++++++----------- textstat.py | 8 ++++---- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/PrintRScript.py b/PrintRScript.py index 90a4398..7f7e4c2 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -115,7 +115,7 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv source("%s") source("%s") source("%s") - """ % (RscriptPath['CHD'], RscriptPath['chdtxt'], RscriptPath['anacor'], RscriptPath['Rgraph']) + """ % (ffr(RscriptPath['CHD']), ffr(RscriptPath['chdtxt']), ffr(RscriptPath['anacor']), ffr(RscriptPath['Rgraph'])) if R_max_mem : txt += """ memory.limit(%i) @@ -153,14 +153,14 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv data1 <- readMM("%s") data1 <- as(data1, "dgCMatrix") row.names(data1) <- 1:nrow(data1) - """ % DicoPath['TableUc1'] + """ % ffr(DicoPath['TableUc1']) if classif_mode == 0: txt += """ data2 <- readMM("%s") data2 <- as(data2, "dgCMatrix") row.names(data2) <- 1:nrow(data2) - """ % DicoPath['TableUc2'] + """ % ffr(DicoPath['TableUc2']) txt += """ chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path) """ @@ -173,12 +173,12 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv txt += """ #lecture des uce listuce1<-read.csv2("%s") - """ % DicoPath['listeuce1'] + """ % ffr(DicoPath['listeuce1']) if classif_mode == 0: txt += """ listuce2<-read.csv2("%s") - """ % DicoPath['listeuce2'] + """ % ffr(DicoPath['listeuce2']) txt += """ rm(data1) @@ -202,14 +202,14 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv classes<-n1[,ncol(n1)] write.csv2(n1, file="%s") rm(n1) - """ % (classif_mode, mincl, DicoPath['uce'], DicoPath['n1.csv']) + """ % (classif_mode, mincl, ffr(DicoPath['uce']), ffr(DicoPath['n1.csv'])) txt += """ tree.tot1 <- make_tree_tot(chd1) # open_file_graph("%s", widt = 600, height=400) # plot(tree.tot1$tree.cl) # dev.off() - """ % DicoPath['arbre1'] + """ % ffr(DicoPath['arbre1']) if classif_mode == 0: txt += """ @@ -218,7 +218,7 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv # open_file_graph("%s", width = 600, height=400) # plot(tree.tot2$tree.cl) # dev.off() - """ % DicoPath['arbre2'] + """ % ffr(DicoPath['arbre2'] ) txt += """ tree.cut1 <- make_dendro_cut_tuple(tree.tot1$dendro_tuple, chd.result$coord_ok, classeuce1, 1, nbt) @@ -229,7 +229,7 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv open_file_graph("%s", width = 600, height=400) plot(tree.cut1$dendro_tot_cl) dev.off() - """ % (DicoPath['Rdendro'], DicoPath['dendro1'], DicoPath['arbre1']) + """ % (ffr(DicoPath['Rdendro']), ffr(DicoPath['dendro1']), ffr(DicoPath['arbre1'])) if classif_mode == 0: txt += """ @@ -240,12 +240,12 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv open_file_graph("%s", width = 600, height=400) plot(tree.cut1$dendro_tot_cl) dev.off() - """ % (DicoPath['dendro2'], DicoPath['arbre2']) + """ % (ffr(DicoPath['dendro2']), ffr(DicoPath['arbre2'])) txt += """ #save.image(file="%s") - """ % (DicoPath['RData']) + """ % (ffr(DicoPath['RData'])) fileout = open(DicoPath['Rchdtxt'], 'w') fileout.write(txt) @@ -283,7 +283,7 @@ def RchdQuest(DicoPath, RscriptPath, nbcl = 10, mincl = 10): source("%s") source("%s") source("%s") - """ % (RscriptPath['CHD'], RscriptPath['chdquest'], RscriptPath['anacor'],RscriptPath['Rgraph']) + """ % (ffr(RscriptPath['CHD']), ffr(RscriptPath['chdquest']), ffr(RscriptPath['anacor']),ffr(RscriptPath['Rgraph'])) txt += """ nbt <- %i - 1 @@ -294,14 +294,14 @@ def RchdQuest(DicoPath, RscriptPath, nbcl = 10, mincl = 10): chd.result<-Rchdquest("%s","%s","%s", nbt = nbt, mincl = mincl) n1 <- chd.result$n1 classeuce1 <- chd.result$cuce1 - """ % (DicoPath['mat01.csv'], DicoPath['listeuce1'], DicoPath['uce']) + """ % (ffr(DicoPath['mat01.csv']), ffr(DicoPath['listeuce1']), ffr(DicoPath['uce'])) txt += """ tree_tot1 <- make_tree_tot(chd.result$chd) open_file_graph("%s", width = 600, height=400) plot(tree_tot1$tree.cl) dev.off() - """%DicoPath['arbre1'] + """ % ffr(DicoPath['arbre1']) txt += """ tree_cut1 <- make_dendro_cut_tuple(tree_tot1$dendro_tuple, chd.result$coord_ok, classeuce1, 1, nbt) @@ -310,11 +310,11 @@ def RchdQuest(DicoPath, RscriptPath, nbcl = 10, mincl = 10): open_file_graph("%s", width = 600, height=400) classes<-n1[,ncol(n1)] plot.dendropr(tree_cut1$tree.cl,classes, histo = TRUE) - """ % (DicoPath['Rdendro'],DicoPath['dendro1']) + """ % (ffr(DicoPath['Rdendro']), ffr(DicoPath['dendro1'])) txt += """ save.image(file="%s") - """ % DicoPath['RData'] + """ % ffr(DicoPath['RData']) fileout = open(DicoPath['Rchdquest'], 'w') fileout.write(txt) fileout.close() @@ -325,12 +325,12 @@ def AlcesteTxtProf(DictChdTxtOut, RscriptsPath, clnb, taillecar): source("%s") #load("%s") n1 <- read.csv2("%s") -""" % (RscriptsPath['chdfunct'], DictChdTxtOut['RData'], DictChdTxtOut['n1.csv']) +""" % (ffr(RscriptsPath['chdfunct']), ffr(DictChdTxtOut['RData']), ffr(DictChdTxtOut['n1.csv'])) txt += """ dataact<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA') datasup<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA') dataet<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA') -""" % (DictChdTxtOut['Contout'], DictChdTxtOut['ContSupOut'], DictChdTxtOut['ContEtOut']) +""" % (ffr(DictChdTxtOut['Contout']), ffr(DictChdTxtOut['ContSupOut']), ffr(DictChdTxtOut['ContEtOut'])) txt += """ tablesqrpact<-BuildProf(as.matrix(dataact),n1,clnb) tablesqrpsup<-BuildProf(as.matrix(datasup),n1,clnb) @@ -338,7 +338,7 @@ tablesqrpet<-BuildProf(as.matrix(dataet),n1,clnb) """ txt += """ PrintProfile(n1,tablesqrpact[4],tablesqrpet[4],tablesqrpact[5],tablesqrpet[5],clnb,"%s","%s",tablesqrpsup[4],tablesqrpsup[5]) -""" % (DictChdTxtOut['PROFILE_OUT'], DictChdTxtOut['ANTIPRO_OUT']) +""" % (ffr(DictChdTxtOut['PROFILE_OUT']), ffr(DictChdTxtOut['ANTIPRO_OUT'])) txt += """ colnames(tablesqrpact[[2]])<-paste('classe',1:clnb,sep=' ') colnames(tablesqrpact[[1]])<-paste('classe',1:clnb,sep=' ') @@ -355,7 +355,7 @@ write.csv2(chistabletot,file="%s") write.csv2(ptabletot,file="%s") gbcluster<-n1 write.csv2(gbcluster,file="%s") -""" % (DictChdTxtOut['chisqtable'], DictChdTxtOut['ptable'], DictChdTxtOut['SbyClasseOut']) +""" % (ffr(DictChdTxtOut['chisqtable']), ffr(DictChdTxtOut['ptable']), ffr(DictChdTxtOut['SbyClasseOut'])) if clnb > 2 : txt += """ library(ca) @@ -375,7 +375,7 @@ write.csv2(gbcluster,file="%s") #FIXME : split this!!! txt += """ source("%s") - """ % RscriptsPath['Rgraph'] + """ % ffr(RscriptsPath['Rgraph']) txt += """ afc <- summary.ca.dm(afc) @@ -383,25 +383,25 @@ write.csv2(gbcluster,file="%s") write.csv2(afc_table$facteur, file = "%s") write.csv2(afc_table$colonne, file = "%s") write.csv2(afc_table$ligne, file = "%s") - """ % (DictChdTxtOut['afc_facteur'], DictChdTxtOut['afc_col'], DictChdTxtOut['afc_row']) + """ % (ffr(DictChdTxtOut['afc_facteur']), ffr(DictChdTxtOut['afc_col']), ffr(DictChdTxtOut['afc_row'])) txt += """ PARCEX<-%s """ % taillecar txt += """ xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) - """ % (DictChdTxtOut['AFC2DL_OUT']) + """ % (ffr(DictChdTxtOut['AFC2DL_OUT'])) txt += """ 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], active=FALSE) - """ % (DictChdTxtOut['AFC2DSL_OUT']) + """ % (ffr(DictChdTxtOut['AFC2DSL_OUT'])) txt += """ if ((fin - debet) > 2) { 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], active = FALSE) } - """ % (DictChdTxtOut['AFC2DEL_OUT']) + """ % (ffr(DictChdTxtOut['AFC2DEL_OUT'])) txt += """ 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], active=FALSE) - """ % (DictChdTxtOut['AFC2DCL_OUT']) + """ % (ffr(DictChdTxtOut['AFC2DCL_OUT'])) # txt += """ # PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=1, fin=(debsup-1), xlab = xlab, ylab = ylab) # PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab) @@ -417,7 +417,7 @@ rm(tablesqrpact) rm(tablesqrpsup) rm(tablesqrpet) save.image(file="%s") -""" % DictChdTxtOut['RData'] +""" % ffr(DictChdTxtOut['RData']) file = open(DictChdTxtOut['RTxtProfGraph'], 'w') file.write(txt) file.close() @@ -449,7 +449,7 @@ def write_afc_graph(self): txt = f.read() # self.DictPathOut['RData'], \ - scripts = txt % (self.RscriptsPath['Rgraph'],\ + scripts = txt % (ffr(self.RscriptsPath['Rgraph']),\ self.param['typegraph'], \ self.param['what'], \ self.param['facteur'][0],\ diff --git a/layout.py b/layout.py index 829d6ae..a4834dd 100644 --- a/layout.py +++ b/layout.py @@ -206,7 +206,7 @@ class GraphPanelAfc(wx.Panel): self.RscriptsPath = self.ira.RscriptsPath txt = """ load("%s") - """ % self.DictPathOut['RData'] + """ % ffr(self.DictPathOut['RData']) if self.itempath == 'liste_graph_afcf' : txt += """ afc <- afcf diff --git a/tabchdalc.py b/tabchdalc.py index 2b101dc..ce05833 100644 --- a/tabchdalc.py +++ b/tabchdalc.py @@ -134,16 +134,16 @@ class AnalyseQuest(AnalyseMatrix): txt = '' txt += """ source("%s") - """ % self.parent.RscriptsPath['chdfunct'] + """ % ffr(self.parent.RscriptsPath['chdfunct']) txt += """ load("%s") - """ % self.pathout['RData'] + """ % ffr(self.pathout['RData']) txt += """ dataact<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA') - """ % self.pathout['Contout'] + """ % ffr(self.pathout['Contout']) txt += """ dataet<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA') - """ % self.pathout['ContEtOut'] + """ % ffr(self.pathout['ContEtOut']) txt += """ clnb<-%i """ % self.clnb @@ -151,7 +151,7 @@ class AnalyseQuest(AnalyseMatrix): tablesqrpact<-BuildProf(as.matrix(dataact),n1,clnb) tablesqrpet<-BuildProf(as.matrix(dataet),n1,clnb) PrintProfile(n1,tablesqrpact[4],tablesqrpet[4],tablesqrpact[5],tablesqrpet[5],%i,"%s","%s") - """ % (self.clnb, self.pathout['PROFILE_OUT'], self.pathout['ANTIPRO_OUT']) + """ % (self.clnb, ffr(self.pathout['PROFILE_OUT']), ffr(self.pathout['ANTIPRO_OUT'])) txt += """ colnames(tablesqrpact[[2]])<-paste('classe',1:clnb,sep=' ') colnames(tablesqrpact[[1]])<-paste('classe',1:clnb,sep=' ') @@ -161,13 +161,13 @@ class AnalyseQuest(AnalyseMatrix): ptabletot<-rbind(as.data.frame(tablesqrpact[1]),as.data.frame(tablesqrpet[1])) gbcluster<-n1 write.csv2(chistabletot,file="%s") - """ % self.pathout['chisqtable'] + """ % ffr(self.pathout['chisqtable']) txt += """ write.csv2(ptabletot,file="%s") - """ % self.pathout['ptable'] + """ % ffr(self.pathout['ptable']) txt += """ write.csv2(gbcluster,file="%s") - """ % self.pathout['SbyClasseOut'] + """ % ffr(self.pathout['SbyClasseOut']) if self.clnb > 2 : txt += """ library(ca) @@ -180,7 +180,7 @@ class AnalyseQuest(AnalyseMatrix): fin<-rowtot afc<-AddCorrelationOk(afc) source("%s") - """ % self.parent.RscriptsPath['Rgraph'] + """ % ffr(self.parent.RscriptsPath['Rgraph']) txt += """ afc <- summary.ca.dm(afc) @@ -188,7 +188,7 @@ class AnalyseQuest(AnalyseMatrix): write.csv2(afc_table$facteur, file = "%s") write.csv2(afc_table$colonne, file = "%s") write.csv2(afc_table$ligne, file = "%s") - """ % (self.pathout['afc_facteur'], self.pathout['afc_col'], self.pathout['afc_row']) + """ % (ffr(self.pathout['afc_facteur']), ffr(self.pathout['afc_col']), ffr(self.pathout['afc_row'])) txt += """ xlab <- paste('facteur 1 - ', round(afc$facteur[1,2],2), sep = '') @@ -202,16 +202,16 @@ class AnalyseQuest(AnalyseMatrix): """ % "0.9" txt += """ xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) - """ % (self.pathout['AFC2DL_OUT']) + """ % (ffr(self.pathout['AFC2DL_OUT'])) txt += """ 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.pathout['AFC2DSL_OUT']) + """ % (ffr(self.pathout['AFC2DSL_OUT'])) txt += """ 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.pathout['AFC2DCL_OUT']) + """ % (ffr(self.pathout['AFC2DCL_OUT'])) txt += """ save.image(file="%s") - """ % self.pathout['RData'] + """ % ffr(self.pathout['RData']) tmpfile = tempfile.mktemp(dir=self.parent.TEMPDIR) tmpscript = open(tmpfile, 'w') tmpscript.write(txt) diff --git a/textaslexico.py b/textaslexico.py index bb8e436..b9268de 100644 --- a/textaslexico.py +++ b/textaslexico.py @@ -3,7 +3,7 @@ #Copyright (c) 2008-2011 Pierre Ratinaud #License: GNU/GPL -from chemins import ConstructPathOut, StatTxtPathOut, PathOut +from chemins import ConstructPathOut, StatTxtPathOut, PathOut, ffr #from corpus import Corpus from analysetxt import AnalyseText import wx @@ -40,13 +40,13 @@ class Lexico(AnalyseText) : txt = """ source("%s") source("%s") - """ % (self.parent.RscriptsPath['chdfunct'], self.parent.RscriptsPath['Rgraph']) + """ % (ffr(self.parent.RscriptsPath['chdfunct']), ffr(self.parent.RscriptsPath['Rgraph'])) txt += """ dmf<-read.csv2("%s",row.names=1) - """ % self.dictpathout['tableafcm'] + """ % ffr(self.dictpathout['tableafcm']) txt += """ dmt<-read.csv2("%s",row.names=1) - """ % self.dictpathout['tabletypem'] + """ % ffr(self.dictpathout['tabletypem']) txt += """ indice <- "%s" """ % self.parametres['indice'] @@ -72,21 +72,21 @@ class Lexico(AnalyseText) : banalspec <- specf<-outf[[1]][banal,] banal <- cbind(banalfreq, banalspec) write.csv2(banal,file="%s") - """ % self.pathout['banalites.csv'] + """ % ffr(self.pathout['banalites.csv']) txt += """ specf<-outf[[1]] spect<-outt[[1]] write.csv2(specf,file="%s") - """ % self.dictpathout['tablespecf'] + """ % ffr(self.dictpathout['tablespecf']) txt += """ write.csv2(spect,file="%s") - """ % self.dictpathout['tablespect'] + """ % ffr(self.dictpathout['tablespect']) txt += """ write.csv2(outf[[3]],file="%s") - """ % self.dictpathout['eff_relatif_forme'] + """ % ffr(self.dictpathout['eff_relatif_forme']) txt += """ write.csv2(outt[[3]],file="%s") - """ % self.dictpathout['eff_relatif_type'] + """ % ffr(self.dictpathout['eff_relatif_type']) if self.parametres['clnb'] > 2 : txt += """ library(ca) @@ -133,11 +133,11 @@ class Lexico(AnalyseText) : debsup <- NULL debet <- NULL clnb <- ncol(specf) - """ % (self.dictpathout['afcf_row'], self.dictpathout['afcf_col'], self.dictpathout['afct_row'], self.dictpathout['afct_col'], self.dictpathout['afcf_facteur_csv'], self.dictpathout['afcf_col_csv'], self.dictpathout['afcf_row_csv'], self.dictpathout['afct_facteur_csv'], self.dictpathout['afct_col_csv'], self.dictpathout['afct_row_csv']) + """ % (ffr(self.dictpathout['afcf_row']), ffr(self.dictpathout['afcf_col']), ffr(self.dictpathout['afct_row']), ffr(self.dictpathout['afct_col']), ffr(self.dictpathout['afcf_facteur_csv']), ffr(self.dictpathout['afcf_col_csv']), ffr(self.dictpathout['afcf_row_csv']), ffr(self.dictpathout['afct_facteur_csv']), ffr(self.dictpathout['afct_col_csv']), ffr(self.dictpathout['afct_row_csv'])) txt += """ save.image("%s") - """ % self.dictpathout['RData'] + """ % ffr(self.dictpathout['RData']) tmpfile = tempfile.mktemp(dir=self.parent.TEMPDIR) tmpscript = open(tmpfile, 'w') tmpscript.write(txt) diff --git a/textstat.py b/textstat.py index f8f3735..76ecb40 100644 --- a/textstat.py +++ b/textstat.py @@ -4,7 +4,7 @@ #Copyright (c) 2008-2012 Pierre Ratinaud #License: GNU/GPL -#from chemins import ConstructPathOut, StatTxtPathOut, ffr +from chemins import ffr from chemins import PathOut from analysetxt import AnalyseText #from corpus import Corpus @@ -73,17 +73,17 @@ class Stat(AnalyseText) : txt = """ source("%s") tot <- read.csv2("%s", header = FALSE, row.names = 1) - """ % (self.parent.RscriptsPath['Rgraph'], self.pathout['total.csv']) + """ % (ffr(self.parent.RscriptsPath['Rgraph']), ffr(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'] + """ % ffr(self.pathout['hapax.csv']) txt += """ open_file_graph("%s", width = 400, height = 400) plot(tot[,1], log = 'xy', xlab='log(rangs)', ylab = 'log(frequences)', col = 'red', pch=16) dev.off() - """ % (self.pathout['zipf.png']) + """ % (ffr(self.pathout['zipf.png'])) tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR) with open(tmpscript, 'w') as f : f.write(txt) -- 2.7.4