Revision 2229

tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesR.java (revision 2229)
84 84
		specIndex = compute(symbol, lt, null, null);
85 85
	}
86 86

  
87
	/**
88
	 * compute Specificites of subcorpus using the textometry package functions.
89
	 *
90
	 * @param lexicon the lexicon
91
	 * @param subLexicon the sub lexicon
92
	 * @return the double[][]
93
	 * @throws StatException the stat exception
94
	 * @throws REXPMismatchException 
95
	 * @throws RserveException 
96
	 */
97
	public SpecificitiesR(Vector lexicon, Vector subLexicon) throws StatException, RserveException, REXPMismatchException {
98
		super(prefixR+(specif_counter++));
87
//	/**
88
//	 * compute Specificites of subcorpus using the textometry package functions.
89
//	 *
90
//	 * @param lexicon the lexicon
91
//	 * @param subLexicon the sub lexicon
92
//	 * @return the double[][]
93
//	 * @throws StatException the stat exception
94
//	 * @throws REXPMismatchException 
95
//	 * @throws RserveException 
96
//	 */
97
//	public SpecificitiesR(Vector lexicon, Vector subLexicon) throws StatException, RserveException, REXPMismatchException {
98
//		super(prefixR+(specif_counter++));
99
//
100
//		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
101
//		rw.safeEval("library(textometry)"); //$NON-NLS-1$
102
//		REXP r = rw.callFunction("specificities.lexicon.new", new QuantitativeDataStructure[] { lexicon, subLexicon }, symbol); //$NON-NLS-1$
103
//		// double[] res = RWorkspace.toDouble(r);
104
//		//System.out.println(" build double matrix");
105
//		specIndex = r.asDoubleMatrix();
106
//	}
99 107

  
100
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
101
		rw.safeEval("library(textometry)"); //$NON-NLS-1$
102
		REXP r = rw.callFunction("specificities.lexicon.new", new QuantitativeDataStructure[] { lexicon, subLexicon }, symbol); //$NON-NLS-1$
103
		// double[] res = RWorkspace.toDouble(r);
104
		//System.out.println(" build double matrix");
105
		specIndex = r.asDoubleMatrix();
106
	}
107

  
108 108
	/**
109 109
	 * compute Specificites of lexical table using the textometry package functions.
110 110
	 *
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 2229)
46 46
import org.txm.core.results.TXMResult;
47 47
import org.txm.lexicaltable.core.functions.LexicalTable;
48 48
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
49
import org.txm.objects.CorpusBuild;
50 49
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
51
import org.txm.searchengine.cqp.corpus.CQPCorpus;
52
import org.txm.searchengine.cqp.corpus.CQPLexicon;
53 50
import org.txm.searchengine.cqp.corpus.Partition;
54 51
import org.txm.searchengine.cqp.corpus.Property;
55
import org.txm.searchengine.cqp.corpus.Subcorpus;
56 52
import org.txm.searchengine.cqp.corpus.WordProperty;
57 53
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
58 54
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
......
167 163
		}
168 164

  
169 165
		ILexicalTable data = this.lexicalTable.getData();
170

  
171 166
		SpecificitiesR rSpecificities = new SpecificitiesR(data);
172 167
		double[][] specIndex = rSpecificities.getScores();
173 168

  
174
		if (this.lexicalTable.getPartition() != null) {
175
			init(symbol, specIndex); 
176
		}
177
		else {
169
		//TODO if test no more necessary ? only if lexicalTable symb
170
//		if (this.lexicalTable.getPartition() != null) {
171
//			init(symbol, specIndex); 
172
//		}
173
//		else {
178 174
			init(rSpecificities.getSymbol(), specIndex); //$NON-NLS-1$
179
		}
175
//		}
180 176
		//}
181 177

  
182 178
		return true;
......
239 235
			for (int j = 0 ; j < indices[i].length ; j++) {
240 236
				if (indices[i][j] > MAX) {
241 237
					indices[i][j] = MAX;
242
				}
243
				else if (indices[i][j] < MIN) {
238
				} else if (indices[i][j] < MIN) {
244 239
					indices[i][j] = MIN;
245 240
				}
246 241
			}
......
298 293
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
299 294
		rw.voidEval("library(textometry)");
300 295
		REXP rez = rw.eval("specificities(matrix(c("+f+", "+(t-f)+", "+(F-f)+", "+(T-t-F+f)+"), ncol=2))");
301
		if (rez != null) return rez.asDoubles()[0];
296
		if (rez != null) {
297
			return rez.asDoubles()[0];
298
		}
302 299
		return 0.0d;
303 300
	}
304 301

  
......
311 308
		this.getLexicalTable().setUnitProperty(unitProperty);
312 309
	}
313 310

  
314

  
315

  
316

  
317 311
	/**
318 312
	 * Gets the type focus.
319 313
	 *
......
339 333
	 * @throws StatException the stat exception
340 334
	 */
