Révision 2397

tmp/org.txm.concordance.rcp/.classpath (revision 2397)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		    <accessrules>
6
			      <accessrule kind="accessible" pattern="**"/>
7
		    </accessrules>
8
	  </classpathentry>
9
	  <classpathentry kind="src" path="src"/>
10
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.dictionary.rcp/.classpath (revision 2397)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		    <accessrules>
6
			      <accessrule kind="accessible" pattern="**"/>
7
		    </accessrules>
8
	  </classpathentry>
9
	  <classpathentry kind="src" path="src"/>
10
	  <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
11
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry exported="true" kind="con"
13
		path="GROOVY_DSL_SUPPORT" />
14
	<classpathentry kind="output" path="bin" />
12 15
</classpath>
tmp/org.txm.internalview.core/.classpath (revision 2397)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		    <accessrules>
6
			      <accessrule kind="accessible" pattern="**"/>
7
		    </accessrules>
8
	  </classpathentry>
9
	  <classpathentry kind="src" path="src"/>
10
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.internalview.core/src/org/txm/internalview/core/messages/InternalViewCoreMessages.java (revision 2397)
15 15
	private static final String BUNDLE_NAME = "org.txm.internalview.core.messages.messages"; //$NON-NLS-1$
16 16
	
17 17
	public static String RESULT_TYPE;
18

  
19 18
	
20
	public static String structureInformationsColon; 
21
	public static String internalViewColonFailedToRetrieveStructPropertiesValuesColonP0; 
22
	public static String noStructureInformations; 
23 19
	
20
	public static String structureInformationsColon;
21
	
22
	public static String internalViewColonFailedToRetrieveStructPropertiesValuesColonP0;
23
	
24
	public static String noStructureInformations;
25
	
24 26
	static {
25 27
		Utf8NLS.initializeMessages(BUNDLE_NAME, InternalViewCoreMessages.class);
26 28
	}
tmp/org.txm.internalview.core/src/org/txm/internalview/core/functions/package.html (revision 2397)
1 1
<html>
2 2
<body>
3
<p>Internal view</p>
3
	<p>Internal view</p>
4 4
</body>
5 5
</html>
tmp/org.txm.internalview.core/src/org/txm/internalview/core/functions/InternalView.java (revision 2397)
30 30
import org.txm.utils.logger.Log;
31 31

  
32 32
/**
33
 * Internal view. 
33
 * Internal view.
34 34
 * 
35 35
 * @author mdecorde
36 36
 * @author sjacquot
37 37
 *
38 38
 */
39
public class InternalView extends TXMResult  {
40

  
39
public class InternalView extends TXMResult {
40
	
41 41
	protected List<Match> matches = new ArrayList<Match>();
42
	
42 43
	protected int nmatches = 0;
43

  
44
	
44 45
	/**
45 46
	 * Current page.
46 47
	 */
47
	@Parameter(key=InternalViewPreferences.CURRENT_PAGE)
48
	@Parameter(key = InternalViewPreferences.CURRENT_PAGE)
48 49
	protected int pCurrentPage;
49

  
50
	
50 51
	/**
51 52
	 * Structural unit to explore.
52 53
	 */
53
	@Parameter(key=TXMPreferences.STRUCTURAL_UNIT)
54
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT)
54 55
	protected StructuralUnit pStructuralUnit;
55

  
56
	
56 57
	/**
57 58
	 * Word properties to display.
58 59
	 */
59
	@Parameter(key=TXMPreferences.UNIT_PROPERTIES)
60
	@Parameter(key = TXMPreferences.UNIT_PROPERTIES)
60 61
	protected List<WordProperty> pWordProperties;
61

  
62
	
62 63
	/**
63 64
	 * Structural units to display.
64 65
	 */
65
	@Parameter(key=TXMPreferences.STRUCTURAL_UNIT_PROPERTIES)
66
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT_PROPERTIES)
66 67
	protected List<StructuralUnitProperty> pStructuralUnitsProperties;
67

  
68

  
68
	
69
	
69 70
	/**
70 71
	 * 
71 72
	 * @param parent
......
73 74
	public InternalView(CQPCorpus parent) {
74 75
		super(parent);
75 76
	}
76

  
77
	
77 78
	/**
78 79
	 * 
79 80
	 * @param parametersNodePath
......
81 82
	public InternalView(String parametersNodePath) {
82 83
		super(parametersNodePath);
83 84
	}
84

  
85

  
86

  
85
	
86
	
87
	
87 88
	@Override
88 89
	public boolean loadParameters() throws Exception {
89 90
		try {
90 91
			String str = this.getStringParameterValue(TXMPreferences.STRUCTURAL_UNIT);
91 92
			this.pStructuralUnit = this.getCorpus().getStructuralUnit(str);
92
		} catch (Exception e) {
93
		}
94
		catch (Exception e) {
93 95
			Log.printStackTrace(e);
94 96
		}
95 97
		try {
96 98
			String str = this.getStringParameterValue(TXMPreferences.UNIT_PROPERTIES);
97 99
			this.pWordProperties = (List<WordProperty>) WordProperty.stringToProperties(this.getCorpus(), str);
98
		} catch (Exception e2) {
100
		}
101
		catch (Exception e2) {
99 102
			Log.printStackTrace(e2);
100 103
		}
101 104
		try {
102 105
			String str = this.getStringParameterValue(TXMPreferences.STRUCTURAL_UNIT_PROPERTIES);
103 106
			this.pStructuralUnitsProperties = StructuralUnitProperty.stringToProperties(this.getCorpus(), str);
104
		} catch (Exception e3) {
107
		}
108
		catch (Exception e3) {
105 109
			Log.printStackTrace(e3);
106 110
		}
107 111
		return true;
108 112
	}
109

  
110

  
113
	
114
	
111 115
	@Override
112 116
	protected boolean _compute() throws Exception {
113

  
114
		if(this.hasParameterChanged(InternalViewPreferences.STRUCTURAL_UNIT))	{
117
		
118
		if (this.hasParameterChanged(InternalViewPreferences.STRUCTURAL_UNIT)) {
115 119
			
116 120
			// reset the current page (only if the result has been computed at least once otherwise it breaks the deserialization)
117
			if(this.hasBeenComputedOnce)	{
121
			if (this.hasBeenComputedOnce) {
118 122
				this.pCurrentPage = 0;
119 123
			}
120 124
			
121
			//find struct start-end
125
			// find struct start-end
122 126
			CQLQuery query = new CQLQuery("<" + pStructuralUnit.getName() + "> [] expand to " + pStructuralUnit); //$NON-NLS-1$ //$NON-NLS-2$
123
			//System.out.println(query);
127
			// System.out.println(query);
124 128
			QueryResult result = getCorpus().query(query, "test", false); //$NON-NLS-1$
125 129
			nmatches = result.getNMatch();
126 130
			if (nmatches > 0) {
127 131
				matches = result.getMatches();
128 132
			}
129 133
			result.drop();
130
			//System.out.println(matches);
134
			// System.out.println(matches);
131 135
			dirty = false;
132 136
			return (nmatches > 0);
133 137
		}
134 138
		return true;
135 139
	}
136

  
137

  
138

  
139

  
140
	
141
	
142
	
143
	
140 144
	@Override
141 145
	public boolean canCompute() {
142
		return getCorpus() != null && 
143
				pStructuralUnit != null && 
144
				pWordProperties != null && 
145
				pWordProperties.size() > 0 && 
146
				pStructuralUnitsProperties != null && 
146
		return getCorpus() != null &&
147
				pStructuralUnit != null &&
148
				pWordProperties != null &&
149
				pWordProperties.size() > 0 &&
150
				pStructuralUnitsProperties != null &&
147 151
				pStructuralUnitsProperties.size() > 0;
148 152
	}
149

  
153
	
150 154
	/**
151 155
	 * get the ith page and set the current page number to i
152 156
	 * 
......
156 160
	 */
