Révision 1148

tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 1148)
871 871
	public boolean canCompute() {
872 872
		try {
873 873
			return 
874
					this.parent != null
875
					&& this.getLexicalTable().getNColumns() > 3
874
					this.getLexicalTable().getNColumns() > 3
876 875
					&& this.firstDimension > 0
877 876
					&& this.secondDimension > 0
878 877
					&& this.firstDimension != this.secondDimension
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/RCoreMessages.java (revision 1148)
41 41
	public static String info_statisticsEngineLaunched;
42 42
	public static String info_tryingToStartRFrom;
43 43
	public static String info_tryingToStartRWithRPath;
44
	
45
	public static String ExecuteRScript_1;
46
	public static String ExecuteRScript_2;
47
	public static String ExecuteRScript_3;
48
	public static String ExecuteRText_0;
49
	public static String ExecuteRText_1;
50
	public static String ExecuteRText_2;
51
	public static String ExecuteScriptR_0;
52
	public static String ExecuteScriptR_1;	
44 53

  
45 54
	public static String error_unexpectedErrorInRStatisticsEngine;
46 55

  
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages.properties (revision 1148)
28 28
info_statisticsEngineLaunched  = Statistical Engine launched
29 29
info_tryingToStartRFrom        = Try to start R from: {0}...
30 30
info_tryingToStartRWithRPath   = Try to start R with path: 'R'.
31

  
32
ExecuteRScript_1 = Running {0}
33
ExecuteRScript_2 = Done:
34
ExecuteRScript_3 = \ ms
35

  
36
ExecuteRText_0 = Running text selection...
37
ExecuteRText_1 = ** Error while running R script {0}: {1}
38
ExecuteRText_2 = \ ms
39

  
40
ExecuteScriptR_0 = ** {0} R script doesn''t exist
41
ExecuteScriptR_1 = ** Error while Running R script {0}: {1}
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages_ru.properties (revision 1148)
2 2
error_unexpectedErrorInRStatisticsEngine = Неожиданная ошибка в статистической машине R : {0}
3 3

  
4 4
info_tryingToStartRWithRPath = 
5

  
6
ExecuteRScript_1 = \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 
7
ExecuteRScript_2 = \u0413\u043E\u0442\u043E\u0432\u043E: 
8
ExecuteRScript_3 = \ \u043C\u0441
9

  
10
ExecuteRText_0 = \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u044F \u0442\u0435\u043A\u0441\u0442\u0430... 
11
ExecuteRText_1 = ** \u041E\u0448\u0438\u0431\u043A\u0430 \u0432\u043E \u0432\u0440\u0435\u043C\u044F \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F \u0441\u043A\u0440\u0438\u043F\u0442\u0430 R {0}: {1}
12
ExecuteRText_2 = \ \u043C\u0441
13

  
14
ExecuteScriptR_0 = ** \u0424\u0430\u0439\u043B \u0441\u043A\u0440\u0438\u043F\u0442\u0430 R {0} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D
15
ExecuteScriptR_1 = ** \u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0438 \u0441\u043A\u0440\u0438\u043F\u0442\u0430 R {0}: {1}
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages_fr.properties (revision 1148)
28 28
info_statisticsEngineLaunched  = Moteur statistique lancé
29 29
info_tryingToStartRFrom        = Tentative de démarrage de R depuis : {0}...
30 30
info_tryingToStartRWithRPath   = Tentative de démarrage de R depuis le chemin : 'R'.
31

  
32
ExecuteRScript_1 = Exécution de {0}
33
ExecuteRScript_2 = Terminé : 
34
ExecuteRScript_3 = \ ms
35

  
36
ExecuteRText_0 = Exécution de la sélection de texte... 
37
ExecuteRText_1 = ** Erreur lors de l''exécution du script R {0} : {1}
38
ExecuteRText_2 = \ ms
39

  
40
ExecuteScriptR_0 = ** Le fichier de script R {0} n''existe pas
41
ExecuteScriptR_1 = ** Erreur lors de l''exécution du script R {0} : {1}
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RScriptEngine.java (revision 1148)
1
package org.txm.statsengine.r.core;
2

  
3
import java.io.BufferedReader;
4
import java.io.File;
5
import java.io.FileReader;
6
import java.util.HashMap;
7

  
8
import org.eclipse.core.runtime.IProgressMonitor;
9
import org.eclipse.core.runtime.IStatus;
10
import org.eclipse.core.runtime.Status;
11
import org.eclipse.osgi.util.NLS;
12
import org.txm.core.engines.ScriptEngine;
13
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
14
import org.txm.statsengine.r.core.messages.RCoreMessages;
15
import org.txm.utils.logger.Log;
16

  
17
public class RScriptEngine extends ScriptEngine {
18

  
19
	public RScriptEngine() {
20
		super("R");
21
	}
22

  
23
	@Override
24
	public boolean isRunning() {
25
		return true;
26
	}
27

  
28
	@Override
29
	public boolean initialize() throws Exception {
30
		return true;
31
	}
32

  
33
	@Override
34
	public boolean start(IProgressMonitor monitor) throws Exception {
35
		return true;
36
	}
37

  
38
	@Override
39
	public boolean stop() throws Exception {
40
		return true;
41
	}
42
	
43
	/**
44
	 * Execute text.
45
	 *
46
	 * @param text the text
47
	 * @return the object
48
	 */
49
	public IStatus executeText(String text, HashMap<String, Object> env) {
50
		RWorkspace rw = null;
51
		try {
52
			rw = RWorkspace.getRWorkspaceInstance();
53
		} catch (RWorkspaceException e1) {
54
			Log.printStackTrace(e1);
55
			return Status.CANCEL_STATUS;
56
		}
57
		boolean initState = rw.isLogging();
58
		rw.setLog(true);
59

  
60
		try {
61
			System.out.println(RCoreMessages.ExecuteRText_0);
62
			long time = System.currentTimeMillis();
63
			//execute a file line per line
64

  
65
			//String str = rw.userEval(text);//evaluate line in R
66
			rw.eval(text);
67
//			if (str != null && rw.isLogging() && str.length() > 0)
68
//				RConsole.printServer(str);
69
			RWorkspace.appendtoEvalLog(text);
70

  
71
			System.out.println(RCoreMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+RCoreMessages.ExecuteRText_2); 
72
		} catch(Exception e) {
73
			System.out.println(NLS.bind(RCoreMessages.ExecuteRText_1, text, Log.toString(e))); 
74
//			StatusLine.error(NLS.bind(TXMUIMessages.ExecuteRText_1, text, Log.toString(e))); 
75
			Log.printStackTrace(e);
76
		}
77

  
78
		rw.setLog(initState);
79
		return Status.OK_STATUS;
80
	}
81

  
82
	@Override
83
	/**
84
	 * Execute script.
85
	 *
86
	 * @param scriptfile the scriptfile
87
	 */
88
	public IStatus executeScript(File rFile, HashMap<String, Object> env) {
89
		if (!rFile.exists()) {
90
			System.err.println(NLS.bind(RCoreMessages.ExecuteScriptR_0, rFile));
91
			return Status.CANCEL_STATUS;
92
		}
93

  
94
		RWorkspace rw = null;
95
		try {
96
			rw = RWorkspace.getRWorkspaceInstance();
97
		} catch (RWorkspaceException e1) {
98
			Log.printStackTrace(e1);
99
			return Status.CANCEL_STATUS;
100
		}
101
		boolean initState = rw.isLogging();
102
		rw.setLog(true);
103
		try {
104
			System.out.println(NLS.bind(RCoreMessages.ExecuteRScript_1, rFile.getName()));
105
			long time = System.currentTimeMillis();
106
			//execute a file line per line
107

  
108
			//if (TxmPreferences.getBoolean(RPreferencePage.R_REMOTE)) {
109
				BufferedReader reader = new BufferedReader(new FileReader(rFile));// create a file reader
110
				String line = reader.readLine();// read next line
111
				StringBuffer buffer = new StringBuffer();
112
				while (line != null) {
113
					buffer.append(line+"\n"); //$NON-NLS-1$
114
					line = reader.readLine();//read next line
115
				}
116
				
117
				String allScript = buffer.toString();
118
				//if (rw.isLogging() && allScript.length() > 0) RConsole.printUser(allScript);
119

  
120
				//String str = rw.userEval(allScript); // evaluate line in R
121
				rw.eval(allScript);
122
				//if (str != null && rw.isLogging() && str.length() > 0)
123
					//RConsole.printServer(str);
124
				reader.close();
125
//			} else {
126
//				String cmd = "source(\""+rFile.getAbsolutePath().replace("\\", "/")+"\")";
127
//				if (rw.isLogging())
128
//					RConsole.printUser)(cmd);
129
//				String str = rw.userEval(cmd);//evaluate line in R
130
//				if (rw.isLogging() && str.length() > 0)
131
//					RConsole.printServer(cmd);
132
//			}
133
			System.out.println(RCoreMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+RCoreMessages.ExecuteRScript_3);
134
		} catch(Exception e) {
135
			System.out.println(NLS.bind(RCoreMessages.ExecuteScriptR_1, rFile, e)); 
136
			//StatusLine.error(NLS.bind(RCoreMessages.ExecuteScriptR_1, rFile, e)); 
137
			Log.printStackTrace(e);
138
			return Status.CANCEL_STATUS;
139
		} finally {
140
			rw.setLog(initState);
141
		}
142
		
143
		return Status.OK_STATUS;
144
		
145
	}
146
}
0 147

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifities.java (revision 1148)
78 78
				// creating from Subcorpus
79 79
				else if (selection instanceof Subcorpus) {
80 80
					Subcorpus corpus = (Subcorpus) selection;
81
					lexicalTable = new LexicalTable(corpus, corpus.getDefaultProperty());
81
					lexicalTable = new LexicalTable(corpus);
82
					lexicalTable.setUnitProperty(corpus.getDefaultProperty());
82 83
				}
83 84
				// creating from Lexical Table
84 85
				else if (selection instanceof LexicalTable) {
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 1148)
231 231
					partTableColumn.pack();
232 232

  
233 233
					viewerComparator.addSelectionAdapter(viewer, partTableColumn, ++firstPartColumnIndex);
234
					
235 234
				}
236 235
			}
237

  
238 236
			
239
			if(this.getResult().canCompute())	{
237
			if(!this.getResult().isDirty())	{
240 238
				
241 239
				typeFrequencyColumn.setText(TXMCoreMessages.common_frequency + " " + SpecificitiesUIMessages.SpecificitiesTableEditor_11 + " " + this.getResult().getCorpusSize()); //$NON-NLS-1$ //$NON-NLS-2$
242 240
				typeFrequencyColumn.setToolTipText(typeFrequencyColumn.getText()); 
......
263 261
					tableLines[j] = new Object[] { typeNames[j], new Integer(typeFreq[j]), specFreqs[j], specIndex[j] };
264 262
				}
265 263
				viewer.setInput(tableLines);
264
			} else {
265
				viewer.setInput(null);
266 266
			}
267 267

  
268 268
			// Pack the columns so the label of the sort column is not truncated due of the sorting order arrow display			
tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryCooccurrence.java (revision 1148)
104 104
		return nEdges;
105 105
	}
106 106
	
107
	public LexicalTable toLexicalTable() throws RWorkspaceException, CqiClientException {
107
	public LexicalTable toLexicalTable() throws Exception {
108 108
		sendToR();
109 109
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
110 110
		rw.eval("LT<-"+this.getSymbol());
......
113 113
		rw.eval(this.getSymbol()+"LT<-LT");
114 114
		rw.eval("rm(LT)");
115 115
		//TODO: use LexicalTablePreferences fmin 
116
		LexicalTable table = new LexicalTable(corpus, corpus.getProperty("word"), new LexicalTableImpl(this.getSymbol()+"LT"));
116
		LexicalTable table = new LexicalTable(corpus);
117
		table.setUnitProperty(corpus.getProperty("word"));
118
		table.setData(new LexicalTableImpl(this.getSymbol()+"LT"));
117 119
		return table;
118 120
	}
119 121
	
......
174 176
	}
175 177

  
176 178
	@Override
