Révision 2543

tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 2543)
32 32

  
33 33
import org.txm.core.messages.TXMCoreMessages;
34 34
import org.txm.core.preferences.TXMPreferences;
35
import org.txm.core.results.TXMResult;
35 36
import org.txm.index.core.messages.IndexCoreMessages;
36 37
import org.txm.searchengine.cqp.corpus.CQPCorpus;
37 38
import org.txm.searchengine.cqp.corpus.CQPLexicon;
......
49 50
public class Lexicon extends Index {
50 51
	
51 52
	
53
	/**
54
	 * 
55
	 * @param parent
56
	 */
52 57
	public Lexicon(CQPCorpus parent) {
53 58
		super(parent);
54 59
	}
55 60
	
56
	public Lexicon(String parent_id) {
57
		super(parent_id);
61
	/**
62
	 * 
63
	 * @param parametersNodePath
64
	 */
65
	public Lexicon(String parametersNodePath) {
66
		super(parametersNodePath);
58 67
	}
59 68
	
69
	/**
70
	 * 
71
	 * @param parametersNodePath
72
	 */
73
	public Lexicon(String parametersNodePath, TXMResult parent) {
74
		super(parametersNodePath, parent);
75
	}
76
	
77
	
60 78
	@Override
61 79
	protected boolean _computeLines() {
62 80
		try {
......
74 92
			String[] forms = lexicon.getForms();
75 93
			int[] freqs = lexicon.getFreq();
76 94
			int[] ids = lexicon.getIds();
77
			this.lines = new ArrayList<Line>();
95
			this.lines = new ArrayList<>();
78 96
			int nbOfToken = lexicon.nbrOfToken();
79 97
			if (nbOfToken > 0) { // no lines
80 98
				for (int i = 0; i < forms.length && i < freqs.length; i++) {
81 99
					Line l = new Line();
82
					List<String> values = new ArrayList<String>(1);
100
					List<String> values = new ArrayList<>(1);
83 101
					values.add(forms[i]);
84 102
					l.put(property, values);
85 103
					int[] c = new int[1];
tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 2543)
43 43
import org.txm.index.core.messages.IndexCoreMessages;
44 44
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
45 45
import org.txm.searchengine.cqp.corpus.CQPCorpus;
46
import org.txm.searchengine.cqp.corpus.CQPLexicon;
47 46
import org.txm.searchengine.cqp.corpus.Part;
48 47
import org.txm.searchengine.cqp.corpus.Partition;
49 48
import org.txm.searchengine.cqp.corpus.Property;
......
61 60
 */
62 61
public class PartitionIndex extends Index {
63 62
	
64
	/** The lexicon used to compute the index (if query = null || query == [] && properties.size() == 1 */
65
	@Deprecated
66
	protected CQPLexicon lexicon;
67
	
68 63
	/**
69 64
	 * 
70 65
	 * @param parent
......
213 208
	
214 209
	@Override
215 210
	public String getDetails() {
216
		if (lexicon != null) {
217
			return lexicon.getDetails();
218
		}
219
		else {
220
			
221
			try {
222
				Object[] params = new Object[] { this.parent.getSimpleName(), this.getQuery().getQueryString(), this.getProperties(), this.getFmin(), this.getFmax() };
223
				String str;
224
				if (this.parent instanceof Partition) {
225
					str = IndexCoreMessages.indexColonPartitionP0queryP1propertiesP2FminP3FmaxP4;
226
				}
227
				else {
228
					str = IndexCoreMessages.indexColonCorpusP0queryP1propertiesP2FminP3FmaxP4;
229
				}
230
				return NLS.bind(str, params);
211
		try {
212
			Object[] params = new Object[] { this.parent.getSimpleName(), this.getQuery().getQueryString(), this.getProperties(), this.getFmin(), this.getFmax() };
213
			String str;
214
			if (this.parent instanceof Partition) {
215
				str = IndexCoreMessages.indexColonPartitionP0queryP1propertiesP2FminP3FmaxP4;
231 216
			}
232
			catch (Exception e) {
233
				return getName();
217
			else {
218
				str = IndexCoreMessages.indexColonCorpusP0queryP1propertiesP2FminP3FmaxP4;
234 219
			}
220
			return NLS.bind(str, params);
235 221
		}
222
		catch (Exception e) {
223
			return getName();
224
		}
236 225
	}
237 226
	
238 227
	
239
	
240 228
	/**
241
	 * If the index has been build with corpus + property, the method returns the lexicon used.
242
	 *
243
	 * @return the lexicon
244
	 */
245
	public CQPLexicon getLexicon() {
246
		return lexicon;
247
	}
248
	
249
	/**
250 229
	 * update the lines counts.
251 230
	 */
252 231
	@Override
......
272 251
	@Override
273 252
	public String getName() {
274 253
		try {
275
			if (lexicon != null) {
276
				return lexicon.getName();
277
			}
278
			else {
279
				return IndexCoreMessages.PARTITION_RESULT_TYPE + ": " + this.parent.getSimpleName() + ": " + this.getSimpleName();
280
			}
254
			return IndexCoreMessages.PARTITION_RESULT_TYPE + ": " + this.parent.getSimpleName() + ": " + this.getSimpleName();
281 255
		}
282 256
		catch (Exception e) {
283 257
			return this.getEmptyName();
......
324 298
	
325 299
	@Override
326 300
	public String getSimpleName() {
327
		if (lexicon != null) {
328
			return lexicon.getSimpleName();
329
		}
330
		else {
331
			String name = ""; //$NON-NLS-1$
332
			if (pQuery != null && !pQuery.isEmpty()) {
333
				name += pQuery.getQueryString();
334
				name += ": "; //$NON-NLS-1$
335
				
336
				for (Property s : pProperties) {
337
					name += s.getName() + pPropertiesSeparator;
338
				}
339
				if (pProperties.size() > 0) {
340
					name = name.substring(0, name.length() - 1);
341
				}
342
				return name;
301
		String name = ""; //$NON-NLS-1$
302
		if (pQuery != null && !pQuery.isEmpty()) {
303
			name += pQuery.getQueryString();
304
			name += ": "; //$NON-NLS-1$
305
			
306
			for (Property s : pProperties) {
307
				name += s.getName() + pPropertiesSeparator;
343 308
			}
344
			else {
345
				return this.getEmptyName();
309
			if (pProperties.size() > 0) {
310
				name = name.substring(0, name.length() - 1);
346 311
			}
312
			return name;
347 313
		}
314
		else {
315
			return this.getEmptyName();
316
		}
348 317
	}
349 318
	
350 319
	
......
369 338
	public void setParameters(List<WordProperty> props) {
370 339
		this.pQuery = new CQLQuery("[]"); //$NON-NLS-1$
371 340
		this.pProperties = props;
372
		this.lexicon = null;
373 341
	}
374 342
	
375 343
	
376 344
	
377
	
378
	
379
	
380
	
381 345
	/**
382 346
	 * dump a part of the index.
383 347
	 *

Formats disponibles : Unified diff