157 161
	protected LinkedHashMap<Property, List<String>> getPageContent(int i) throws CqiClientException {
158 162
		LinkedHashMap<Property, List<String>> rez = new LinkedHashMap<Property, List<String>>();
159

  
163
		
160 164
		if (i >= 0 && i < nmatches) {
161 165
			Match m = matches.get(i);
162 166
			Collection<? extends Integer> positions = m.getRange();
163 167
			int[] p = new int[positions.size()];
164 168
			int c = 0;
165
			for(int v : positions) {
169
			for (int v : positions) {
166 170
				p[c++] = v;
167 171
			}
168 172
			for (Property prop : pWordProperties) {
......
172 176
		}
173 177
		return rez;
174 178
	}
175

  
176

  
179
	
180
	
177 181
	/**
178 182
	 * 
179 183
	 * @return the current page content map
......
183 187
		HashMap<Property, List<String>> current = this.getPageContent(pCurrentPage);
184 188
		return current;
185 189
	}
186

  
187

  
188

  
189

  
190
	
191
	
192
	
193
	
190 194
	/**
191 195
	 * Gets the current page number.
196
	 * 
192 197
	 * @return the current page number
193 198
	 */
194 199
	public int getCurrentPage() {
195 200
		return pCurrentPage;
196 201
	}
197

  
202
	
198 203
	@Override
199 204
	public boolean saveParameters() {
200 205
		if (pStructuralUnit != null) {
......
207 212
		if (pWordProperties != null) {
208 213
			this.saveParameter(InternalViewPreferences.UNIT_PROPERTIES, WordProperty.propertiesToString(pWordProperties));
209 214
		}
210

  
215
		
211 216
		return true;
212 217
	}
213

  
218
	
214 219
	@Override
215 220
	public void clean() {
216 221
		// nothing to do
217 222
	}
218

  
219

  
223
	
224
	
220 225
	/**
221 226
	 * Gets the linked corpus.
227
	 * 
222 228
	 * @return
223 229
	 */
224 230
	public CQPCorpus getCorpus() {
225
		return (CQPCorpus)getParent();
231
		return (CQPCorpus) getParent();
226 232
	}
227

  
228

  
233
	
234
	
229 235
	@Override
230 236
	public String getDetails() {
231
		return getCorpus().getName()+" "+pStructuralUnit.getName()+" "+(pCurrentPage+1); //$NON-NLS-1$ //$NON-NLS-2$
237
		return getCorpus().getName() + " " + pStructuralUnit.getName() + " " + (pCurrentPage + 1); //$NON-NLS-1$ //$NON-NLS-2$
232 238
	}
233

  
239
	
234 240
	@Override
235 241
	public String getComputingDoneMessage() {
236 242
		return "";
237
		//return TXMCoreMessages.common_done;
243
		// return TXMCoreMessages.common_done;
238 244
	}
239

  
245
	
240 246
	@Override
241 247
	public String getSimpleName() {
242 248
		return getName();
243 249
	}
244

  
245

  
250
	
251
	
246 252
	@Override
247 253
	public String getName() {
248 254
		if (pStructuralUnit != null) {
249
			return pStructuralUnit.getName( ) + " (" + (this.pCurrentPage + 1) + " / " + this.nmatches + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
255
			return pStructuralUnit.getName() + " (" + (this.pCurrentPage + 1) + " / " + this.nmatches + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
250 256
		}
251 257
		return getCorpus().getName();
252 258
	}
253

  
254

  
259
	
260
	
255 261
	/**
256 262
	 * Gets the number of matched segments.
263
	 * 
257 264
	 * @return
258 265
	 */
259 266
	public int getSegmentsCount() {
260 267
		return nmatches;
261 268
	}
262

  
263

  
269
	
270
	
264 271
	/**
265 272
	 * Gets lexical properties to display.
273
	 * 
266 274
	 * @return
267 275
	 */
268 276
	public List<WordProperty> getProperties() {
269 277
		return pWordProperties;
270 278
	}
271

  
279
	
272 280
	/**
273 281
	 * 
274 282
	 * @return
......
280 288
		if (matches.size() < pCurrentPage) {
281 289
			return 0;
282 290
		}
283

  
291
		
284 292
		Match m = matches.get(pCurrentPage);
285 293
		return m.size();
286 294
	}
287

  
295
	
288 296
	/**
289 297
	 * 
290 298
	 * @return
291 299
	 */
292 300
	public String getStructInfos() {
293

  
301
		
294 302
		try {
295 303
			if (pStructuralUnitsProperties.size() > 0) {
296 304
				String str = InternalViewCoreMessages.structureInformationsColon;
297 305
				for (Property sup : pStructuralUnitsProperties) {
298
					int[] array = {getCurrentPage()};
299
					str += " "+sup.getName()+"="+CQPSearchEngine.getCqiClient().struc2Str(sup.getQualifiedName(), array)[0]; //$NON-NLS-1$ //$NON-NLS-2$
306
					int[] array = { getCurrentPage() };
307
					str += " " + sup.getName() + "=" + CQPSearchEngine.getCqiClient().struc2Str(sup.getQualifiedName(), array)[0]; //$NON-NLS-1$ //$NON-NLS-2$
300 308
				}
301 309
				return str;
302 310
			}
303
		} catch (Exception e) {
311
		}
312
		catch (Exception e) {
304 313
			System.out.println(NLS.bind(InternalViewCoreMessages.internalViewColonFailedToRetrieveStructPropertiesValuesColonP0, e.getMessage()));
305 314
			org.txm.utils.logger.Log.printStackTrace(e);
306 315
		}
307 316
		return InternalViewCoreMessages.noStructureInformations;
308 317
	}
309

  
318
	
310 319
	/**
311 320
	 * Gets the structural unit to explore.
321
	 * 
312 322
	 * @return
313 323
	 */
314 324
	public StructuralUnit getStructuralUnit() {
315 325
		return pStructuralUnit;
316 326
	}
317

  
318

  
327
	
328
	
319 329
	/**
320 330
	 * Dumps the specified segment in the console.
331
	 * 
321 332
	 * @param seg
322 333
	 */
323 334
	public void printSeg(HashMap<Property, List<String>> seg) {
324 335
		Collection<List<String>> values = seg.values();
325
		if(values.size() == 0) {
336
		if (values.size() == 0) {
326 337
			return;
327 338
		}
328

  
329
		for(List<String> list : values) {
330
			for(String value : list) {
331
				System.out.print("\t"+value); //$NON-NLS-1$
339
		
340
		for (List<String> list : values) {
341
			for (String value : list) {
342
				System.out.print("\t" + value); //$NON-NLS-1$
332 343
			}
333 344
			System.out.println();
334 345
		}
335 346
		System.out.println();
336 347
	}
337

  
338

  
348
	
349
	
339 350
	public void setParameters(List<WordProperty> properties, StructuralUnit struct, List<StructuralUnitProperty> structProperties, Integer currentStructure) {
340 351
		if (properties != null) this.pWordProperties = properties;
341 352
		if (struct != null) this.pStructuralUnit = struct;
342 353
		if (structProperties != null) this.pStructuralUnitsProperties = structProperties;
343 354
		if (currentStructure != null) this.pCurrentPage = currentStructure;
344

  
355
		
345 356
		dirty = true;
346 357
	}
347

  
348

  
349

  
350

  
358
	
359
	
360
	
361
	
351 362
	@Override
352 363
	public boolean setParameters(TXMParameters parameters) {
353 364
		// FIXME: Debug
354 365
		System.err.println("InternalView.setParameters(): not yet implemented.");
355 366
		return false;
356 367
	}
357

  
358

  
368
	
369
	
359 370
	@Override
360 371
	public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
361 372
		PrintWriter writer = IOUtils.getWriter(outfile, encoding);
362
		for (int ipage = 0 ; ipage < nmatches ; ipage++) { // run through all pages
373
		for (int ipage = 0; ipage < nmatches; ipage++) { // run through all pages
363 374
			LinkedHashMap<Property, List<String>> page = getPageContent(ipage);
364 375
			for (Property p : pWordProperties) {
365 376
				writer.println(StringUtils.join(page.get(p), colseparator));
......
369 380
		writer.close();
370 381
		return false;
371 382
	}
372

  
373

  
383
	
384
	
374 385
	/**
375 386
	 * Sets the structural unit to explore.
387
	 * 
376 388
	 * @param structuralUnit
377 389
	 */
378 390
	public void setStructuralUnit(StructuralUnit structuralUnit) {
379 391
		this.pStructuralUnit = structuralUnit;
380 392
	}
381

  
382

  
393
	
394
	
383 395
	/**
384 396
	 * Sets the word properties to display.
397
	 * 
385 398
	 * @param properties
386 399
	 */
387
	public void setWordProperties(List<WordProperty> properties)	{
400
	public void setWordProperties(List<WordProperty> properties) {
388 401
		this.pWordProperties = properties;
389 402
	}
390

  
403
	
391 404
	/**
392 405
	 * Sets the structural unit properties to display.
406
	 * 
393 407
	 * @param structuralUnitProperties
394 408
	 */
395 409
	public void setStructuralUnitProperties(List<StructuralUnitProperty> structuralUnitProperties) {
396 410
		this.pStructuralUnitsProperties = structuralUnitProperties;
397 411
	}
398

  
399

  
412
	
413
	
400 414
	/**
401 415
	 * Sets the current page number.
416
	 * 
402 417
	 * @param currentPage the currentPage to set
403 418
	 */
404 419
	public void setCurrentPage(int currentPage) {
405 420
		this.pCurrentPage = currentPage;
406

  
407
		if(this.pCurrentPage < 0 || this.pCurrentPage > (this.nmatches - 1))	 {
421
		
422
		if (this.pCurrentPage < 0 || this.pCurrentPage > (this.nmatches - 1)) {
408 423
			System.err.println("InternalView.setCurrentPage(): current page (" + this.pCurrentPage + ") is outside matches range (" + this.nmatches + ").");
409 424
			this.pCurrentPage = 0;
410 425
		}
411 426
	}
412

  
427
	
413 428
	@Override
414 429
	public String getResultType() {
415 430
		return InternalViewCoreMessages.RESULT_TYPE;
416 431
	}
417

  
418
}
432
	
433
}
tmp/org.txm.internalview.core/src/org/txm/internalview/core/preferences/InternalViewPreferences.java (revision 2397)
12 12
 *
13 13
 */
14 14
public class InternalViewPreferences extends TXMPreferences {
15

  
15
	
16 16
	/**
17
	 * Current page number. 
17
	 * Current page number.
18 18
	 */
19 19
	public static final String CURRENT_PAGE = "current_page"; //$NON-NLS-1$
20

  
21 20
	
21
	
22 22
	/**
23 23
	 * Gets the instance.
24
	 * 
24 25
	 * @return the instance
25 26
	 */
26
	public static TXMPreferences getInstance()	{
27
	public static TXMPreferences getInstance() {
27 28
		if (!TXMPreferences.instances.containsKey(InternalViewPreferences.class)) {
28 29
			new InternalViewPreferences();
29 30
		}
30 31
		return TXMPreferences.instances.get(InternalViewPreferences.class);
31 32
	}
32

  
33 33
	
34
	
34 35
	@Override
35 36
	public void initializeDefaultPreferences() {
36 37
		super.initializeDefaultPreferences();
tmp/org.txm.cql2lsa.rcp/.classpath (revision 2397)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		    <accessrules>
6
			      <accessrule kind="accessible" pattern="**"/>
7
		    </accessrules>
8
	  </classpathentry>
9
	  <classpathentry kind="src" path="src"/>
10
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.cql2lsa.rcp/src/org/txm/functions/cql2lsa/package.html (revision 2397)
1 1
<html>
2 2
<body>
3
<p>Prototype of Query index.</p>
3
	<p>Prototype of Query index.</p>
4 4
</body>
5 5
</html>
tmp/org.txm.index.core/.classpath (revision 2397)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		    <accessrules>
6
			      <accessrule kind="accessible" pattern="**"/>
7
		    </accessrules>
8
	  </classpathentry>
9
	  <classpathentry kind="src" path="src"/>
10
	  <classpathentry kind="src" path="groovy"/>
11
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="src" path="groovy" />
13
	<classpathentry kind="output" path="bin" />
12 14
</classpath>
tmp/org.txm.index.core/groovy/org/txm/test/TestIndex.java (revision 2397)
21 21
 *
22 22
 */
23 23
public class TestIndex {
24
	
24 25
	/**
25 26
	 * the corpus name to use
26 27
	 */
......
33 34
	
34 35
	/**
35 36
	 * First test
37
	 * 
36 38
	 * @param outdir : the out folder
37 39
	 */
38 40
	public boolean test1(File outdir) {
39
		return testCorpus(new File(outdir, TestIndex.class.getName()+"_test1.csv"), CORPUS, null, "je", //$NON-NLS-1$ //$NON-NLS-2$
41
		return testCorpus(new File(outdir, TestIndex.class.getName() + "_test1.csv"), CORPUS, null, "je", //$NON-NLS-1$ //$NON-NLS-2$
40 42
				Arrays.asList("word"), null); //$NON-NLS-1$
41 43
	}
42 44
	
43 45
	/**
44 46
	 * First test
47
	 * 
45 48
	 * @param outdir : the out folder
46 49
	 */
47 50
	public boolean test2(File outdir) {
48
//		return testPartition(new File(outdir, TestIndex.class.getName()+"_test2.csv"), CORPUS, "texts", "je", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
49
//				Arrays.asList("word"), null); //$NON-NLS-1$
51
		// return testPartition(new File(outdir, TestIndex.class.getName()+"_test2.csv"), CORPUS, "texts", "je", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
52
		// Arrays.asList("word"), null); //$NON-NLS-1$
50 53
		return false;
51 54
	}
52 55
	
......
60 63
			CQLQuery query = new CQLQuery(CQLQuery.fixQuery(queryString));
61 64
			
62 65
			List<WordProperty> properties = new ArrayList<WordProperty>();
63
			for (String p : propertiesString) properties.add(corpus.getProperty(p));
64

  
66
			for (String p : propertiesString)
67
				properties.add(corpus.getProperty(p));
68
			
65 69
			Index index = new Index(corpus);
66 70
			index.setParameters(query, properties, null, null, null, null);
67 71
			index.compute();
......
72 76
				else if ("unitfreq".equals(sortBy)) index.sortLines(SortMode.UNITFREQ, false); //$NON-NLS-1$
73 77
			}
74 78
			index.toTxt(outfile, "UTF-8", "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
75
		} catch (Exception e) {
79
		}
80
		catch (Exception e) {
76 81
			org.txm.utils.logger.Log.printStackTrace(e);
77 82
			return false;
78 83
		}
79 84
		return true;
80 85
	}
81 86
	
82
//	private boolean testPartition(File outfile, String corpusname, String partitionname, String queryString,
83
//			List<String> propertiesString, String sortBy) {
84
//		try {
85
//			CQPCorpus corpus = CorpusManager.getCorpusManager().getCorpus(corpusname);
86
//			Partition partition = corpus.getPartition(partitionname);
87
//			
88
//			CQLQuery query = new CQLQuery(CQLQuery.fixQuery(queryString));
89
//			
90
//			List<WordProperty> properties = new ArrayList<WordProperty>();
91
//			for (String p : propertiesString) properties.add(corpus.getProperty(p));
92
//
93
//			Index index = new Index(partition);
94
//			index.setParameters(query, properties, null, null, null, null);
95
//			index.compute();
96
//			index.getAllLines();
97
//			
98
//			if (sortBy != null) {
99
//				if ("frequnit".equals(sortBy)) index.sortLines(SortMode.FREQUNIT, false); //$NON-NLS-1$
100
//				else if ("unitfreq".equals(sortBy)) index.sortLines(SortMode.UNITFREQ, false); //$NON-NLS-1$
101
//			}
102
//			index.toTxt(outfile, "UTF-8", "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
103
//		} catch (Exception e) {
104
//			org.txm.utils.logger.Log.printStackTrace(e);
105
//			return false;
106
//		}
107
//		return true;
108
//	}
87
	// private boolean testPartition(File outfile, String corpusname, String partitionname, String queryString,
88
	// List<String> propertiesString, String sortBy) {
89
	// try {
90
	// CQPCorpus corpus = CorpusManager.getCorpusManager().getCorpus(corpusname);
91
	// Partition partition = corpus.getPartition(partitionname);
92
	//
93
	// CQLQuery query = new CQLQuery(CQLQuery.fixQuery(queryString));
94
	//
95
	// List<WordProperty> properties = new ArrayList<WordProperty>();
96
	// for (String p : propertiesString) properties.add(corpus.getProperty(p));
97
	//
98
	// Index index = new Index(partition);
99
	// index.setParameters(query, properties, null, null, null, null);
100
	// index.compute();
101
	// index.getAllLines();
102
	//
103
	// if (sortBy != null) {
104
	// if ("frequnit".equals(sortBy)) index.sortLines(SortMode.FREQUNIT, false); //$NON-NLS-1$
105
	// else if ("unitfreq".equals(sortBy)) index.sortLines(SortMode.UNITFREQ, false); //$NON-NLS-1$
106
	// }
107
	// index.toTxt(outfile, "UTF-8", "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
108
	// } catch (Exception e) {
109
	// org.txm.utils.logger.Log.printStackTrace(e);
110
	// return false;
111
	// }
112
	// return true;
113
	// }
109 114
}
tmp/org.txm.index.core/groovy/org/txm/test/IndexSample.groovy (revision 2397)
39 39
import org.txm.searchengine.cqp.corpus.query.*
40 40

  
41 41
// on récupère le corpus DISCOURS
42
MainCorpus discours = CorpusManager.getCorpusManager().getCorpus("BFM")
43
println discours
42
MainCorpus discours=CorpusManager.getCorpusManager().getCorpus("BFM")println discours
44 43

  
45 44
// on récupère ses propriétés
46
Property pos = discours.getProperty("ttpos")
47
Property word = discours.getProperty("word")
45
Property pos=discours.getProperty("ttpos")Property word=discours.getProperty("word")
48 46

  
49 47
// on créé une Query, ici "[]"
50
Query query = new Query(Query.fixQuery("[word=\"je\"]"))
48
Query query=new Query(Query.fixQuery("[word=\"je\"]"))
51 49

  
52
List<Property> props = [pos,word]
50
List<Property>props=[pos,word]
53 51

  
54 52
// on exécute la commande
55
def time = System.currentTimeMillis()
56
println(""+discours+"\t"+query+"\t"+props)
57
Index index = new Index(discours, query, props )
58
println("execution time : "+(System.currentTimeMillis()-time)+" ms")
53
def time=System.currentTimeMillis()println(""+discours+"\t"+query+"\t"+props)Index index=new Index(discours,query,props)println("execution time : "+(System.currentTimeMillis()-time)+" ms")
59 54

  
60
//sort
61
//index.sortLines(LineComparator.SortMode.FREQUNIT)
55
// sort
56
// index.sortLines(LineComparator.SortMode.FREQUNIT)
62 57

  
63
//get some infos
64
println("V : "+index.getV())
65
println("T : "+index.getT())
58
// get some infos
59
println("V : "+index.getV())println("T : "+index.getT())
66 60

  
67
//filter
68
index.filterLines(2,3000)
69
println("V after: "+index.getV())
70
println("T after: "+index.getT())
61
// filter
62
index.filterLines(2,3000)println("V after: "+index.getV())println("T after: "+index.getT())
71 63

  
72
//on écrit tout dans un fichier
73
File file = new File("voc.txt")
74
index.toTxt(file, "'", "\t", "UTF-8")
75
println("index file : "+ file.getAbsolutePath())
64
// on écrit tout dans un fichier
65
File file=new File("voc.txt")index.toTxt(file,"'","\t","UTF-8")println("index file : "+file.getAbsolutePath())
tmp/org.txm.index.core/groovy/org/txm/test/IndexPartition.groovy (revision 2397)
39 39
import org.txm.searchengine.cqp.corpus.query.*
40 40
// TODO: Auto-generated Javadoc
41 41

  
42
/* (non-Javadoc)
42
/*
43
 * (non-Javadoc)
43 44
 * @see groovy.lang.Script#run()
44 45
 */
45
boolean manualInit = false
46
if(!org.txm.Toolbox.isInitialized())
47
{
48
	manualInit = true
49
	org.txm.Toolbox.initialize(new File(System.getProperty("user.home")+"/TXM/install.prefs"))
50
}
51
	// on récupère le corpus DISCOURS
52
	MainCorpus discours = CorpusManager.getCorpusManager().getCorpus("DISCOURS")
53
	Partition discours_dates = discours.createPartition( discours.getStructuralUnit("text"), discours.getStructuralUnit("text").getProperty("date"))
54
	println discours
55
	
56
	// on récupère ses propriétés
57
	Property pos = discours.getProperty("pos")
58
	Property word = discours.getProperty("word")
59
	
60
	// on créé une Query, ici "[]"
61
	Query query = new Query(Query.fixQuery("[word=\"j.*\"]"))
62
	
63
	List<Property> props = [pos,word]
64
	
65
	// on exécute la commande
66
	def time = System.currentTimeMillis()
67
	println(""+discours+"\t"+query+"\t"+props)
68
	Index index = new Index(discours_dates, query, props )
69
	println("execution time : "+(System.currentTimeMillis()-time)+" ms")
70
	
71
	//sort
72
	//index.sortLines(LineComparator.SortMode.FREQUNIT)
73
	
74
	//get some infos
75
	println("V : "+index.getV())
76
	println("T : "+index.getT())
77
	
78
	//filter
79
	index.filterLines(2,3000)
80
	println("V after: "+index.getV())
81
	println("T after: "+index.getT())
82
	
83
	//on écrit tout dans un fichier
84
	File file = new File("voc.txt")
85
	index.toTxt(file)
86
	println("index file : "+ file.getAbsolutePath())
46
boolean manualInit=false if(!org.txm.Toolbox.isInitialized()){manualInit=true org.txm.Toolbox.initialize(new File(System.getProperty("user.home")+"/TXM/install.prefs"))}
47
// on récupère le corpus DISCOURS
48
MainCorpus discours=CorpusManager.getCorpusManager().getCorpus("DISCOURS")Partition discours_dates=discours.createPartition(discours.getStructuralUnit("text"),discours.getStructuralUnit("text").getProperty("date"))println discours
87 49

  
88
	
89
if(manualInit)
90
	org.txm.Toolbox.shutdown()
50
// on récupère ses propriétés
51
Property pos=discours.getProperty("pos")Property word=discours.getProperty("word")
52

  
53
// on créé une Query, ici "[]"
54
Query query=new Query(Query.fixQuery("[word=\"j.*\"]"))
55

  
56
List<Property>props=[pos,word]
57

  
58
// on exécute la commande
59
def time=System.currentTimeMillis()println(""+discours+"\t"+query+"\t"+props)Index index=new Index(discours_dates,query,props)println("execution time : "+(System.currentTimeMillis()-time)+" ms")
60

  
61
// sort
62
// index.sortLines(LineComparator.SortMode.FREQUNIT)
63

  
64
// get some infos
65
println("V : "+index.getV())println("T : "+index.getT())
66

  
67
// filter
68
index.filterLines(2,3000)println("V after: "+index.getV())println("T after: "+index.getT())
69

  
70
// on écrit tout dans un fichier
71
File file=new File("voc.txt")index.toTxt(file)println("index file : "+file.getAbsolutePath())
72

  
73

  
74
if(manualInit)org.txm.Toolbox.shutdown()
tmp/org.txm.index.core/groovy/org/txm/macro/r/ExecRMacro.groovy (revision 2397)
9 9
import org.txm.statsengine.r.core.RWorkspace
10 10

  
11 11

  
12
def sel = corpusViewSelection
12
def sel=corpusViewSelection
13 13

  
14
String symbol = null;
15
String prop = "none"
16
if (sel instanceof Index) {
17
	println "Sending Index data to R..."
18
	((Index)sel).asRMatrix()
19
	symbol = "t("+((Index)sel).getSymbol()+'$data)'
20
	prop = ((Index)sel).getProperties().toString()
21
}
14
String symbol=null;String prop="none"if(sel instanceof Index){println"Sending Index data to R..."((Index)sel).asRMatrix()symbol="t("+((Index)sel).getSymbol()+'$data)'prop=((Index)sel).getProperties().toString()}
22 15

  
23
if (symbol == null) {
24
	println "Selection is not an Index. Aborting."
25
	return
26
}
16
if(symbol==null){println"Selection is not an Index. Aborting."return}
27 17

  
28
def r = RWorkspace.getRWorkspaceInstance()
29
def file = File.createTempFile("IndexHist", ".svg", new File(Toolbox.getTxmHomePath(), "results"))
18
def r=RWorkspace.getRWorkspaceInstance()def file=File.createTempFile("IndexHist",".svg",new File(Toolbox.getTxmHomePath(),"results"))
30 19

  
31 20
/// BEGIN SCRIPTS
32
def script ="""
33
par(las=2)
34
barplot($symbol, xlab="$prop", ylab="f")
35
"""
21
def script="""par(las=2)barplot($symbol,xlab="$prop",ylab="f")"""
36 22
/// END SCRIPTS
37
r.plot(file, script)
38
println "Result saved in: "+file.getAbsolutePath()
23
r.plot(file,script)println"Result saved in: "+file.getAbsolutePath()
39 24

  
40
//display the graphic
41
monitor.syncExec(new Runnable() {
42
	@Override
43
	public void run() {	OpenSVGGraph.OpenSVGFile(file.getAbsolutePath(), "Specificity distribution") }
44
});
25
// display the graphic
26
monitor.syncExec(new Runnable(){@Override public void run(){OpenSVGGraph.OpenSVGFile(file.getAbsolutePath(),"Specificity distribution")}});
tmp/org.txm.index.core/src/org/txm/index/core/messages/IndexCoreMessages.java (revision 2397)
9 9
 *
10 10
 */
11 11
public class IndexCoreMessages extends NLS {
12

  
12
	
13 13
	private static final String BUNDLE_NAME = "org.txm.index.core.messages.messages"; //$NON-NLS-1$
14 14
	
15
	public static String indexColonPartitionP0queryP1propertiesP2FminP3FmaxP4; 
16
	public static String indexColonCorpusP0queryP1propertiesP2FminP3FmaxP4; 
15
	public static String indexColonPartitionP0queryP1propertiesP2FminP3FmaxP4;
17 16
	
17
	public static String indexColonCorpusP0queryP1propertiesP2FminP3FmaxP4;
18
	
18 19
	public static String RESULT_TYPE;
19
	public static String lexicon; 
20 20
	
21
	public static String consoleColonP0; 
22
	public static String error_failedToExportLexiconColonP0; 
23

  
24

  
25
	public static String formsAndFrequenciesTablesMustHaveTheSameSize; 
26
	public static String lexiconColonP0; 
21
	public static String lexicon;
22
	
23
	public static String consoleColonP0;
24
	
25
	public static String error_failedToExportLexiconColonP0;
26
	
27
	
28
	public static String formsAndFrequenciesTablesMustHaveTheSameSize;
29
	
30
	public static String lexiconColonP0;
31
	
27 32
	public static String computingTheLexiconOfSubcorpusP0;
33
	
28 34
	public static String lexiconOfP0InTheP1Corpus;
35
	
29 36
	public static String indexOfP0PropertiesP1InTheP2Corpus;
30 37
	
31 38
	
32

  
39
	
33 40
	static {
34 41
		// initialize resource bundle
35 42
		Utf8NLS.initializeMessages(BUNDLE_NAME, IndexCoreMessages.class);
36 43
	}
37

  
38
	private IndexCoreMessages() {
39
	}
44
	
45
	private IndexCoreMessages() {}
40 46
}
tmp/org.txm.index.core/src/org/txm/index/core/functions/package.html (revision 2397)
1 1
<html>
2 2
<body>
3
<p>Index function</p>
3
	<p>Index function</p>
4 4
</body>
5 5
</html>
tmp/org.txm.index.core/src/org/txm/index/core/functions/LineComparator.java (revision 2397)
37 37
 * The Class LineComparator.
38 38
 */
39 39
public class LineComparator implements Comparator<Line> {
40

  
40
	
41 41
	/** The collator. */
42 42
	protected Collator collator;
43

  
43
	
44 44
	/**
45 45
	 * The Enum SortMode.
46 46
	 */
47 47
	public enum SortMode { // the sort methods
48 48
		/** The FREQ. */
49
 FREQ, // compare only frequency
49
		FREQ, // compare only frequency
50 50
		/** The UNIT. */
51
 UNIT, // compare only units
51
		UNIT, // compare only units
52 52
		/** The FREQUNIT. */
53
 FREQUNIT, // compare frequency then units
53
		FREQUNIT, // compare frequency then units
54 54
		/** The UNITFREQ. */
55
 UNITFREQ
55
		UNITFREQ
56 56
		// compare units then frequency
57 57
	}
58

  
58
	
59 59
	/** The currentsortmode. */
60 60
	SortMode currentsortmode = SortMode.FREQUNIT;
61 61
	
62 62
	/** The reverse. */
63 63
	boolean reverse;
64

  
64
	
65 65
	/**
66 66
	 * Instantiates a new line comparator.
67 67
	 *
......
72 72
		setSortByFrequence(mode);
73 73
		setReverse(reverse);
74 74
	}
75

  
75
	
76 76
	/**
77 77
	 * set if the sort must be reverted.
78 78
	 *
......
81 81
	private void setReverse(boolean reverse) {
82 82
		this.reverse = reverse;
83 83
	}
84

  
85
	/* (non-Javadoc)
84
	
85
	/*
86
	 * (non-Javadoc)
86 87
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
87 88
	 */
88 89
	@Override
89 90
	public int compare(Line arg0, Line arg1) {
90 91
		int sort = 0;
91 92
		switch (currentsortmode) {
92
		case FREQUNIT:
93
			sort = arg0.getFrequency() - arg1.getFrequency();
93
			case FREQUNIT:
94
				sort = arg0.getFrequency() - arg1.getFrequency();
95
				
96
				if (sort == 0)
97
					sort = -collator.compare(arg0.toString(), arg1.toString());
98
				
99
				break;
94 100
			
95
			if (sort == 0)
96
				sort = -collator.compare(arg0.toString(), arg1.toString());
101
			case UNITFREQ:
102
				sort = collator.compare(arg0.toString(), arg1.toString());
103
				if (sort == 0)
104
					sort = arg0.getFrequency() - arg1.getFrequency();
105
				break;
97 106
			
98
			break;
99

  
100
		case UNITFREQ:
101
			sort = collator.compare(arg0.toString(), arg1.toString());
102
			if (sort == 0)
107
			case FREQ:
103 108
				sort = arg0.getFrequency() - arg1.getFrequency();
104
			break;
105

  
106
		case FREQ:
107
			sort = arg0.getFrequency() - arg1.getFrequency();
108
			break;
109

  
110
		case UNIT:
111
			sort = collator.compare(arg0.toString(), arg1.toString());
112
			break;
109
				break;
110
			
111
			case UNIT:
112
				sort = collator.compare(arg0.toString(), arg1.toString());
113
				break;
113 114
		}
114 115
		if (reverse)
115 116
			sort = -sort;
116 117
		return sort;
117 118
	}
118

  
119
	
119 120
	/**
120 121
	 * set the sort method.
121 122
	 *
......
124 125
	public void setSortByFrequence(SortMode mode) {
125 126
		currentsortmode = mode;
126 127
	}
127

  
128
	
128 129
	/**
129 130
	 * Initialize.
130 131
	 *
tmp/org.txm.index.core/src/org/txm/index/core/functions/___Lexicon2.java (revision 2397)
69 69
 * @author sloiseau
70 70
 */
71 71
public class ___Lexicon2 extends Index {
72

  
72
	
73 73
	/** The nolex. */
74 74
	protected static int nolex = 1;
75

  
75
	
76 76
	/** The prefix r. */
77 77
	protected static String prefixR = "Lexicon_"; //$NON-NLS-1$
78

  
78
	
79 79
	/** The forms. */
80 80
	private String[] forms;
81

  
81
	
82 82
	/** The freqs. */
83 83
	private int[] freqs;
84

  
84
	
85 85
	/** The ids. */
86 86
	private int[] ids;
87

  
87
	
88 88
	/** The number of tokens. */
89 89
	int numberOfTokens = -1;
90

  
90
	
91 91
	/** The symbol. */
92 92
	private String symbol;
93

  
93
	
94 94
	/** The writer. */
95 95
	private OutputStreamWriter writer;
96

  
96
	
97 97
	/**
98 98
	 * The property.
99 99
	 */
100
	@Parameter(key=TXMPreferences.UNIT_PROPERTY)
100
	@Parameter(key = TXMPreferences.UNIT_PROPERTY)
101 101
	protected Property pProperty;
102 102
	
103

  
103
	
104 104
	/**
105 105
	 * Creates a not computed lexicon from the specified corpus.
106
	 * 
106 107
	 * @param parent
107 108
	 */
108
	public ___Lexicon2(CQPCorpus parent)	{
109
	public ___Lexicon2(CQPCorpus parent) {
109 110
		super(parent);
110 111
	}
111

  
112
	
112 113
	/**
113 114
	 * Creates a not computed lexicon from the specified parametersNodePath node name.
115
	 * 
114 116
	 * @param parametersNodePath
115 117
	 */
116
	public ___Lexicon2(String parametersNodePath)	{
118
	public ___Lexicon2(String parametersNodePath) {
117 119
		super(parametersNodePath);
118 120
	}
119 121
	
120

  
121 122
	
123
	
122 124
	@Override
123 125
	public CQPCorpus getParent() {
124
		return (CQPCorpus)super.getParent();
126
		return (CQPCorpus) super.getParent();
125 127
	}
126

  
128
	
127 129
	@Override
128 130
	public boolean loadParameters() {
129 131
		super.loadParameters();
130 132
		try {
131
			//this.persistable = false; // FIXME: remove that later
133
			// this.persistable = false; // FIXME: remove that later
132 134
			String p = this.getStringParameterValue(TXMPreferences.UNIT_PROPERTY);
133 135
			if (p != null && p.length() > 0) {
134 136
				CQPCorpus parent = getParent();
......
152 154
	public boolean saveParameters() {
153 155
		super.saveParameters();
154 156
		// FIXME: became useless? check that it's well automated by autoSaveParametersFromAnnotations()?
155
		//this.saveParameter(TXMPreferences.UNIT_PROPERTY, this.pProperty);
157
		// this.saveParameter(TXMPreferences.UNIT_PROPERTY, this.pProperty);
156 158
		return true;
157 159
	}
158

  
159 160
	
161
	
160 162
	@Override
161 163
	public void clean() {
162 164
		super.clean();
163 165
		// TODO Auto-generated method stub
164 166
	}
165

  
167
	
166 168
	@Override
167 169
	public boolean canCompute() {
168 170
		return super.canCompute() && (pProperty != null);
169 171
	}
170

  
172
	
171 173
	@Override
172 174
	protected boolean _computeLines() throws Exception {
173 175
		if (this.getParent() instanceof MainCorpus) {
174
			return computeWithMainCorpus((MainCorpus)this.getParent(), pProperty, monitor);
176
			return computeWithMainCorpus((MainCorpus) this.getParent(), pProperty, monitor);
175 177
		}
176 178
		else if (this.getParent() instanceof Subcorpus) {
177
			return computewithSubCorpus((Subcorpus)this.getParent(), pProperty, monitor);
179
			return computewithSubCorpus((Subcorpus) this.getParent(), pProperty, monitor);
178 180
		}
179 181
		else {
180 182
			Log.severe("Error: Lexicon parent is neither a Maincorpus nor a Subcorpus."); //$NON-NLS-1$
......
201 203
		int lexiconSize;
202 204
		try {
203 205
			lexiconSize = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(property.getQualifiedName());
204
		} catch (Exception e) {
206
		}
207
		catch (Exception e) {
205 208
			throw new CqiClientException(e);
206 209
		}
207

  
210
		
208 211
		int[] ids = new int[lexiconSize];
209 212
		for (int i = 0; i < ids.length; i++) {
210 213
			ids[i] = i;
211 214
		}
212

  
215
		
213 216
		int[] freqs;
214 217
		try {
215 218
			this.subTask("Computing lexicon frequencies...");
216 219
			freqs = CorpusManager.getCorpusManager().getCqiClient().id2Freq(property.getQualifiedName(), ids);
217
		} catch (Exception e) {
220
		}
221
		catch (Exception e) {
218 222
			throw new CqiClientException(e);
219 223
		}
220

  
224
		
221 225
		this.init(corpus, property, freqs, ids);
222 226
		return true;
223 227
	}
224

  
228
	
225 229
	/**
226 230
	 * 
227 231
	 * @param corpus
......
231 235
	 * @throws CqiClientException
232 236
	 */
233 237
	// FIXME: why this method needs to create and delete some new subcorpus???? the computing can't be done directly on the corpus argument???
234
	// eg. dist = CorpusManager.getCorpusManager().getCqiClient().fdist1(corpus.getQualifiedCqpId(), 0,	ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
238
	// eg. dist = CorpusManager.getCorpusManager().getCqiClient().fdist1(corpus.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
235 239
	protected boolean computewithSubCorpus(Subcorpus corpus, Property property, IProgressMonitor monitor) throws CqiClientException {
236

  
237
//		if (corpus instanceof Part) {
238
//			this.persistable = false;
239
//		}
240 240
		
241
		//System.out.println("not found");
241
		// if (corpus instanceof Part) {
242
		// this.persistable = false;
243
		// }
244
		
245
		// System.out.println("not found");
242 246
		Log.finest(NLS.bind(IndexCoreMessages.computingTheLexiconOfSubcorpusP0, corpus.getName()));
243
		//long start = System.currentTimeMillis();
247
		// long start = System.currentTimeMillis();
244 248
		int[][] fdist = null;
245 249
		Subcorpus tmp = null;
246 250
		try {
......
248 252
			tmp = corpus.createSubcorpus(new CQLQuery("[]"), "S" + corpus.getNextSubcorpusCounter(), true); //$NON-NLS-1$
249 253
			if (tmp != null) {
250 254
				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(tmp.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
251

  
255
				
252 256
				corpus.dropSubcorpus(tmp);
253 257
				tmp.delete();
254 258
			}
255
			//System.out.println("nb lines: "+fdist.length);
256
		} catch (Exception e) {
259
			// System.out.println("nb lines: "+fdist.length);
260
		}
261
		catch (Exception e) {
257 262
			throw new CqiClientException(e);
258
		} finally {
263
		}
264
		finally {
259 265
			if (tmp != null) {
260 266
				try {
261 267
					corpus.dropSubcorpus(tmp);
......
266 272
			}
267 273
		}
268 274
		int lexiconSize = fdist.length;
269

  
275
		
270 276
		int[] freqs = new int[lexiconSize];
271 277
		int[] ids = new int[lexiconSize];
272 278
		for (int i = 0; i < fdist.length; i++) {
273 279
			ids[i] = fdist[i][0];
274 280
			freqs[i] = fdist[i][1];
275 281
		}
276

  
282
		
277 283
		init(corpus, property, freqs, ids);
278 284
		return true;
279 285
	}
......
291 297
		this.symbol = v.getSymbol();
292 298
		return v;
293 299
	}
294

  
300
	
295 301
	/**
296 302
	 * Compute number of tokens. / this.nbr
297 303
	 */
......
301 307
			numberOfTokens += freqs[i];
302 308
		}
303 309
	}
304

  
310
	
305 311
	/**
306 312
	 * Dump lexicon forms and frequencies in a String.
307 313
	 *
......
313 319
		StringBuffer buffer = new StringBuffer();
314 320
		getForms();
315 321
		for (int i = 0; i < forms.length; i++) {
316
			buffer.append(txt + forms[i].replace(txt, txt + txt) + txt + col + freqs[i] + "\n"); //$NON-NLS-1$ 
322
			buffer.append(txt + forms[i].replace(txt, txt + txt) + txt + col + freqs[i] + "\n"); //$NON-NLS-1$
317 323
		}
318 324
		return buffer.toString();
319 325
	}
320

  
321
	/* (non-Javadoc)
326
	
327
	/*
328
	 * (non-Javadoc)
322 329
	 * @see java.lang.Object#equals(java.lang.Object)
323 330
	 */
324 331
	@Override
......
327 334
			return false;
328 335
		}
329 336
		___Lexicon2 other = (___Lexicon2) obj;
330

  
337
		
331 338
		if (other.nbrOfType() != this.nbrOfType()) {
332 339
			return false;
333 340
		}
334 341
		return (Arrays.equals(freqs, other.getFreq()) && Arrays.equals(getForms(), other.getForms()));
335 342
	}
336

  
337

  
338

  
343
	
344
	
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff