Révision 3521

TXM/trunk/org.txm.partition.rcp/plugin.xml (revision 3521)
122 122
            </iterate>
123 123
         </with>
124 124
      </definition>
125
      <definition
126
            id="OnePartitionDimensionsSelected">
127
         <with
128
               variable="corporaSelection">
129
            <iterate
130
                  ifEmpty="false"
131
                  operator="and">
132
               <instanceof
133
                     value="org.txm.partition.core.functions.PartitionDimensions">
134
               </instanceof>
135
            </iterate>
136
         </with>
137
      </definition>
125 138
   </extension>
126 139

  
127 140
</plugin>
TXM/trunk/org.txm.chartsengine.r.core/src/org/txm/chartsengine/r/core/RChartCreator.java (revision 3521)
22 22
 */
23 23
public abstract class RChartCreator<R extends ChartResult> extends ChartCreator<RChartsEngine, R> {
24 24
	
25
	protected String symbol = null;
26
	
25 27
	/**
26 28
	 * creates an empty file. the chart will be written after in the updateChart method
27 29
	 */
......
68 70
		return RChartsEngine.class;
69 71
	}
70 72
	
73
	public String getSymbol() {
74
		return symbol;
75
	}
71 76
	
72 77
	
73
	
74 78
	// @Override
75 79
	// public Object createChart(ChartResult result) {
76 80
	// //return this.createChartFile(result);
TXM/trunk/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/r/CooccurrencesRTransformer.java (revision 3521)
2 2

  
3 3
import org.txm.cooccurrence.core.functions.Cooccurrence;
4 4
import org.txm.cooccurrence.core.functions.Cooccurrence.CLine;
5
import org.txm.core.results.TXMResult;
6 5
import org.txm.statsengine.r.core.RTransformer;
7 6
import org.txm.statsengine.r.core.RWorkspace;
8 7
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
......
21 20
	}
22 21

  
23 22
	@Override
24
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
23
	public String fromTXMtoR(Cooccurrence o) throws RWorkspaceException {
25 24
		
26 25
		if (!(o instanceof Cooccurrence)) return null;
27 26
		
......
61 60
				//+ ", query=\""+this.query.getQueryString()+"\""
62 61
				+ ")"); //$NON-NLS-1$
63 62

  
63
		rw.eval("rm(coocfreq, cooccofreq, coocscore, coocmeandist)");
64 64
		nocooc++;
65 65
		return symbol;
66 66
	}
TXM/trunk/org.txm.statsengine.r.rcp/plugin.xml (revision 3521)
143 143
                  <reference
144 144
                        definitionId="OnePartitionIndexSelected">
145 145
                  </reference>
146
                  <reference
147
                        definitionId="OnePartitionSelected">
148
                  </reference>
149
                  <reference
150
                        definitionId="OneLexicalTableSelected">
151
                  </reference>
152
                  <reference
153
                        definitionId="OneCAHSelected">
154
                  </reference>
155
                  <reference
156
                        definitionId="OneCASelected">
157
                  </reference>
158
                  <reference
159
                        definitionId="OneProgressionSelected">
160
                  </reference>
161
                  <reference
162
                        definitionId="OneSpecificitiesResultSelected">
163
                  </reference>
164
                  <reference
165
                        definitionId="OnePartitionDimensionsSelected">
166
                  </reference>
146 167
               </or>
147 168
            </visibleWhen>
148 169
         </command>
......
178 199
                  <reference
179 200
                        definitionId="OnePartitionIndexSelected">
180 201
                  </reference>
202
                  <reference
203
                        definitionId="OnePartitionSelected">
204
                  </reference>
205
                  <reference
206
                        definitionId="OneLexicalTableSelected">
207
                  </reference>
208
                  <reference
209
                        definitionId="OneCAHSelected">
210
                  </reference>
211
                  <reference
212
                        definitionId="OneCASelected">
213
                  </reference>
214
                  <reference
215
                        definitionId="OneProgressionSelected">
216
                  </reference>
217
                  <reference
218
                        definitionId="OneSpecificitiesResultSelected">
219
                  </reference>
220
                  <reference
221
                        definitionId="OnePartitionDimensionsSelected">
222
                  </reference>
181 223
               </or>
182 224
            </visibleWhen>
183 225
         </command>
......
213 255
                  <reference
214 256
                        definitionId="OnePartitionIndexSelected">
215 257
                  </reference>
258
                  <reference
259
                        definitionId="OnePartitionSelected">
260
                  </reference>
261
                  <reference
262
                        definitionId="OneLexicalTableSelected">
263
                  </reference>
264
                  <reference
265
                        definitionId="OneCAHSelected">
266
                  </reference>
267
                  <reference
268
                        definitionId="OneCASelected">
269
                  </reference>
270
                  <reference
271
                        definitionId="OneProgressionSelected">
272
                  </reference>
273
                  <reference
274
                        definitionId="OneSpecificitiesResultSelected">
275
                  </reference>
276
                  <reference
277
                        definitionId="OnePartitionDimensionsSelected">
278
                  </reference>
216 279
               </or>
217 280
            </visibleWhen>
218 281
         </command>
TXM/trunk/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/SendToRCommand.java (revision 3521)
44 44
import org.txm.rcp.utils.JobHandler;
45 45
import org.txm.rcp.views.corpora.CorporaView;
46 46
import org.txm.statsengine.core.StatsEnginesManager;
47
import org.txm.statsengine.r.core.RResult;
47 48
import org.txm.statsengine.r.core.RStatsEngine;
48 49
import org.txm.statsengine.r.core.RTransformer;
49 50
import org.txm.statsengine.r.rcp.messages.RUIMessages;
......
84 85
					monitor.beginTask(RUIMessages.sendingToRWorkspaceColon + list, 100);
85 86
					int delta = 100 / list.size();
86 87
					for (Object o : list) {
87
						if (o instanceof TXMResult) {
88
						if (o instanceof RResult) {
89
							Log.info(NLS.bind("''{0}'' has been copied in the ''{1}'' R variable.", ((RResult)o).toString(),  ((RResult)o).getRSymbol()));
90
						} else if (o instanceof TXMResult) {
88 91
							try {
89 92
								monitor.subTask(RUIMessages.sendingToRWorkspaceColon + o);
90 93
								this.acquireSemaphore();
91 94
								String symbol = send((TXMResult) o);
92 95
								if (symbol == null) {
93
									Log.info(NLS.bind("** {0} was not transfered to the R workspace.", o));
96
									Log.info(NLS.bind("** ''{0}'' was not transfered to the R workspace.", o));
94 97
									this.releaseSemaphore();
95 98
									return Status.CANCEL_STATUS;
96 99
								}
97 100
								else {
98
									Log.info(NLS.bind("{0} has been copied in the ''{1}'' R variable.", o.toString(), symbol));
101
									Log.info(NLS.bind("''{0}'' has been copied in the ''{1}'' R variable.", o.toString(), symbol));
99 102
								}
100 103
								this.releaseSemaphore();
101 104
								
......
141 144
	 * @param o the o
142 145
	 * @throws Exception the exception
143 146
	 */
147
	@SuppressWarnings({ "rawtypes", "unchecked" })
144 148
	public static String send(TXMResult o) throws Exception {
145 149
		
146 150
		RStatsEngine rengine = (RStatsEngine) StatsEnginesManager.getREngine();
147 151
		HashMap<String, RTransformer<? extends TXMResult>> transformers = rengine.getTransformers();
148 152
		if (transformers.containsKey(o.getClass().getName())) {
149
			RTransformer<? extends TXMResult> transformer = rengine.getTransformers().get(o.getClass().getName());
153
			RTransformer transformer = rengine.getTransformers().get(o.getClass().getName());
154
			if (transformer == null) {
155
				return null;
156
			}
150 157
			String s = transformer.fromTXMtoR(o);
151 158
			return s;
152 159
		}
TXM/trunk/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionDensityChartCreator.java (revision 3521)
18 18
		return super.createChart(result, file, false);
19 19
	}
20 20
	
21
	
22 21
}
TXM/trunk/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionBaseChartCreator.java (revision 3521)
13 13
import org.txm.progression.core.chartsengine.base.ProgressionChartCreator;
14 14
import org.txm.progression.core.chartsengine.base.Utils;
15 15
import org.txm.progression.core.functions.Progression;
16
import org.txm.progression.core.preferences.ProgressionPreferences;
17 16
import org.txm.statsengine.r.core.RWorkspace;
18 17
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
19 18
import org.txm.utils.logger.Log;
......
136 135
			
137 136
			this.getChartsEngine().plot(file, cmd, result, StringEscapeUtils.escapeJava(Utils.createProgressionChartTitle(progression, cumulative)), null);
138 137
			
139
			RWorkspace.getRWorkspaceInstance().eval(Progression.prefixR + Progression.norep + " <- list(positions=positions, names=names, xmin=" + progression.getXminCorpus() + ",xmax=" + progression //$NON-NLS-1$ //$NON-NLS-2$
138
			symbol = Progression.prefixR + Progression.norep;
139
			
140
			RWorkspace.getRWorkspaceInstance().eval(symbol + " <- list(positions=positions, names=names, xmin=" + progression.getXminCorpus() + ",xmax=" + progression //$NON-NLS-1$ //$NON-NLS-2$
140 141
					.getXmaxCorpus() + ", structpositions=structurepositions, structnames=structurenames)");  //$NON-NLS-1$
141 142
			Progression.norep++;
142 143
		}
TXM/trunk/org.txm.progression.core/src/org/txm/progression/core/r/ProgressionRTransformer.java (revision 3521)
1 1
package org.txm.progression.core.r;
2 2

  
3
import org.txm.core.results.TXMResult;
3
import java.util.List;
4

  
5
import org.txm.progression.core.chartsengine.r.RProgressionBaseChartCreator;
4 6
import org.txm.progression.core.functions.Progression;
7
import org.txm.searchengine.core.Query;
5 8
import org.txm.statsengine.r.core.RTransformer;
9
import org.txm.statsengine.r.core.RWorkspace;
6 10
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
7 11

  
8 12
public class ProgressionRTransformer extends RTransformer<Progression> {
9 13

  
14
	/** The prefix r. */
15
	public static String prefixR = "Progression"; //$NON-NLS-1$
16
	
10 17
	@Override
11 18
	public Progression fromRtoTXM(String symbol) throws RWorkspaceException {
12 19
		return null;
13 20
	}
14 21

  
15 22
	@Override
16
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
23
	public String fromTXMtoR(Progression o) throws RWorkspaceException {
17 24

  
18 25
		if (!(o instanceof Progression)) return null;
26
			
27
		if (o.getChartCreator() instanceof RProgressionBaseChartCreator) {
28
			return ((RProgressionBaseChartCreator)o.getChartCreator()).getSymbol();
29
		} else {
30
			String s = Progression.prefixR + Progression.norep;
31
			Progression.norep++;
32
			
33
			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
34
			
35
			List<Query> queries = o.getQueries();
36
			List<int[]> positions = o.getAllPositions();
37
			
38
			String[] names = new String[queries.size()];
39
			for (int i = 0 ; i < queries.size() ; i++) {
40
				names[i] = queries.get(i).getQueryString();
41
			}
42
			
43
			rw.addVectorToWorkspace("tmpqueries", names);
44
			rw.eval("tmppositions <- list();");
45
			//rw.eval(s+"$positions <- list();");
46
			for (int i = 0 ; i < queries.size() ; i++) {
47
				rw.addVectorToWorkspace("TEMP", positions.get(i));
48
				rw.eval("tmppositions[["+(i+1)+"]] <- TEMP");
49
			}
50
			rw.eval(s+" <- list(queries=tmpqueries, positions=tmppositions);");
51
			rw.eval("rm(tmpqueries, tmppositions);");
52
			//rw.addVectorToWorkspace(variableName, vector);
53
			return s;
54
		}
19 55
		
20
		return null;
21 56
	}
22 57

  
23 58
}
TXM/trunk/org.txm.progression.core/plugin.xml (revision 3521)
24 24
            class="org.txm.progression.core.preferences.ProgressionPreferences">
25 25
      </initializer>
26 26
   </extension>
27
   <extension
28
         point="org.txm.statsengine.r.core.RTransformer">
29
      <transformer
30
            class="org.txm.progression.core.r.ProgressionRTransformer"
31
            type="org.txm.progression.core.functions.Progression">
32
      </transformer>
33
   </extension>
27 34

  
28 35
</plugin>
TXM/trunk/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RTransformer.java (revision 3521)
28 28
	 * @return the created R variable symbol
29 29
	 * @throws RWorkspaceException
30 30
	 */
31
	public abstract String fromTXMtoR(TXMResult o) throws RWorkspaceException;
31
	public abstract String fromTXMtoR(T o) throws RWorkspaceException;
32 32
}
TXM/trunk/org.txm.index.core/src/org/txm/index/core/r/ParitionIndexRTransformer.java (revision 3521)
35 35
	 * @throws RWorkspaceException the r workspace exception
36 36
	 */
37 37
	@Override
38
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
38
	public String fromTXMtoR(PartitionIndex o) throws RWorkspaceException {
39 39
		if (!(o instanceof PartitionIndex)) return null;
40 40
		
41 41
		PartitionIndex index = (PartitionIndex) o;
TXM/trunk/org.txm.index.core/src/org/txm/index/core/r/LexiconRTransformer.java (revision 3521)
36 36
	 * @throws RWorkspaceException the r workspace exception
37 37
	 */
38 38
	@Override
39
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
39
	public String fromTXMtoR(Lexicon o) throws RWorkspaceException {
40 40
		if (!(o instanceof Lexicon)) return null;
41 41
		
42 42
		Lexicon index = (Lexicon) o;
......
74 74
		rw.eval("rownames(" + symbol + " ) <- vockeywords"); //$NON-NLS-1$ //$NON-NLS-2$
75 75
		rw.eval(symbol + "<- list(data=" + symbol + ")"); //$NON-NLS-1$ //$NON-NLS-2$
76 76
		
77
		rw.eval("rm(vocfreq, vockeywords, voccolnames)");
78
		
77 79
		novoc++;
78 80
		return symbol;
79 81
	}
TXM/trunk/org.txm.index.core/src/org/txm/index/core/r/IndexRTransformer.java (revision 3521)
36 36
	 * @throws RWorkspaceException the r workspace exception
37 37
	 */
38 38
	@Override
39
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
39
	public String fromTXMtoR(Index o) throws RWorkspaceException {
40 40
		if (!(o instanceof Index)) return null;
41 41
		
42 42
		Index index = (Index) o;
......
74 74
		rw.eval("rownames(" + symbol + " ) <- vockeywords"); //$NON-NLS-1$ //$NON-NLS-2$
75 75
		rw.eval(symbol + "<- list(data=" + symbol + ")"); //$NON-NLS-1$ //$NON-NLS-2$
76 76
		
77
		rw.eval("rm(vocfreq, vockeywords, voccolnames)");
77 78
		novoc++;
78 79
		return symbol;
79 80
	}
TXM/trunk/org.txm.partition.core/src/org/txm/partition/core/r/PartitionDimensionsRTransformer.java (revision 3521)
1
package org.txm.partition.core.r;
2

  
3
import java.util.Arrays;
4
import java.util.List;
5

  
6
import org.txm.core.results.TXMResult;
7
import org.txm.partition.core.functions.PartitionDimensions;
8
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
9
import org.txm.searchengine.cqp.corpus.Part;
10
import org.txm.statsengine.r.core.RTransformer;
11
import org.txm.statsengine.r.core.RWorkspace;
12
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
13

  
14

  
15
public class PartitionDimensionsRTransformer extends RTransformer<PartitionDimensions> {
16
	
17
	public static int nrec = 1;
18
	
19
	public PartitionDimensionsRTransformer() {
20
		
21
		// TODO Auto-generated constructor stub
22
	}
23
	
24
	@Override
25
	public PartitionDimensions fromRtoTXM(String symbol) throws RWorkspaceException {
26
		
27
		// TODO Auto-generated method stub
28
		return null;
29
	}
30
	
31
	@Override
32
	public String fromTXMtoR(PartitionDimensions o) throws RWorkspaceException {
33
		
34
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
35
//		System.out.println("rw="+rw);
36
		List<Part> parts = o.getParts(false);
37
//		System.out.println("parts="+parts);
38
		int[] vector = new int[parts.size()];
39
		String[] svector = new String[parts.size()];
40
		for (int i = 0 ; i < parts.size() ; i++) {
41
			try {
42
				vector[i] = parts.get(i).getSize();
43
				svector[i] = parts.get(i).getName();
44
			}
45
			catch (CqiClientException e) {
46
				// TODO Auto-generated catch block
47
				e.printStackTrace();
48
			}
49
		}
50
//		System.out.println("vector="+Arrays.toString(vector));
51
//		System.out.println("svector="+Arrays.toString(svector));
52
		String s = "PartitionDimensions"+nrec;
53
		rw.addVectorToWorkspace(s, vector);
54
		rw.addVectorToWorkspace("names("+s+")", svector);
55
		nrec++;
56
		return s;
57
	}
58
	
59
}
0 60

  
TXM/trunk/org.txm.partition.core/plugin.xml (revision 3521)
28 28
            fileNamePrefix="partition_dimensions_pie">
29 29
      </ChartCreator>
30 30
   </extension>
31
   <extension
32
         point="org.txm.statsengine.r.core.RTransformer">
33
      <transformer
34
            class="org.txm.partition.core.r.PartitionDimensionsRTransformer"
35
            type="org.txm.partition.core.functions.PartitionDimensions">
36
      </transformer>
37
   </extension>
31 38

  
32 39
</plugin>
TXM/trunk/org.txm.concordance.core/src/org/txm/concordance/core/r/ConcordanceRTransformer.java (revision 3521)
22 22
	}
23 23

  
24 24
	@Override
25
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
25
	public String fromTXMtoR(Concordance o) throws RWorkspaceException {
26 26
		
27 27
		if (!(o instanceof Concordance)) return null;
28 28
		
......
62 62
				//+ ", query=\""+conc.query.getQueryString()+"\""
63 63
				+ ")"); //$NON-NLS-1$
64 64

  
65
		rw.eval("rm(concrefs, conclefts, conckeywords, concrights)");
65 66
		return symbol;
66 67
	}
67 68

  
TXM/trunk/org.txm.specificities.rcp/plugin.xml (revision 3521)
175 175
                  ifEmpty="false"
176 176
                  operator="and">
177 177
               <instanceof
178
                     value="org.txm.functions.specificities.SpecificitesResult">
178
                     value="org.txm.specificities.core.functions.Specificities">
179 179
               </instanceof>
180 180
            </iterate>
181 181
         </with>
TXM/trunk/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 3521)
40 40
import org.eclipse.osgi.util.NLS;
41 41
import org.rosuda.REngine.REXP;
42 42
import org.txm.core.messages.TXMCoreMessages;
43
import org.txm.core.preferences.TBXPreferences;
44 43
import org.txm.core.preferences.TXMPreferences;
45 44
import org.txm.core.results.Parameter;
46 45
import org.txm.core.results.TXMParameters;

Formats disponibles : Unified diff