177
	public CA toCA() throws StatException, CqiClientException {
179
	public CA toCA() throws Exception {
178 180
		CQPCorpus corpus = this.getCorpus();
179 181
		Property analysisProperty = null;
180 182
		try {
......
187 189
		int fmin = table.getFMin();
188 190
		
189 191
		CA ca = new CA(table);
190
		
191 192
		return ca;
192 193
	}
193 194

  
tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryAutoCooccurrence.java (revision 1148)
138 138
	}
139 139

  
140 140

  
141
	public LexicalTable toLexicalTable() throws RWorkspaceException, CqiClientException {
141
	public LexicalTable toLexicalTable() throws Exception {
142 142
		sendToR();
143 143
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
144 144
		rw.eval("LT<-"+this.getSymbol());
......
147 147
		rw.eval(this.getSymbol()+"LT<-LT");
148 148
		rw.eval("rm(LT)");
149 149
		//TODO: use Table fmin preference
150
		LexicalTable table = new LexicalTable(corpus, corpus.getProperty("word"), new LexicalTableImpl(this.getSymbol()+"LT"));
150
		LexicalTable table = new LexicalTable(corpus);
151
		table.setUnitProperty(corpus.getProperty("word"));
152
		table.setData(new LexicalTableImpl(this.getSymbol()+"LT"));
151 153
		return table;
152 154
	}
153 155

  
......
242 244
	}
243 245

  
244 246
	@Override
245
	public CA toCA() throws StatException, CqiClientException {
247
	public CA toCA() throws Exception {
246 248
		CQPCorpus corpus = this.getCorpus();
247 249
		Property analysisProperty = null;
248 250
		try {
tmp/org.txm.querycooccurrences.rcp/src/org/txm/links/coocmatrix/toCA.java (revision 1148)
16 16
	 * @throws StatException the stat exception
17 17
	 * @throws CqiClientException 
18 18
	 */
19
	public static CA link(QueryCooccurrence coocs) throws StatException, CqiClientException {
19
	public static CA link(QueryCooccurrence coocs) throws Exception {
20 20
		CQPCorpus corpus = coocs.getCorpus();
21 21
		Property analysisProperty = null;
22 22
		try {
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1148)
96 96
			//org.txm.Toolbox.shutdownSearchEngine();
97 97
			monitor.worked(5);
98 98

  
99
			GSERunner gse = GSERunner.buildDefaultGSE(mainScript);
99
			GSERunner gse = GSERunner.buildDefaultGSE();
100 100

  
101 101
			Binding binding = new Binding();
102 102
			binding.setProperty("projectBinding", project); //$NON-NLS-1$
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GSERunner.java (revision 1148)
38 38
	}
39 39

  
40 40
	protected static GSERunner defaultGSE;
41
	protected static String defaultScriptRootDir = "";
41
	protected static File defaultScriptRootDir;
42 42
	
43 43
	public static void clearDefaultGSE() {
44 44
		defaultGSE = null;
45
		defaultScriptRootDir = "";
45
		defaultScriptRootDir = null;
46 46
	}
47 47
	
48 48
	/**
......
52 52
	 * @param script
53 53
	 * @return
54 54
	 */
55
	public static GSERunner buildDefaultGSE(File script) {
56
		String scriptRootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/").getAbsolutePath();
55
	public static GSERunner buildDefaultGSE() {
56
		File rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/");
57 57
		// check if script root dir was changed
58
		if (defaultScriptRootDir.equals(scriptRootDir) && defaultGSE != null) {
59
			try {
60
				defaultGSE.getGroovyClassLoader().addURL(script.getParentFile().toURI().toURL());
61
			} catch (MalformedURLException e) {
62
				// TODO Auto-generated catch block
63
				e.printStackTrace();
64
			}
58
		if (defaultScriptRootDir.equals(rootDir) && defaultGSE != null) {
59
//			try {
60
//				defaultGSE.getGroovyClassLoader().addURL(rootDir.toURI().toURL());
61
//			} catch (MalformedURLException e) {
62
//				// TODO Auto-generated catch block
63
//				e.printStackTrace();
64
//			}
65 65
			return defaultGSE;
66 66
		}
67 67
		
68
		if (scriptRootDir == null) {
69
			scriptRootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/").getAbsolutePath();
68
		if (rootDir == null) {
69
			rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/");
70 70
		}
71 71
		String[] roots = new String[] { 
72
				scriptRootDir+"/user/", //$NON-NLS-1$
73
				scriptRootDir+"/system/", //$NON-NLS-1$
72
				rootDir.getAbsolutePath()+"/user/", //$NON-NLS-1$
73
				rootDir.getAbsolutePath()+"/system/", //$NON-NLS-1$
74 74
		}; 
75 75

  
76 76
		try {
77
			defaultScriptRootDir = scriptRootDir;
77
			defaultScriptRootDir = rootDir;
78 78
			Log.info("GSE roots: "+Arrays.toString(roots));
79 79
			defaultGSE = new GSERunner(roots);
80 80
		} catch (IOException e) {
......
94 94
		
95 95
		defaultGSE.setConfig(configuration);
96 96
		
97
		File jardir = new File(scriptRootDir,"lib"); //$NON-NLS-1$
97
		File jardir = new File(rootDir, "lib"); //$NON-NLS-1$
98 98
		if (jardir.exists() && jardir.isDirectory()) {
99 99
			for (File f: jardir.listFiles(new FilenameFilter() {
100 100
				@Override
......
111 111
				}
112 112
			}
113 113
		}	
114
		defaultGSE.getGroovyClassLoader().addClasspath(scriptRootDir); // for the .class files if any
114
		defaultGSE.getGroovyClassLoader().addClasspath(rootDir.getAbsolutePath()); // for the .class files if any
115 115
		
116 116
		return defaultGSE;
117 117
	}
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/TXMGroovyScriptEngine.java (revision 1148)
1
package org.txm.groovy.core;
2

  
3
import java.io.File;
4
import java.util.HashMap;
5

  
6
import org.eclipse.core.runtime.IProgressMonitor;
7
import org.eclipse.core.runtime.IStatus;
8
import org.eclipse.core.runtime.Status;
9
import org.txm.core.engines.ScriptEngine;
10

  
11
public class TXMGroovyScriptEngine extends ScriptEngine {
12

  
13
	public TXMGroovyScriptEngine() {
14
		super("groovy");
15
	}
16

  
17
	@Override
18
	public boolean isRunning() {
19
		return GSERunner.defaultGSE != null;
20
	}
21

  
22
	@Override
23
	public boolean initialize() throws Exception {
24
		return GSERunner.buildDefaultGSE() != null;
25
	}
26

  
27
	@Override
28
	public boolean start(IProgressMonitor monitor) throws Exception {
29
		return true;
30
	}
31

  
32
	@Override
33
	public boolean stop() throws Exception {
34
		GSERunner.clearDefaultGSE();
35
		return true;
36
	}
37

  
38
	@Override
39
	public IStatus executeScript(File script, HashMap<String, Object> env) {
40
		return Status.CANCEL_STATUS;
41
	}
42
	
43
	@Override
44
	public IStatus executeText(String text, HashMap<String, Object> env) {
45
		return Status.CANCEL_STATUS;
46
	}
47
}
0 48

  
tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 1148)
729 729
					/ (conc.getLeftContextSize() + conc.getRightContextSize());
730 730
			this.FA = conc.getNLines();
731 731
			corpus = conc.getCorpus();
732
			this.parent = corpus;
733 732
			pQuery = conc.getQuery();
734 733
			// System.out.println("CONC PROPS :"+conc.getViewProperties());
735 734
			pProperties = conc.getKeywordViewProperties();
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/handlers/ComputeAHC.java (revision 1148)
110 110
					fMin = d.getFmin();
111 111
					vMax = d.getMaxLines();
112 112
					
113
					LexicalTable lexicaltable = new LexicalTable(partition, property, fMin, vMax); // use the CAPreferencePage Fmin
114
					ahc = new AHC(new CA(lexicaltable));
113
					LexicalTable lexicalTable = new LexicalTable(partition); // use the CAPreferencePage Fmin
114
					lexicalTable.setParameters(property, fMin, vMax, null);
115
					ahc = new AHC(new CA(lexicalTable));
115 116
				}
116 117
				// canceled
117 118
				else {
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryPart.java (revision 1148)
65 65
		this.structure = structure;
66 66
		this.property = property;
67 67
		this.value = value;
68
		
69
		String tag = structure.getName() + TAG_ATTRIBUTE_SEPARATOR + property.getName();
70
		String label = "a"; //$NON-NLS-1$
71
		StringBuffer query = new StringBuffer();
72
		query.append(REGION_MACRO + START_MACRO_ARGS);
73
		query.append(tag + MACRO_ARGS_SEPARATOR + label + END_MACRO_ARGS);
74
		query.append(START_GLOBAL_CONSTRAINT + label + DOT + tag + EQUALS
75
				+ START_DOUBLE_QUOTE + value + END_DOUBLE_QUOTE);
76
		queryString = query.toString();
68 77
	}
69 78

  
70 79
	/*
......
79 88
	 */
80 89
	@Override
81 90
	public String getQueryString() {
82
		String tag = structure.getName() + TAG_ATTRIBUTE_SEPARATOR + property.getName();
83
		String label = "a"; //$NON-NLS-1$
84
		StringBuffer query = new StringBuffer();
85
		query.append(REGION_MACRO + START_MACRO_ARGS);
86
		query.append(tag + MACRO_ARGS_SEPARATOR + label + END_MACRO_ARGS);
87
		query.append(START_GLOBAL_CONSTRAINT + label + DOT + tag + EQUALS
88
				+ START_DOUBLE_QUOTE + value + END_DOUBLE_QUOTE);
89
		return query.toString();
91
		return queryString;
90 92
		
91 93
		// another way to query parts less restrictif but missleading
92 94
		//return String.format("[_.%s=\"%s\"] expand to %s", tag, value, structure.getName());
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 1148)
1053 1053
		return cql_limit_query;
1054 1054
	}
1055 1055

  
1056
	public List<TXMResult> clearResults() {
1057
		List<TXMResult> old = this.children;
1058
		this.children = new ArrayList<TXMResult>();
1059
		return old;
1060
	}
1056
//	public List<TXMResult> clearResults() {
1057
//		List<TXMResult> old = this.children;
1058
//		this.children = new ArrayList<TXMResult>();
1059
//		return old;
1060
//	}
1061 1061
	
1062
	HashMap<Class, HashSet<Object>> storedData = new HashMap<Class, HashSet<Object>>();
1062
//	HashMap<Class, HashSet<Object>> storedData = new HashMap<Class, HashSet<Object>>();
1063 1063

  
1064 1064
	private StructuralUnit textStructuralUnit;
1065 1065

  
1066 1066
	private StructuralUnitProperty textIdStructuralUnitProperty;
1067
	public HashSet<Object> getStoredData(Class class1) {
1068
		
1069
		if (!storedData.containsKey(class1)) {
1070
			storedData.put(class1, new HashSet<Object>());
1071
		}
1072
		
1073
		return storedData.get(class1);
1074
	}
1067
//	public HashSet<Object> getStoredData(Class class1) {
1068
//		
1069
//		if (!storedData.containsKey(class1)) {
1070
//			storedData.put(class1, new HashSet<Object>());
1071
//		}
1072
//		
1073
//		return storedData.get(class1);
1074
//	}
1075
//	
1076
//	/**
1077
//	 * TODO: fix this hack to store Lexicons
1078
//	 * 
1079
//	 * @param o a lexicon
1080
//	 */
1081
//	public void storeData(Object o) {
1082
//		if (storedData.containsKey(o.getClass())) {
1083
//			storedData.put(o.getClass(), new HashSet<Object>());
1084
//		}
1085
//		
1086
//		HashSet<Object> hash = storedData.get(o.getClass());
1087
//		hash.add(o);
1088
//	}
1075 1089
	
1076
	/**
1077
	 * TODO: fix this hack to store Lexicons
1078
	 * 
1079
	 * @param o a lexicon
1080
	 */
1081
	public void storeData(Object o) {
1082
		if (storedData.containsKey(o.getClass())) {
1083
			storedData.put(o.getClass(), new HashSet<Object>());
1084
		}
1085
		
1086
		HashSet<Object> hash = storedData.get(o.getClass());
1087
		hash.add(o);
1088
	}
1090
//	/**
1091
//	 * 
1092
//	 * @param o the object to remove
1093
//	 * @return true if o has been removed
1094
//	 */
1095
//	public boolean removeData(Object o) {
1096
//		if (storedData.containsKey(o.getClass())) {
1097
//			return storedData.get(o.getClass()).remove(o);
1098
//		}
1099
//		return false;
1100
//	}
1089 1101
	
1090
	/**
1091
	 * 
1092
	 * @param o the object to remove
1093
	 * @return true if o has been removed
1094
	 */
1095
	public boolean removeData(Object o) {
1096
		if (storedData.containsKey(o.getClass())) {
1097
			return storedData.get(o.getClass()).remove(o);
1098
		}
1099
		return false;
1100
	}
1101
	
1102 1102
	public StructuralUnit getTextStructuralUnit() throws CqiClientException {
1103 1103
		if (textStructuralUnit == null) {
1104 1104
			textStructuralUnit = getStructuralUnit(TEXT);
tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/ExecuteRScript.java (revision 1148)
30 30
import java.io.BufferedReader;
31 31
import java.io.File;
32 32
import java.io.FileReader;
33
import java.util.HashMap;
33 34
import java.util.Iterator;
34 35

  
35 36
import org.eclipse.core.commands.AbstractHandler;
......
48 49
import org.eclipse.ui.handlers.HandlerUtil;
49 50
import org.eclipse.ui.ide.FileStoreEditorInput;
50 51
import org.txm.Toolbox;
52
import org.txm.core.engines.ScriptEnginesManager;
51 53
import org.txm.core.preferences.TBXPreferences;
52 54
import org.txm.core.preferences.TXMPreferences;
53 55
import org.txm.rcp.StatusLine;
54 56
import org.txm.rcp.editors.TxtEditor;
55 57
import org.txm.rcp.messages.TXMUIMessages;
56 58
import org.txm.rcp.swt.dialog.LastOpened;
59
import org.txm.statsengine.r.core.RScriptEngine;
57 60
import org.txm.statsengine.r.core.RWorkspace;
58 61
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
59 62
import org.txm.statsengine.r.rcp.views.RConsole;
......
119 122
			LastOpened.set(ID, new File(result));
120 123
		}
121 124

  
122
		executeScript(result);
125
		ScriptEnginesManager.getREngine().executeScript(new File(result), new HashMap<String, Object>());
123 126
		return null;
124 127
	}
125

  
126
	/**
127
	 * Execute script.
128
	 *
129
	 * @param scriptfile the scriptfile
130
	 */
131
	public static void executeScript(String scriptfile) {
132
		File rFile = new File(scriptfile);
133
		if (!rFile.exists()) {
134
			System.err.println(NLS.bind(TXMUIMessages.ExecuteScriptR_0, rFile));
135
			return;
136
		}
137

  
138
		RWorkspace rw = null;
139
		try {
140
			rw = RWorkspace.getRWorkspaceInstance();
141
		} catch (RWorkspaceException e1) {
142
			org.txm.rcp.utils.Logger.printStackTrace(e1);
143
			return;
144
		}
145
		boolean initState = rw.isLogging();
146
		rw.setLog(true);
147
		try {
148
			System.out.println(NLS.bind(TXMUIMessages.ExecuteRScript_1, rFile.getName()));
149
			long time = System.currentTimeMillis();
150
			//execute a file line per line
151

  
152
			//if (TxmPreferences.getBoolean(RPreferencePage.R_REMOTE)) {
153
				BufferedReader reader = new BufferedReader(new FileReader(rFile));// create a file reader
154
				String line = reader.readLine();// read next line
155
				StringBuffer buffer = new StringBuffer();
156
				while(line != null) {
157
					buffer.append(line+"\n"); //$NON-NLS-1$
158
					line = reader.readLine();//read next line
159
				}
160
				
161
				String allScript = buffer.toString();
162
				//if (rw.isLogging() && allScript.length() > 0) RConsole.printUser(allScript);
163

  
164
				//String str = rw.userEval(allScript); // evaluate line in R
165
				rw.eval(allScript);
166
				//if (str != null && rw.isLogging() && str.length() > 0)
167
					//RConsole.printServer(str);
168
				reader.close();
169
//			} else {
170
//				String cmd = "source(\""+rFile.getAbsolutePath().replace("\\", "/")+"\")";
171
//				if (rw.isLogging())
172
//					RConsole.printUser)(cmd);
173
//				String str = rw.userEval(cmd);//evaluate line in R
174
//				if (rw.isLogging() && str.length() > 0)
175
//					RConsole.printServer(cmd);
176
//			}
177
			System.out.println(TXMUIMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+TXMUIMessages.ExecuteRScript_3);
178
		} catch(Exception e) {
179
			System.out.println(NLS.bind(TXMUIMessages.ExecuteScriptR_1, rFile, e)); 
180
			StatusLine.error(NLS.bind(TXMUIMessages.ExecuteScriptR_1, rFile, e)); 
181
			Log.printStackTrace(e);
182
		}
183

  
184
		rw.setLog(initState);
128
	
129
	public static void executeScript(String absolutePath) {
130
		ScriptEnginesManager.getREngine().executeScript(new File(absolutePath));
185 131
	}
186 132
}
tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/ExecuteRText.java (revision 1148)
27 27
//
28 28
package org.txm.statsengine.r.rcp.handlers;
29 29

  
30
import java.io.File;
31

  
30 32
import org.eclipse.core.commands.AbstractHandler;
31 33
import org.eclipse.core.commands.ExecutionEvent;
32 34
import org.eclipse.core.commands.ExecutionException;
......
34 36
import org.eclipse.jface.viewers.ISelection;
35 37
import org.eclipse.osgi.util.NLS;
36 38
import org.eclipse.ui.handlers.HandlerUtil;
39
import org.txm.core.engines.ScriptEnginesManager;
37 40
import org.txm.rcp.StatusLine;
38 41
import org.txm.rcp.messages.TXMUIMessages;
39 42
import org.txm.statsengine.r.core.RWorkspace;
......
65 68
		return null;
66 69
	}
67 70

  
68
	/**
69
	 * Execute text.
70
	 *
71
	 * @param text the text
72
	 * @return the object
73
	 */
74
	public static Object executeText(String text) {
75
		RWorkspace rw = null;
76
		try {
77
			rw = RWorkspace.getRWorkspaceInstance();
78
		} catch (RWorkspaceException e1) {
79
			org.txm.rcp.utils.Logger.printStackTrace(e1);
80
			return null;
81
		}
82
		boolean initState = rw.isLogging();
83
		rw.setLog(true);
84

  
85
		try {
86
			System.out.println(TXMUIMessages.ExecuteRText_0);
87
			long time = System.currentTimeMillis();
88
			//execute a file line per line
89

  
90
			//String str = rw.userEval(text);//evaluate line in R
91
			rw.eval(text);
92
//			if (str != null && rw.isLogging() && str.length() > 0)
93
//				RConsole.printServer(str);
94
			RWorkspace.appendtoEvalLog(text);
95

  
96
			System.out.println(TXMUIMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+TXMUIMessages.ExecuteRText_2); 
97
		} catch(Exception e) {
98
			System.out.println(NLS.bind(TXMUIMessages.ExecuteRText_1, text, Log.toString(e))); 
99
			StatusLine.error(NLS.bind(TXMUIMessages.ExecuteRText_1, text, Log.toString(e))); 
100
			org.txm.rcp.utils.Logger.printStackTrace(e);
101
		}
102

  
103
		rw.setLog(initState);
104
		return null;
71
	public static void executeText(String str) {
72
		ScriptEnginesManager.getREngine().executeText(str);
105 73
	}
106 74
}
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/r/data/LexicalTableImpl.java (revision 1148)
73 73
	/** The sortedindex. */
74 74
	private int[] sortedindex;
75 75

  
76
	protected ArrayList<Integer> frequencies;
76
	//protected ArrayList<Integer> frequencies;
77 77

  
78 78
	/**
79 79
	 * Instantiates a new lexical table impl.
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 1148)
47 47
	/** stores the R table computed */
48 48
	protected ILexicalTable statsData;
49 49

  
50

  
51

  
52 50
	/**
53 51
	 * The property.
54 52
	 */
......
73 71
	@Parameter(key=LexicalTablePreferences.USE_ALL_OCCURRENCES)
74 72
	protected boolean useAllOccurrences;
75 73

  
76
	/**
77
	 * Build a LexicalTable result with an already computed frequency R table
78
	 * 
79
	 * @param corpus
80
	 * @param analysisProperty
81
	 * @param itable
82
	 */
83
	public LexicalTable(CQPCorpus corpus, WordProperty analysisProperty, ILexicalTable itable) {
84
		super(corpus);
85
		this.property = analysisProperty;
86
		this.statsData = itable;
87
	}
74
//	/**
75
//	 * Build a LexicalTable result with an already computed frequency R table
76
//	 * 
77
//	 * @param corpus
78
//	 * @param analysisProperty
79
//	 * @param itable
80
//	 */
81
//	public LexicalTable(CQPCorpus corpus, WordProperty analysisProperty, ILexicalTable itable) {
82
//		super(corpus);
83
//		this.property = analysisProperty;
84
//		this.statsData = itable;
85
//	}
88 86

  
87
//	/**
88
//	 * Build a LexicalTable with the {@link Subcorpus} words and {@link Subcorpus} parent remaining words.
89
//	 * 
90
//	 * @param corpus
91
//	 * @param analysisProperty the property to count
92
//	 * @throws Exception
93
//	 */
94
//	public LexicalTable(Subcorpus corpus, WordProperty analysisProperty) {
95
//		this(corpus, analysisProperty, null);
96
//	}
89 97

  
90 98
	/**
91
	 * Build a LexicalTable with the {@link Subcorpus} words and {@link Subcorpus} parent remaining words.
92
	 * 
93
	 * @param corpus
94
	 * @param analysisProperty the property to count
95
	 * @throws Exception
96
	 */
97
	public LexicalTable(Subcorpus corpus, WordProperty analysisProperty) {
98
		this(corpus, analysisProperty, null);
99
	}
100

  
101
	/**
102 99
	 * Build a LexicalTable with the Subcorpus words and Subcorpus parent remaining words.
103 100
	 * 
104 101
	 * @param corpus
105 102
	 * @throws Exception
106 103
	 */
107
	public LexicalTable(Subcorpus corpus) throws Exception {
108
		this(corpus, corpus.getDefaultProperty());
104
	public LexicalTable(CQPCorpus corpus) throws Exception {
105
		//this(corpus, corpus.getDefaultProperty(), null);
106
		super(corpus);
109 107
	}
110 108

  
109
//	/**
110
//	 * 
111
//	 * @param partition
112
//	 * @param analysisProperty
113
//	 * @param fMin
114
//	 * @param vMax
115
//	 * @param iTable
116
//	 */
117
//	public LexicalTable(Partition partition, WordProperty analysisProperty, int fMin, int vMax, ILexicalTable iTable) {
118
//		this(partition, analysisProperty, fMin, vMax, false, iTable);
119
//	}
111 120

  
112 121
	/**
113 122
	 * 
114
	 * @param partition
115
	 * @param analysisProperty
116
	 * @param fMin
117
	 * @param vMax
118
	 * @param iTable
119
	 */
120
	public LexicalTable(Partition partition, WordProperty analysisProperty, int fMin, int vMax, ILexicalTable iTable) {
121
		this(partition, analysisProperty, fMin, vMax, false, iTable);
122
	}
123

  
124
	/**
125
	 * 
126 123
	 * @param index
127 124
	 */
128 125
	public LexicalTable(PartitionIndex index)	{
......
137 134
		super(partition);
138 135
	}
139 136

  
140
	/**
141
	 * 
142
	 * @param partition
143
	 * @param analysisProperty
144
	 * @param fMin
145
	 * @param vMax
146
	 */
147
	public LexicalTable(Partition partition, WordProperty analysisProperty, int fMin, int vMax) {
148
		this(partition, analysisProperty, fMin, vMax, null);
149
	}
137
//	/**
138
//	 * 
139
//	 * @param partition
140
//	 * @param analysisProperty
141
//	 * @param fMin
142
//	 * @param vMax
143
//	 */
144
//	public LexicalTable(Partition partition, WordProperty analysisProperty, int fMin, int vMax) {
145
//		this(partition, analysisProperty, fMin, vMax, null);
146
//	}
150 147

  
151
	/**
152
	 * 
153
	 * @param parent
154
	 * @param analysisProperty
155
	 * @param fMin
156
	 * @param vMax
157
	 * @param useAllOccurrences
158
	 * @param iTable
159
	 */
160
	private LexicalTable(TXMResult parent, WordProperty analysisProperty, int fMin, int vMax, boolean useAllOccurrences, ILexicalTable iTable)	{
161
		super(parent);
162
		this.setParameters(analysisProperty, fMin, vMax, useAllOccurrences);
163
		this.statsData = iTable;
164
	}
148
//	/**
149
//	 * 
150
//	 * @param parent
151
//	 * @param analysisProperty
152
//	 * @param fMin
153
//	 * @param vMax
154
//	 * @param useAllOccurrences
155
//	 * @param iTable
156
//	 */
157
//	private LexicalTable(TXMResult parent, WordProperty analysisProperty, int fMin, int vMax, boolean useAllOccurrences, ILexicalTable iTable)	{
158
//		super(parent);
159
//		this.setParameters(analysisProperty, fMin, vMax, useAllOccurrences);
160
//		this.statsData = iTable;
161
//	}
165 162

  
166

  
167

  
168 163
	public LexicalTable(String parametersNodePath)	{
169 164
		super(parametersNodePath);
170 165
	}
171 166

  
172

  
173

  
174 167
	@Override
175 168
	public boolean loadParameters() {
176 169
		try {
......
340 333
	@Override
341 334
	protected boolean _compute() throws Exception {
342 335

  
343
		this.statsData = null; // reset frequencies
336
		//this.statsData = null; // reset frequencies
344 337

  
345 338
		if (this.parent instanceof Subcorpus) {
346 339

  
......
663 656
		this.useAllOccurrences = useAllOccurrences;
664 657
	}
665 658

  
666

  
667 659
	@Override
668 660
	public String getResultype() {
669 661
		return LexicalTableCoreMessages.RESULT_TYPE;
670 662
	}
671 663

  
672

  
673

  
674

  
664
	public void setData(LexicalTableImpl lexicalTableImpl) {
665
		this.statsData = lexicalTableImpl;
666
	}
675 667
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteScript.java (revision 1148)
28 28
package org.txm.rcp.handlers.scripts;
29 29

  
30 30
import java.io.File;
31
import java.util.HashMap;
31 32
import java.util.Iterator;
32 33

  
34
import org.apache.commons.collections.map.HashedMap;
33 35
import org.eclipse.core.commands.AbstractHandler;
34 36
import org.eclipse.core.commands.ExecutionEvent;
35 37
import org.eclipse.core.commands.ExecutionException;
......
48 50
import org.eclipse.ui.handlers.HandlerUtil;
49 51
import org.eclipse.ui.ide.FileStoreEditorInput;
50 52
import org.txm.Toolbox;
53
import org.txm.core.engines.EngineType;
54
import org.txm.core.engines.ScriptEngine;
55
import org.txm.core.engines.ScriptEnginesManager;
51 56
import org.txm.core.preferences.TBXPreferences;
52 57
import org.txm.core.preferences.TXMPreferences;
53 58
import org.txm.rcp.editors.TxtEditor;
......
73 78
		String result = ""; //$NON-NLS-1$
74 79
		boolean executionFromEditor = false;
75 80
		TxtEditor txteditor = null;
76
		
81

  
77 82
		IWorkbenchPart page = HandlerUtil.getActiveWorkbenchWindow(event)
78 83
				.getActivePage().getActivePart();
79 84
		ISelection selection = HandlerUtil.getCurrentSelection(event);
......
125 130
				if (!doit) { // ask user
126 131
					MessageDialog dialog = new MessageDialog(shell, TXMUIMessages.ExecuteScript_0+result, null,
127 132
							TXMUIMessages.ExecuteScript_1, MessageDialog.QUESTION, new String[] {TXMUIMessages.ExecuteScript_2, TXMUIMessages.ExecuteScript_4,
128
							TXMUIMessages.ExecuteScript_5}, 0) {
133
									TXMUIMessages.ExecuteScript_5}, 0) {
129 134
						Button checkDefault;
130
						 @Override
131
						  protected Control createDialogArea(Composite parent) {
132
						    Composite container = (Composite) super.createDialogArea(parent);
133
						    checkDefault = new Button(container, SWT.CHECK);
134
						    checkDefault.setText(TXMUIMessages.ExecuteScript_6);
135
						    boolean b = RCPPreferences.getInstance().getBoolean(RCPPreferences.SAVE_BEFORE_EXECUTION);
136
						    checkDefault.setSelection(b);
137
						    
138
						    checkDefault.addSelectionListener(new SelectionListener() {
139
								
135
						@Override
136
						protected Control createDialogArea(Composite parent) {
137
							Composite container = (Composite) super.createDialogArea(parent);
138
							checkDefault = new Button(container, SWT.CHECK);
139
							checkDefault.setText(TXMUIMessages.ExecuteScript_6);
140
							boolean b = RCPPreferences.getInstance().getBoolean(RCPPreferences.SAVE_BEFORE_EXECUTION);
141
							checkDefault.setSelection(b);
142

  
143
							checkDefault.addSelectionListener(new SelectionListener() {
144

  
140 145
								@Override
141 146
								public void widgetSelected(SelectionEvent e) {
142 147
									boolean b = checkDefault.getSelection();
143 148
									RCPPreferences.getInstance().put(RCPPreferences.SAVE_BEFORE_EXECUTION, b);
144 149
								}
145
								
150

  
146 151
								@Override
147 152
								public void widgetDefaultSelected(SelectionEvent e) { }
148 153
							});
149
						    return container;
150
						  }
154
							return container;
155
						}
151 156
					};
152 157
					int c = dialog.open();
153 158
					if (c == 1) {
......
183 188
		File script = new File(scriptpath);
184 189
		if (!script.exists()) return;
185 190

  
186
		if (script.getName().endsWith(".groovy")) { //$NON-NLS-1$
191
		String ext = script.getName();
192
		int i = ext.lastIndexOf(".");
193
		if (i > 0) {
194
			ext = ext.substring(i);
195
		}
196

  
197
		if ("groovy".equals(ext)) { // TODO make Groovy a script engine
187 198
			ExecuteGroovyScript.executeScript(scriptpath, page, selection);
188
		} else if (script.getName().endsWith(".R")) { //$NON-NLS-1$
189
			System.out.println("ExecuteScript with R not implemented");
190
			//ExecuteRScript.executeScript(scriptpath);
191 199
		} else {
192
			System.out.println(TXMUIMessages.ExecuteScript_3+script.getName());
200
			ScriptEngine se = (ScriptEngine) Toolbox.getEngineManager(EngineType.SCRIPT).getEngine(ext);
201
			if (se != null) {
202
				HashMap<String, Object> env = new HashMap<String, Object>();
203
				env.put("page", page); // selection
204
				env.put("selection", selection); // selection
205
				se.executeScript(script, env);
206
			} else {
207
				System.out.println(TXMUIMessages.ExecuteScript_3+script.getName());
208
			}
193 209
		}
194 210
	}
195 211
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 1148)
27 27
//
28 28
package org.txm.rcp.handlers.scripts;
29 29

  
30
import groovy.lang.Binding;
31

  
32 30
import java.io.File;
33
import java.io.FilenameFilter;
34
import java.io.IOException;
35
import java.net.MalformedURLException;
36
import java.util.HashMap;
37
import java.util.HashSet;
38 31
import java.util.Iterator;
39 32
import java.util.List;
40 33

  
41
import org.codehaus.groovy.control.CompilerConfiguration;
42
import org.codehaus.groovy.control.customizers.ImportCustomizer;
43 34
import org.eclipse.core.commands.AbstractHandler;
44 35
import org.eclipse.core.commands.ExecutionEvent;
45 36
import org.eclipse.core.commands.ExecutionException;
46
import org.eclipse.core.internal.runtime.InternalPlatform;
47 37
import org.eclipse.core.runtime.IProgressMonitor;
48 38
import org.eclipse.core.runtime.IStatus;
49 39
import org.eclipse.core.runtime.Platform;
......
58 48
import org.eclipse.ui.IWorkbenchPart;
59 49
import org.eclipse.ui.handlers.HandlerUtil;
60 50
import org.eclipse.ui.ide.FileStoreEditorInput;
61
import org.osgi.framework.Bundle;
62
import org.osgi.framework.BundleContext;
63 51
import org.txm.Toolbox;
64
import org.txm.core.preferences.TBXPreferences;
65 52
import org.txm.groovy.core.GSERunner;
66 53
import org.txm.rcp.editors.TxtEditor;
67 54
import org.txm.rcp.messages.TXMUIMessages;
......
69 56
import org.txm.rcp.swt.widget.parameters.UIParameterException;
70 57
import org.txm.rcp.utils.JobHandler;
71 58
import org.txm.rcp.views.corpora.CorporaView;
72
import org.txm.utils.logger.Log;
73
// TODO: Auto-generated Javadoc
59

  
60
import groovy.lang.Binding;
74 61
/**
75
 * Execute a Groovy script
62
 * Handler to Execute a Groovy script. 
76 63
 * 
64
 * 1- If no parameter "org.txm.rcp.command.parameter.file" is set
65
 * 2- use the current selection
66
 * 	2.1 TXTEditor text selection and opened file
67
 *  2.2 File
68
 * 3- then ask the user to select a script
69
 * 
77 70
 * @author mdecorde
78 71
 */
79 72
public class ExecuteGroovyScript extends AbstractHandler {
......
218 211
		final String relativepath = path.substring(dir.length()+1);
219 212

  
220 213
		//if (gse == null) {
221
			gse = GSERunner.buildDefaultGSE(scriptfile);
222
			if (gse == null) {
223
				System.out.println("Could not create the Groovy script engine. Aborting.");
224
				return;
225
			}
214
			
226 215
		//}
227 216

  
228
		JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.ExecuteRScript_1,scriptfile.getName())) {
217
		JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.ExecuteScript_0, scriptfile.getName())) {
229 218
			@Override
230 219
			protected IStatus run(IProgressMonitor monitor) {
231 220
				this.runInit(monitor);
232 221
				//this.setCurrentMonitor(monitor);
233
				monitor.beginTask(NLS.bind(TXMUIMessages.ExecuteRScript_1, scriptfile.getName()), 100);
222
				monitor.beginTask(NLS.bind(TXMUIMessages.ExecuteScript_0, scriptfile.getName()), 100);
234 223

  
235 224
				try {
225
					gse = GSERunner.buildDefaultGSE();
226
					if (gse == null) {
227
						System.out.println("Could not create the Groovy script engine. Aborting.");
228
						return Status.CANCEL_STATUS;
229
					}
230
					
236 231
					Binding binding = new Binding();
237 232
					binding.setVariable("editor", page); //$NON-NLS-1$
238 233
					binding.setVariable("selection", selection); //$NON-NLS-1$
......
243 238
					binding.setProperty("MONITOR", this); //$NON-NLS-1$
244 239
					binding.setProperty("gse", gse);
245 240
					
246
					System.out.println(NLS.bind(TXMUIMessages.ExecuteRScript_1, scriptfile.getName()));
241
					System.out.println(NLS.bind(TXMUIMessages.ExecuteScript_11, scriptfile.getName()));
247 242
					long time = System.currentTimeMillis();
248 243
					System.out.println(relativepath);
249 244
					gse.run(relativepath, binding);
250 245
					
251
					System.out.println(TXMUIMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+TXMUIMessages.ExecuteGroovyScript_0);
246
					System.out.println(TXMUIMessages.ExecuteScript_12+(System.currentTimeMillis()-time)+TXMUIMessages.ExecuteGroovyScript_0);
252 247
				} catch (ThreadDeath td) {
253 248
					return Status.CANCEL_STATUS;
254 249
				} catch (UIParameterException e) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyText.java (revision 1148)
107 107
	 */
108 108
	public static Object executeText(final String text, final String scriptfile) {
109 109
		if (!new File(scriptfile).exists()) {
110
			System.err.println(NLS.bind(TXMUIMessages.ExecuteScriptImport_1,
111
					scriptfile));
110
			System.err.println(NLS.bind(TXMUIMessages.ExecuteScriptImport_1, scriptfile));
112 111
			return null;
113 112
		}
114 113
		final String scriptRootDir = Toolbox.getTxmHomePath() + "/scripts";
......
147 146
					for (File file : classPath) {
148 147
						try {
149 148
							shell.getClassLoader().addURL(file.toURI().toURL());
150
							shell.getClassLoader().addClasspath(
151
									file.getAbsolutePath());
149
							shell.getClassLoader().addClasspath(file.getAbsolutePath());
152 150
						} catch (MalformedURLException e) {
153 151
							org.txm.rcp.utils.Logger.printStackTrace(e);
154 152
							return null;
......
159 157
					System.out.println("Executing text selection..."); //$NON-NLS-1$
160 158
					long time = System.currentTimeMillis();
161 159
					shell.evaluate(text);
162
					System.out
163
							.println("Done: " + (System.currentTimeMillis() - time) + TXMUIMessages.ExecuteRScript_3); //$NON-NLS-1$
160
					System.out.println("Done: " + (System.currentTimeMillis() - time) + TXMUIMessages.ExecuteScript_13); //$NON-NLS-1$
164 161
				} catch (ThreadDeath td) { 
165 162
					return Status.CANCEL_STATUS;
166 163
				} catch (CompilationFailedException e) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 1148)
271 271
	public static String ExecuteLastGroovyScript_0;
272 272
	public static String ExecuteLastGroovyScript_1;
273 273
	public static String ExecuteLastGroovyScript_3;
274
	public static String ExecuteRScript_1;
275
	public static String ExecuteRScript_2;
276
	public static String ExecuteRScript_3;
277
	public static String ExecuteRText_0;
278
	public static String ExecuteRText_1;
279
	public static String ExecuteRText_2;
274

  
280 275
	public static String ExecuteScript_0;
281 276
	public static String ExecuteScript_1;
282 277
	public static String ExecuteScript_2;
......
285 280
	public static String ExecuteScript_5;
286 281
	public static String ExecuteScript_6;
287 282
	public static String ExecuteScript_7;
283
	public static String ExecuteScript_11;
284
	public static String ExecuteScript_12;
285
	public static String ExecuteScript_13;
288 286
	public static String ExecuteScriptImport_0;
289 287
	public static String ExecuteScriptImport_1;
290 288
	public static String ExecuteScriptImport_2;
......
293 291
	public static String ExecuteScriptImport_6;
294 292
	public static String ExecuteScriptImport_7;
295 293
	public static String ExecuteScriptImport_8;
296
	public static String ExecuteScriptR_0;
297
	public static String ExecuteScriptR_1;
298 294
	public static String Exit_Menu_Label;
299 295
	public static String Explorer_0;
300 296
	public static String Explorer_1;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 1148)
302 302
ExecuteLastGroovyScript_1 = Executing last script: 
303 303
ExecuteLastGroovyScript_3 = Error: Current Groovy script directory does not exist: 
304 304

  
305
ExecuteRScript_1 = Running {0}
306
ExecuteRScript_2 = Done:
307
ExecuteRScript_3 = \ ms
308

  
309
ExecuteRText_0 = Running text selection...
310
ExecuteRText_1 = ** Error while running R script {0}: {1}
311
ExecuteRText_2 = \ ms
312

  
313 305
ExecuteScriptImport_0 = Import started
314 306
ExecuteScriptImport_1 = ** {0} script file doesn''t exist
315 307
ExecuteScriptImport_2 = ** Error: 'corpora' directory doesn't exist:
......
318 310
ExecuteScriptImport_6 = The import process failed.
319 311
ExecuteScriptImport_7 = Import done:
320 312
ExecuteScriptImport_8 = ** Error while loading corpus
313
ExecuteRScript_11 = Running {0}
314
ExecuteRScript_12 = Done:
315
ExecuteRScript_13 = \ ms
321 316

  
322
ExecuteScriptR_0 = ** {0} R script doesn''t exist
323
ExecuteScriptR_1 = ** Error while Running R script {0}: {1}
324

  
325 317
ExecuteScript_0       = Execution of {0}
326 318
ExecuteScript_1       = Save file before execution ?
327 319
ExecuteScript_2       = Save and run
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_ru.properties (revision 1148)
230 230
ExecuteGroovyScript_1         = N/A_Error during parameters initialisation
231 231
ExecuteGroovyScript_2         = N/A_The user canceled the script execution
232 232

  
233
ExecuteRScript_1 = Выполнение 
234
ExecuteRScript_2 = Готово: 
235
ExecuteRScript_3 = \ мс
236

  
237
ExecuteRText_0 = Выполнение выделения текста... 
238
ExecuteRText_1 = ** Ошибка во время выполнения скрипта R {0}: {1}
239
ExecuteRText_2 = \ мс
240

  
241 233
ExecuteScriptImport_0 = Начало импортирования
242 234
ExecuteScriptImport_1 = ** Файл скрипта {0} не найден
243 235
ExecuteScriptImport_2 = ** Ошибка: папка 'corpora' не существует: 
......
247 239
ExecuteScriptImport_7 = Импортирование завершено: 
248 240
ExecuteScriptImport_8 = ** Ошибка при загрузке корпуса
249 241

  
250
ExecuteScriptR_0 = ** Файл скрипта R {0} не найден
251
ExecuteScriptR_1 = ** Ошибка при выполнении скрипта R {0}: {1}
252

  
253 242
ExecuteScript_3       = ** Не найдено ни одного интерпретатора для расширения файла скрипта 
254 243

  
255 244
Exit_Menu_Label = Выход
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 1148)
266 266
ExecuteGroovyScript_1         = Erreur lors de l'initialisation des paramètres
267 267
ExecuteGroovyScript_2         = L'utilisateur a intérompu l'exécution du script
268 268

  
269
ExecuteRScript_1 = Exécution de {0}
270
ExecuteRScript_2 = Terminé : 
271
ExecuteRScript_3 = \ ms
272

  
273
ExecuteRText_0 = Exécution de la sélection de texte... 
274
ExecuteRText_1 = ** Erreur lors de l''exécution du script R {0} : {1}
275
ExecuteRText_2 = \ ms
276

  
277 269
ExecuteScriptImport_0 = Début de l'importation
278 270
ExecuteScriptImport_1 = ** Le fichier de script {0} n''existe pas
279 271
ExecuteScriptImport_2 = ** Erreur: le dossier 'corpora' n'existe pas : 
......
282 274
ExecuteScriptImport_6 = L'import n'a pas abouti.
283 275
ExecuteScriptImport_7 = Importation terminée : 
284 276
ExecuteScriptImport_8 = ** Erreur lors du chargement du corpus
277

  
278
ExecuteScript_0       = Exécution de {0} ...
279
ExecuteScript_1       = Sauver le fichier avant d'exécuter ?
280
ExecuteScript_2       = Sauver et lancer
281
ExecuteScript_3       = ** Aucun interpréteur trouvé pour l'extension du fichier de script 
282
ExecuteScript_4       = Annuler
283
ExecuteScript_5       = Ne pas sauver et lancer
284
ExecuteScript_6       = Toujours sauvegarder avant de lancer
285
ExecuteScript_7       = Exécution annulée.
286
ExecuteRScript_11 = Exécution de {0}
287
ExecuteRScript_12 = Terminé : 
288
ExecuteRScript_13 = \\ ms
285 289

  
286
ExecuteScriptR_0 = ** Le fichier de script R {0} n''existe pas
287
ExecuteScriptR_1 = ** Erreur lors de l''exécution du script R {0} : {1}
288

  
289
ExecuteScript_0       = Exécution de {0} ...
290
ExecuteScript_1       = Sauver le fichier avant d'exécuter ?
291
ExecuteScript_2       = Sauver et lancer
292
ExecuteScript_3       = ** Aucun interpréteur trouvé pour l'extension du fichier de script 
293
ExecuteScript_4       = Annuler
294
ExecuteScript_5       = Ne pas sauver et lancer
295
ExecuteScript_6       = Toujours sauvegarder avant de lancer
296
ExecuteScript_7       = Exécution annulée.
297

  
298 290
Exit_Menu_Label = Quitter
299 291

  
300 292
Explorer_0 = Le dossier {0} ne devrait pas être supprimé
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 1148)
99 99

  
100 100
					Log.info(NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition, property));
101 101

  
102
					LexicalTable lexicalTable = new LexicalTable(partition, property, fMin, vMax);
102
					LexicalTable lexicalTable = new LexicalTable(partition);
103
					lexicalTable.setParameters(property, fMin, vMax, null);
103 104
					ca = new CA(lexicalTable);
104 105
				} else { // aborted
105 106
					return null;
tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesR.java (revision 1148)
129 129

  
130 130
		try {
131 131
			rw.safeEval("library(textometry)");
132
		} catch (RserveException e1) {
132
		} catch (Exception e1) {
133 133
			// TODO Auto-generated catch block
134 134
			e1.printStackTrace();
135
		} catch (REXPMismatchException e1) {
136
			// TODO Auto-generated catch block
137
			e1.printStackTrace();
138 135
		}
139 136
		REXP r = rw.callFunction("specificities", new QuantitativeDataStructure[] { table, row, column }, symbol); //$NON-NLS-1$
140 137

  
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 1148)
390 390
	 * @throws StatException the stat exception
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff