Révision 711

tmp/org.txm.searchengine.cqp.rcp/plugin.xml (revision 711)
138 138
         </command>
139 139
            </menuContribution>
140 140
      <menuContribution
141
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView?after=org.txm.rcp.corporaview.corpus.manage">
142
         <command
143
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
144
               icon="icons/functions/subcorpus.png"
145
               style="push">
146
            <visibleWhen
147
                  checkEnabled="false">
148
               <reference
149
                     definitionId="OneCorpusSelected">
150
               </reference>
151
            </visibleWhen>
152
         </command>
153
         <command
154
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreatePartition"
155
               icon="icons/functions/partition.png"
156
               style="push">
157
            <visibleWhen
158
                  checkEnabled="false">
159
               <reference
160
                     definitionId="OneCorpusSelected">
161
               </reference>
162
            </visibleWhen>
163
         </command>
164
      </menuContribution>
165
      <menuContribution
141 166
            locationURI="menu:menu.file.export">
142 167
         <command
143 168
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.ExportCorpus"
......
154 179
         </command>
155 180
      </menuContribution>
156 181
      <menuContribution
182
            locationURI="menu:menu.corpus?after=menu.corpus.build">
183
         <command
184
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
185
               icon="icons/functions/subcorpus.png"
186
               style="push">
187
            <visibleWhen
188
                  checkEnabled="false">
189
               <reference
190
                     definitionId="OneCorpusSelected">
191
               </reference>
192
            </visibleWhen>
193
         </command>
194
         <command
195
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreatePartition"
196
               icon="icons/functions/partition.png"
197
               style="push">
198
            <visibleWhen
199
                  checkEnabled="false">
200
               <reference
201
                     definitionId="OneCorpusSelected">
202
               </reference>
203
            </visibleWhen>
204
         </command>
205
      </menuContribution>
206
      <menuContribution
157 207
            allPopups="true"
158 208
            locationURI="toolbar:org.txm.rcp.toolbarfile">
159 209
            <command
......
171 221
            </command>
172 222
      </menuContribution>
173 223
      <menuContribution
174
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.synopticedition.rcp.handlers.OpenEdition">
224
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.rcp.toolbarcorpus.corpus">
175 225
         <command
176 226
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
177 227
               icon="icons/functions/subcorpus.png"
......
196 246
               </visibleWhen>
197 247
            </command>
198 248
      </menuContribution>
199
      <menuContribution
200
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView?after=org.txm.rcp.corporaview.corpus.manage">
201
         <command
202
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
203
               icon="icons/functions/subcorpus.png"
204
               style="push">
205
            <visibleWhen
206
                  checkEnabled="false">
207
               <reference
208
                     definitionId="OneCorpusSelected">
209
               </reference>
210
            </visibleWhen>
211
         </command>
212
         <command
213
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreatePartition"
214
               icon="icons/functions/partition.png"
215
               style="push">
216
            <visibleWhen
217
                  checkEnabled="false">
218
               <reference
219
                     definitionId="OneCorpusSelected">
220
               </reference>
221
            </visibleWhen>
222
         </command>
223
      </menuContribution>
224
      <menuContribution
225
            locationURI="menu:menu.corpus?after=menu.corpus.build">
226
         <command
227
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
228
               icon="icons/functions/subcorpus.png"
229
               style="push">
230
            <visibleWhen
231
                  checkEnabled="false">
232
               <reference
233
                     definitionId="OneCorpusSelected">
234
               </reference>
235
            </visibleWhen>
236
         </command>
237
         <command
238
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreatePartition"
239
               icon="icons/functions/partition.png"
240
               style="push">
241
            <visibleWhen
242
                  checkEnabled="false">
243
               <reference
244
                     definitionId="OneCorpusSelected">
245
               </reference>
246
            </visibleWhen>
247
         </command>
248
      </menuContribution>
249 249
   </extension>
250 250
   <extension
251 251
         point="org.eclipse.ui.preferencePages">
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 711)
37 37
import java.util.Arrays;
38 38
import java.util.List;
39 39

  
40
import org.rosuda.REngine.REXP;
40 41
import org.txm.core.results.Parameter;
41 42
import org.txm.core.results.TXMParameters;
42 43
import org.txm.core.results.TXMResult;
......
55 56
import org.txm.utils.logger.Log;
56 57

  
57 58
/**
58
 * Holds specificities computation result.
59
 * Compute specificities indexes using a {@link LexicalTable}
59 60
 * 
61
 * for alternative and test usages, the Specificities.computeIndex(...) method can be used.
62
 * 
60 63
 * @author mdecorde
61 64
 * @author sloiseau
62 65
 * 
......
129 132
		this.lexicalTable = lexicalTable;
130 133
	}
131 134
	
135
	/**
136
	 * Utility method to compute the specificity index of a word in a subcorpus.
137
	 * <br>
138
	 * Calls the R specificities function with a matrix built with the parameters
139
	 * <pre>
140
	 * f	F-f
141
	 * t-f	T-t-F+f
142
	 * </pre>
143
	 * 
144
	 * @param f word frequency in subcorpus
145
	 * @param F word frequency in corpus
146
	 * @param t subcorpus size
147
	 * @param T corpus size
148
	 * @return the specificity index
149
	 * @throws Exception
150
	 */
151
	public static double computeIndex(int f, int F, int t, int T) throws Exception {
152
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
153
		rw.voidEval("library(textometry)");
154
		REXP rez = rw.eval("specificities(matrix(c("+f+", "+(t-f)+", "+(F-f)+", "+(T-t-F+f)+"), ncol=2))");
155
		if (rez != null) return rez.asDoubles()[0];
156
		return 0.0d;
157
	}
158
	
132 159
	@Override
133 160
	protected boolean _compute() throws Exception {
134 161
		
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 711)
29 29
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
30 30

  
31 31
/**
32
 * ILexicalTable logic + TXMResult management methods
32
 * Holds the word frequencies table of a {@link Partition} seen through a word property.
33 33
 * 
34
 * 
34 35
 * @author mdecorde
35 36
 *
36 37
 */
......
39 40
	public static Integer LEXICALTABLE_COUNTER = new Integer(1);
40 41
	public static String SYMBOL_BASE = "LexicalTable_"; //$NON-NLS-1$
41 42

  
42
	/** the statengine data object */
43
	/** stores the R table computed */
43 44
	protected ILexicalTable statsData;
44

  
45
	
46
	
47
	
45
	/** stores the R table already computed. the _compute method won't update the result*/
46
	protected ILexicalTable alreadyComputedStatsData;
47
		
48 48
	/**
49 49
	 * The property.
50 50
	 */
......
69 69
	protected boolean pUseAllOccurrences;
70 70
	
71 71
	/**
72
	 * Build a LexicalTable result with an already computed frequency R table
72 73
	 * 
73 74
	 * @param corpus
74 75
	 * @param analysisProperty
......
77 78
	public LexicalTable(Corpus corpus, Property analysisProperty, ILexicalTable itable) {
78 79
		super(corpus);
79 80
		this.pProperty = analysisProperty;
80
		this.statsData = itable;
81
		this.alreadyComputedStatsData = itable;
81 82
	}
82 83

  
83 84
	
84 85
	/**
86
	 * Build a LexicalTable with the {@link Subcorpus} words and {@link Subcorpus} parent remaining words.
85 87
	 * 
86 88
	 * @param corpus
87
	 * @param analysisProperty
89
	 * @param analysisProperty the property to count
88 90
	 * @throws Exception
89 91
	 */
90
	public LexicalTable(Corpus corpus, Property analysisProperty) throws Exception {
92
	public LexicalTable(Subcorpus corpus, Property analysisProperty) throws Exception {
91 93
		this(corpus, analysisProperty, null);
92 94
	}
93 95
	
94 96
	/**
97
	 * Build a LexicalTable with the Subcorpus words and Subcorpus parent remaining words.
95 98
	 * 
96 99
	 * @param corpus
97 100
	 * @throws Exception
98 101
	 */
99
	public LexicalTable(Corpus corpus) throws Exception {
102
	public LexicalTable(Subcorpus corpus) throws Exception {
100 103
		this(corpus, corpus.getDefaultProperty());
101 104
	}
102 105
	
......
154 157
	private LexicalTable(TXMResult parent, Property analysisProperty, int fMin, int vMax, boolean useAllOccurrences, ILexicalTable iTable)	{
155 158
		super(parent);
156 159
		this.setParameters(analysisProperty, fMin, vMax, useAllOccurrences);
157
		this.statsData = iTable;
160
		this.alreadyComputedStatsData = iTable;
158 161
	}
159 162

  
160 163
	
......
347 350
	@Override
348 351
	protected boolean _compute() throws Exception {
349 352

  
350
		if (this.parent instanceof Subcorpus) {
353
		this.statsData = null; // reset frequencies
354
		
355
		if (alreadyComputedStatsData != null) {
356
			this.statsData = alreadyComputedStatsData;
357
		}
358
		else if (this.parent instanceof Subcorpus) {
351 359

  
352 360
			this.subTask("Computing from Subcorpus.");
353 361
			
......
374 382
			this._computeFromIndexes(Arrays.asList((Index)this.parent));
375 383
		}
376 384
		
385
		if (this.statsData == null) { // no statsData computed or given
386
			return false;
387
		}
388
		
377 389
		//this.statsData.filter(this.pVMaxFilter, this.pfMinFilter);
378 390
		// FIXME old version
379 391
		this.statsData.cut(this.pVMaxFilter);
tmp/org.txm.internalview.rcp/plugin.xml (revision 711)
12 12
         point="org.eclipse.ui.menus">
13 13
      <menuContribution
14 14
            allPopups="false"
15
            locationURI="toolbar:org.txm.rcp.toolbartools?after=ComputeInformationFromCorpus">
15
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.information.rcp.handlers.ComputeInformation">
16 16
         <command
17 17
               commandId="org.txm.internalview.rcp.handlers.ComputeInternalView"
18 18
               icon="icons/internal_view.png"
......
27 27
      </menuContribution>
28 28
      <menuContribution
29 29
            allPopups="false"
30
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView?after=org.txm.rcp.corporaview.corpus.read">
30
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView?after=org.txm.information.rcp.handlers.ComputeInformation">
31 31
         <command
32 32
               commandId="org.txm.internalview.rcp.handlers.ComputeInternalView"
33 33
               icon="icons/internal_view.png"
......
41 41
         </command>
42 42
      </menuContribution>
43 43
      <menuContribution
44
            locationURI="menu:menu.corpus?after=menu.corpus.read">
44
            locationURI="menu:menu.corpus?after=org.txm.information.rcp.handlers.ComputeInformation">
45 45
         <command
46 46
               commandId="org.txm.internalview.rcp.handlers.ComputeInternalView"
47 47
               icon="icons/internal_view.png"
tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngines.java (revision 711)
34 34
			} catch(Exception e) {
35 35
				System.out.println("Error: fail to instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
36 36
				e.printStackTrace();
37
			} 
37
			}
38 38
		}
39 39

  
40 40
		return engines.size() > 0;
tmp/org.txm.synopticeditor.rcp/plugin.xml (revision 711)
27 27
      </menuContribution>
28 28
      <menuContribution
29 29
            allPopups="true"
30
            locationURI="toolbar:org.txm.rcp.toolbarcorpus">
30
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.rcp.toolbarcorpus.read">
31 31
         <command
32 32
               commandId="org.txm.synopticedition.rcp.handlers.OpenEdition"
33 33
               icon="icons/objects/edition.png"
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 711)
201 201
			selections = null;
202 202
		}
203 203

  
204
		String tmp = Toolbox.getTXMHOMEPATH() + "/scripts"; //$NON-NLS-1$
205
		if (previousScriptRootDir == null || !tmp.equals(previousScriptRootDir)) {
206
			previousScriptRootDir = tmp;
207
			gse = null;
208
			//System.out.println("SCRIPT ROOT DIR CHANGED tmp="+tmp);
209
		}
204
//		 //$NON-NLS-1$
205
//		if (previousScriptRootDir == null || !tmp.equals(previousScriptRootDir)) {
206
//			previousScriptRootDir = tmp;
207
//			gse = null;
208
//			//System.out.println("SCRIPT ROOT DIR CHANGED tmp="+tmp);
209
//		}
210 210

  
211
		String scriptsRootDirectories = Toolbox.getTXMHOMEPATH() + "/scripts";
211 212
		String dir = currentRootDir.getAbsolutePath();
212 213
		String path = scriptfile.getAbsolutePath();
213 214
		if (!path.startsWith(dir)) {
......
216 217
		}
217 218
		final String relativepath = path.substring(dir.length()+1);
218 219

  
219
		if (gse == null) {
220
			gse = buildGSE(previousScriptRootDir, scriptfile);
220
		//if (gse == null) {
221
			gse = buildGSE(scriptsRootDirectories, scriptfile);
221 222
			if (gse == null) {
222 223
				System.out.println("Could not create the Groovy script engine. Aborting.");
223 224
				return;
224 225
			}
225
		}
226
		//}
226 227

  
227 228
		JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.ExecuteRScript_1,scriptfile.getName())) {
228 229
			@Override
......
243 244
					
244 245
					System.out.println(NLS.bind(TXMUIMessages.ExecuteRScript_1, scriptfile.getName()));
245 246
					long time = System.currentTimeMillis();
247
					System.out.println(relativepath);
246 248
					gse.run(relativepath, binding);
247 249
					
248 250
					System.out.println(TXMUIMessages.ExecuteRScript_2+(System.currentTimeMillis()-time)+TXMUIMessages.ExecuteGroovyScript_0);
tmp/org.txm.rcp/plugin.xml (revision 711)
1300 1300
      <menuContribution
1301 1301
            allPopups="true"
1302 1302
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
1303
         <separator
1304
               name="org.txm.rcp.toolbars.begin"
1305
               visible="false">
1306
         </separator>
1303 1307
         <toolbar
1304 1308
               id="org.txm.rcp.toolbars.result">
1305 1309
            <command
......
1356 1360
                  </or>
1357 1361
               </visibleWhen>
1358 1362
            </command>
1363
         </toolbar>
1364
         <separator
1365
               name="org.txm.rcp.toolbar.separator1"
1366
               visible="false">
1367
         </separator>
1368
         <toolbar
1369
               id="org.txm.rcp.toolbarcorpus">
1370
            <separator
1371
                  name="org.txm.rcp.toolbarcorpus.read"
1372
                  visible="false">
1373
            </separator>
1359 1374
            <command
1360 1375
                  commandId="org.txm.rcp.commands.base.DeleteObject?after=org.txm.information.rcp.handlers.ComputeInformation"
1361 1376
                  icon="icons/functions/Delete.png"
......
1391 1406
                  </or>
1392 1407
               </visibleWhen>
1393 1408
            </command>
1394
         </toolbar>
1395
         <separator
1396
               name="org.txm.rcp.toolbar.separator1"
1397
               visible="true">
1398
         </separator>
1399
         <toolbar
1400
               id="org.txm.rcp.toolbarcorpus">
1401 1409
            
1402 1410
            <separator
1403 1411
                  name="org.txm.rcp.toolbarcorpus.corpus"
1404
                  visible="true">
1412
                  visible="false">
1405 1413
            </separator>
1406 1414
            <separator
1407 1415
                  name="org.txm.rcp.toolbarcorpus.annotation"
1408
                  visible="true">
1416
                  visible="false">
1409 1417
            </separator>
1410 1418
         </toolbar>
1411 1419
         <separator
......
1979 1987
                  name="org.txm.rcp.corporaview.corpus.read"
1980 1988
                  visible="true">
1981 1989
            </separator>
1982
            <separator
1983
                  name="org.txm.rcp.corporaview.corpus.manage"
1984
                  visible="true">
1985
            </separator>
1986 1990
            
1987 1991
            <command
1988 1992
                  commandId="org.txm.rcp.commands.base.DeleteObject"
......
2019 2023
               </visibleWhen>
2020 2024
            </command>
2021 2025
            <separator
2026
                  name="org.txm.rcp.corporaview.corpus.manage"
2027
                  visible="true">
2028
            </separator>
2029
            <separator
2022 2030
                  name="org.txm.rcp.corporaview.annotation"
2023 2031
                  visible="true">
2024 2032
            </separator>

Formats disponibles : Unified diff