341 335
	public int getColumnsCount() throws StatException {
342
		if (lexicalTable != null)
336
		if (lexicalTable != null) {
343 337
			try {
344 338
				return lexicalTable.getNColumns();
345 339
			} catch (Exception e) {
......
347 341
				e.printStackTrace();
348 342
				return 0;
349 343
			}
350
		else
344
		} else {
351 345
			return getColumnsNames().length;
346
		}
352 347
	}
353 348

  
354 349
	/**
......
414 409
		//		}
415 410
	}
416 411

  
412
	public LexicalTable getParent() {
413
		return (LexicalTable) this.parent;
414
	}
415
	
417 416
	/**
418 417
	 * Gets the specificities index.
419 418
	 * 
......
502 501
	public int[] getFormFrequencies() throws Exception {
503 502
		//System.out.println("get freq by table");
504 503
		Vector formFrequencies = lexicalTable.getRowMarginsVector();
505
		if (rowindex != null) {
506
			formFrequencies = formFrequencies.get(rowindex);
507
		}
504
//		if (rowindex != null) {
505
//			formFrequencies = formFrequencies.get(rowindex);
506
//		}
508 507
		return formFrequencies.asIntArray();
509 508
	}
510 509

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 2229)
53 53
import org.txm.rcp.swt.widget.ThresholdsGroup;
54 54
import org.txm.rcp.swt.widget.structures.PropertiesComboViewer;
55 55
import org.txm.searchengine.cqp.corpus.CQPCorpus;
56
import org.txm.searchengine.cqp.corpus.Subcorpus;
56 57
import org.txm.specificities.core.functions.Specificities;
57 58
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
58 59
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages;
......
226 227
				return;
227 228
			}
228 229

  
229
			
230
			int len = lexicalTableColumnNames.length;
231
			if (len == 2) {
232
				len--; // show only the first column specifs since they are the same (modulo signus)
233
			}
230 234
			if(!update
231 235
//					//&& this.getResult().hasBeenComputedOnce()
232 236
					)	{
233 237

  
238
				
239
				
234 240
				// remove lexical table columns if already exist
235 241
//				int columnsCount = specificitesTable.getColumnCount();
236 242
//				System.out.println("SpecificitiesEditor.updateEditorFromResult(): column count = " + columnsCount);
......
241 247
				
242 248
				// System.out.println("partnames: "+Arrays.toString(partNames));
243 249
				 // for each lexical table column
244
				for (int i = 0, firstLexicalTableColumnIndex = 3; i < lexicalTableColumnNames.length ; i++, firstLexicalTableColumnIndex += 2) {
250
				for (int i = 0, firstLexicalTableColumnIndex = 3; i < len ; i++, firstLexicalTableColumnIndex += 2) {
245 251

  
246 252
					//System.err.println("SpecificitiesEditor.updateEditorFromResult() creating column freq at index " + firstLexicalTableColumnIndex);
247 253
					
......
309 315
			typeFrequencyColumn.pack();
310 316
			
311 317
			// Updating the table headers from lexical table values
312
			for (int i = 0, firstLexicalTableColumnIndex = 3; i < lexicalTableColumnNames.length ; i++, firstLexicalTableColumnIndex += 2) {
318
			for (int i = 0, firstLexicalTableColumnIndex = 3; i < len ; i++, firstLexicalTableColumnIndex += 2) {
313 319
				// frequency columns
314 320
				TableColumn freqpartTableColumn = specificitesTable.getColumn(firstLexicalTableColumnIndex);
315 321
				text = lexicalTableColumnNames[i];
......
322 328
				freqpartTableColumn.setAlignment(SWT.RIGHT);
323 329
				freqpartTableColumn.pack();
324 330
			}
325
			
326
			
327
			
331

  
328 332
			// Pack the columns so the label of the sort column is not truncated due of the sorting order arrow display			
329 333
			TXMEditor.packColumns(viewer);
330 334
			
331
		}
332
		catch (Exception e) {
335
		} catch (Exception e) {
333 336
			// TODO Auto-generated catch block
334 337
			e.printStackTrace();
335 338
		}
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifities.java (revision 2229)
32 32
import org.txm.core.messages.TXMCoreMessages;
33 33
import org.txm.index.core.functions.PartitionIndex;
34 34
import org.txm.lexicaltable.core.functions.LexicalTable;
35
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor;
36 35
import org.txm.rcp.editors.TXMEditor;
37 36
import org.txm.rcp.handlers.BaseAbstractHandler;
38 37
import org.txm.searchengine.cqp.corpus.Partition;

Also available in: Unified diff