Révision 3372

TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/WordProperty.java (revision 3372)
3 3
import java.io.IOException;
4 4
import java.util.List;
5 5

  
6
import org.apache.commons.lang.math.IntRange;
7
import org.txm.objects.Match;
8 6
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
9 7
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
10 8
import org.txm.searchengine.cqp.corpus.query.MatchUtils;
......
88 86
		return CorpusManager.getCorpusManager().getCqiClient().str2Id(this.getQualifiedName(), new String[] { value })[0];
89 87
	}
90 88
	
89
	/**
90
	 * 
91
	 * @param value
92
	 * @return the CQL inner word test in [] for a value
93
	 */
91 94
	public String getCQLTest(String value) {
95
		
92 96
		return this.getName() + "=\"" + CQLQuery.addBackSlash(value) + "\"";
93 97
	}
94 98
	
99
	/**
100
	 * 
101
	 * @param value
102
	 * @return the CQL inner word test in [] for several values
103
	 */
95 104
	public String getCQLTest(List<String> values) {
105
		
96 106
		StringBuilder sb = new StringBuilder();
97 107
		sb.append(this.getName() + "=\""); //$NON-NLS-1$
98 108
		for (int i = 0; i < values.size(); i++) {
......
107 117
		return sb.toString();
108 118
	}
109 119
	
120
	/**
121
	 * 
122
	 * @return all indexed values in the main corpus 
123
	 * 
124
	 * @throws UnexpectedAnswerException
125
	 * @throws IOException
126
	 * @throws CqiServerError
127
	 */
110 128
	public String[] getValues() throws UnexpectedAnswerException, IOException, CqiServerError {
129
		
111 130
		int n = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(this.getQualifiedName());
112 131
		int[] ids = MatchUtils.toPositions(0, n - 1);
113 132
		return CorpusManager.getCorpusManager().getCqiClient().id2Str(this.getQualifiedName(), ids);
114 133
	}
115 134
	
135
	/**
136
	 * 
137
	 * @return the number of indexed values in the main corpus 
138
	 * 
139
	 * @throws UnexpectedAnswerException
140
	 * @throws IOException
141
	 * @throws CqiServerError
142
	 */
116 143
	public int getNValues() throws UnexpectedAnswerException, IOException, CqiServerError {
144
		
117 145
		return CorpusManager.getCorpusManager().getCqiClient().lexiconSize(this.getQualifiedName());
118 146
	};
119 147
}
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/VirtualProperty.java (revision 3372)
48 48
	public static String fullnameToName(String fullname) {
49 49
		return fullname.substring(1, fullname.length() - 1);
50 50
	}
51
	
52
	@Override
53
	public String getCQLTest(String value) {
54
		return null;
55
	}
56
	
57
	@Override
58
	public String getCQLTest(List<String> values) {
59
		return null;
60
	}
61
	
51 62
}
52 63

  
TXM/trunk/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 3372)
58 58
import org.txm.searchengine.cqp.corpus.CorpusManager;
59 59
import org.txm.searchengine.cqp.corpus.Property;
60 60
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
61
import org.txm.searchengine.cqp.corpus.VirtualProperty;
61 62
import org.txm.searchengine.cqp.corpus.WordProperty;
62 63
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
63 64
import org.txm.searchengine.cqp.serverException.CqiServerError;
......
252 253
			query += "["; //$NON-NLS-1$
253 254
			for (int p = 0; p < nbProps; p++) {
254 255
				
256
				String test = null;
257
				
255 258
				if (props.get(p) instanceof StructuralUnitProperty) {
256
					query += "_." + ((StructuralUnitProperty) props.get(p)).getFullName() + "=\""; //$NON-NLS-1$ //$NON-NLS-2$
259
					test = "_." + ((StructuralUnitProperty) props.get(p)).getFullName() + "=\""; //$NON-NLS-1$ //$NON-NLS-2$
257 260
					
258 261
					for (int l = 0; l < nbLines; l++) {
259 262
						line = lines.get(l);
......
262 265
						s = CQLQuery.addBackSlash(s);
263 266
						query += s + "|"; //$NON-NLS-1$
264 267
					}
265
					query = query.substring(0, query.length() - 1);
268
					test = test.substring(0, query.length() - 1);
266 269
					
267
					query += "\""; //$NON-NLS-1$
270
					test += "\""; //$NON-NLS-1$
271
				}
272
				else if (props.get(p) instanceof VirtualProperty) {
273
					ArrayList<String> values = new ArrayList<>();
274
					for (int l = 0; l < nbLines; l++) {
275
						line = lines.get(l);
276
						String s = line.getUnitsProperties().get(p).get(t);
277
						values.add(s);
278
					}
268 279
					
280
					test = ((VirtualProperty) props.get(p)).getCQLTest(values);
269 281
				}
270 282
				else if (props.get(p) instanceof WordProperty) {
271 283
					ArrayList<String> values = new ArrayList<>();
......
275 287
						values.add(s);
276 288
					}
277 289
					
278
					String test = ((WordProperty) props.get(p)).getCQLTest(values);
279
					if (test != null) {
280
						query += test;
281
					}
282
				}
290
					test = ((WordProperty) props.get(p)).getCQLTest(values);
291
				} 
283 292
				
284
				if (p < nbProps - 1) {
293
				if (test != null && p > 0) {
285 294
					query += " & "; //$NON-NLS-1$
286 295
				}
296
				if (test != null) {
297
					query += test;
298
				}
287 299
			}
288 300
			
289 301
			query += "] "; //$NON-NLS-1$

Formats disponibles : Unified diff