Révision 317
tmp/org.txm.concordance.core/.settings/org.eclipse.jdt.core.prefs (revision 317) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.6 |
|
5 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|
6 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|
7 |
org.eclipse.jdt.core.compiler.source=1.6 |
|
0 | 8 |
tmp/org.txm.concordance.core/.classpath (revision 317) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
5 |
<classpathentry kind="src" path="src"/> |
|
6 |
<classpathentry kind="output" path="bin"/> |
|
7 |
</classpath> |
|
0 | 8 |
tmp/org.txm.concordance.core/META-INF/MANIFEST.MF (revision 317) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: Core |
|
4 |
Bundle-SymbolicName: org.txm.concordance.core |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
7 |
Require-Bundle: org.txm.core |
|
0 | 8 |
tmp/org.txm.concordance.core/.project (revision 317) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.concordance.core</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/Line.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2016-02-01 09:53:38 +0100 (Mon, 01 Feb 2016) $ |
|
25 |
// $LastChangedRevision: 3101 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.Collection; |
|
32 |
import java.util.HashMap; |
|
33 |
import java.util.HashSet; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Map; |
|
36 |
|
|
37 |
import org.apache.commons.lang.StringUtils; |
|
38 |
import org.txm.annotation.Annotation; |
|
39 |
import org.txm.annotation.repository.TypedValue; |
|
40 |
import org.txm.functions.Reference; |
|
41 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
42 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
43 |
import org.txm.searchengine.cqp.corpus.Property; |
|
44 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
45 |
import org.txm.utils.i18n.LangFormater; |
|
46 |
|
|
47 |
// TODO: Auto-generated Javadoc |
|
48 |
/** |
|
49 |
* The Class Line represents concordance line. |
|
50 |
* |
|
51 |
* @author jmague |
|
52 |
*/ |
|
53 |
public class Line { |
|
54 |
|
|
55 |
/** The concordance. */ |
|
56 |
private Concordance concordance; |
|
57 |
|
|
58 |
/** The left ctx view properties. */ |
|
59 |
private Map<Property, List<String>> leftCtxViewProperties; |
|
60 |
|
|
61 |
/** The keywords view properties. */ |
|
62 |
private Map<Property, List<String>> keywordsViewProperties; |
|
63 |
|
|
64 |
/** The right ctx view properties. */ |
|
65 |
private Map<Property, List<String>> rightCtxViewProperties; |
|
66 |
|
|
67 |
/** The left ctx analysis property. */ |
|
68 |
private HashMap<Property, List<String>> leftCtxAnalysisProperty; |
|
69 |
|
|
70 |
/** The keywords analysis property. */ |
|
71 |
private HashMap<Property, List<String>> keywordsAnalysisProperty; |
|
72 |
|
|
73 |
/** The right ctx analysis property. */ |
|
74 |
private HashMap<Property, List<String>> rightCtxAnalysisProperty; |
|
75 |
|
|
76 |
/** The PRO p_ separtor. */ |
|
77 |
public static String PROP_SEPARTOR ="_"; //$NON-NLS-1$ |
|
78 |
|
|
79 |
/** The references : view and sort */ |
|
80 |
private Reference refView; |
|
81 |
private Reference refAna; |
|
82 |
|
|
83 |
/** The match. */ |
|
84 |
private Match match; |
|
85 |
|
|
86 |
/** the line's text. */ |
|
87 |
private String textId; |
|
88 |
|
|
89 |
/** the ids of the keywords. */ |
|
90 |
private List<String> keywordsIdValues; |
|
91 |
|
|
92 |
/** The keywordpos. */ |
|
93 |
private int keywordpos; |
|
94 |
|
|
95 |
/** |
|
96 |
* the @target corpus position of the query |
|
97 |
*/ |
|
98 |
private int targetpos; |
|
99 |
|
|
100 |
private TypedValue annotationValue; |
|
101 |
|
|
102 |
private Annotation annotation; |
|
103 |
|
|
104 |
/** |
|
105 |
* Instantiates a new line. |
|
106 |
* |
|
107 |
* @param concordance the concordance |
|
108 |
* @param keywordsIdValues the keywords id values |
|
109 |
* @param textId the text id |
|
110 |
* @param leftCtxViewProperty the left context view property values |
|
111 |
* @param keywordsViewProperty the keywords view property values |
|
112 |
* @param rightCtxViewProperty the right context view property values |
|
113 |
* @param lineLeftCtxAnaPropValue the left context analysis property values |
|
114 |
* @param lineKeywordsAnaPropValue the keywords analysis property values |
|
115 |
* @param lineRightCtxAnaPropValue the right context analysis property values |
|
116 |
* @param refView the view references |
|
117 |
* @param reference2 the sort references |
|
118 |
* @param matchs the matchs |
|
119 |
* @param annotation |
|
120 |
* @param annotationValue |
|
121 |
*/ |
|
122 |
public Line(Concordance concordance, List<String> keywordsIdValues, |
|
123 |
String textId, Map<Property, List<String>> leftCtxViewProperty, |
|
124 |
Map<Property, List<String>> keywordsViewProperty, |
|
125 |
Map<Property, List<String>> rightCtxViewProperty, |
|
126 |
HashMap<Property, List<String>> lineLeftCtxAnaPropValue, |
|
127 |
HashMap<Property, List<String>> lineKeywordsAnaPropValue, |
|
128 |
HashMap<Property, List<String>> lineRightCtxAnaPropValue, Reference refView, |
|
129 |
Reference refAna, Match matchs, Annotation annotation, TypedValue annotationValue, int targetpos) { |
|
130 |
this.textId = textId; |
|
131 |
this.targetpos = targetpos; |
|
132 |
this.keywordsIdValues = keywordsIdValues; |
|
133 |
this.concordance = concordance; |
|
134 |
this.leftCtxViewProperties = leftCtxViewProperty; |
|
135 |
this.keywordsViewProperties = keywordsViewProperty; |
|
136 |
this.rightCtxViewProperties = rightCtxViewProperty; |
|
137 |
this.leftCtxAnalysisProperty = lineLeftCtxAnaPropValue; |
|
138 |
this.keywordsAnalysisProperty = lineKeywordsAnaPropValue; |
|
139 |
this.rightCtxAnalysisProperty = lineRightCtxAnaPropValue; |
|
140 |
this.refView = refView; |
|
141 |
this.refAna = refAna; |
|
142 |
this.match = matchs; |
|
143 |
this.keywordpos = matchs.getStart(); |
|
144 |
this.annotationValue = annotationValue; |
|
145 |
this.annotation = annotation; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Gets the keywords analysis property. |
|
150 |
* |
|
151 |
* @return the keywords analysis property |
|
152 |
*/ |
|
153 |
public HashMap<Property, List<String>> getKeywordsAnalysisProperty() { |
|
154 |
return keywordsAnalysisProperty; |
|
155 |
} |
|
156 |
|
|
157 |
public TypedValue getAnnotationValue() { |
|
158 |
return annotationValue; |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Gets the left context analysis property. |
|
163 |
* |
|
164 |
* @return the left context analysis property |
|
165 |
*/ |
|
166 |
public HashMap<Property, List<String>> getLeftAnalysisProperty() { |
|
167 |
return leftCtxAnalysisProperty; |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
171 |
* Gets the right ctx analysis property. |
|
172 |
* |
|
173 |
* @return the right ctx analysis property |
|
174 |
*/ |
|
175 |
public HashMap<Property, List<String>> getRightAnalysisProperty() { |
|
176 |
return rightCtxAnalysisProperty; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Gets the keywords view properties. |
|
181 |
* |
|
182 |
* @return the keywords view properties |
|
183 |
*/ |
|
184 |
public Map<Property, List<String>> getKeywordsViewProperties() { |
|
185 |
return keywordsViewProperties; |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* Gets the left context view properties. |
|
190 |
* |
|
191 |
* @return the left context view properties |
|
192 |
*/ |
|
193 |
public Map<Property, List<String>> getLeftCtxViewProperties() { |
|
194 |
return leftCtxViewProperties; |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* Gets the right context view properties. |
|
199 |
* |
|
200 |
* @return the right context view properties |
|
201 |
*/ |
|
202 |
public Map<Property, List<String>> getRightCtxViewProperties() { |
|
203 |
return rightCtxViewProperties; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Gets the reference. |
|
208 |
* |
|
209 |
* @return the reference |
|
210 |
*/ |
|
211 |
public Reference getViewRef() { |
|
212 |
return refView; |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Gets the reference. |
|
217 |
* |
|
218 |
* @return the reference |
|
219 |
*/ |
|
220 |
public Reference getAnaRef() { |
|
221 |
return refAna; |
|
222 |
} |
|
223 |
|
|
224 |
|
|
225 |
/** |
|
226 |
* Gets the left context size. |
|
227 |
* |
|
228 |
* @return the left context size |
|
229 |
*/ |
|
230 |
public int getLeftContextSize() { |
|
231 |
return leftCtxViewProperties.values().iterator().next().size(); |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* Gets the keywords size. |
|
236 |
* |
|
237 |
* @return the keywords size |
|
238 |
*/ |
|
239 |
public int getKeywordsSize() { |
|
240 |
return keywordsViewProperties.values().iterator().next().size(); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* Gets the right context size. |
|
245 |
* |
|
246 |
* @return the right context size |
|
247 |
*/ |
|
248 |
public int getRightContextSize() { |
|
249 |
return rightCtxViewProperties.values().iterator().next().size(); |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* Gets the match. |
|
254 |
* |
|
255 |
* @return the match |
|
256 |
*/ |
|
257 |
public Match getMatch() { |
|
258 |
return match; |
|
259 |
} |
|
260 |
|
|
261 |
/** |
|
262 |
* Used by leftContextToString, keywordsToString and rightContextToString to |
|
263 |
* build te string they return. |
|
264 |
* |
|
265 |
* @param values A map returned by getLeftCtxViewProperties, |
|
266 |
* getKeywordsViewProperties or getRightCtxViewProperties |
|
267 |
* @param propertySeparator The string used to separate the dif ferent view properties for |
|
268 |
* each word |
|
269 |
* @param wordSeparator The string used to separate the dif ferent words |
|
270 |
* @return The string representation |
|
271 |
*/ |
|
272 |
private String fieldToString(Map<Property, List<String>> values, |
|
273 |
String propertySeparator, String wordSeparator) { |
|
274 |
List<String> words = new ArrayList<String>(); |
|
275 |
for (int i = 0; i < values.get(concordance.getViewProperties().get(0)) |
|
276 |
.size(); i++) { |
|
277 |
List<String> word = new ArrayList<String>(); |
|
278 |
for (Property property : concordance.getViewProperties()) |
|
279 |
word.add(values.get(property).get(i)); |
|
280 |
words.add(StringUtils.join(word, propertySeparator)); |
|
281 |
} |
|
282 |
return LangFormater.format(StringUtils.join(words, wordSeparator), |
|
283 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* Fix spaces. |
|
288 |
* |
|
289 |
* @param str the str |
|
290 |
* @return the string |
|
291 |
*/ |
|
292 |
private String fixSpaces(String str) { |
|
293 |
str = str.replace(" ' ", " '"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
294 |
str = str.replace("' ", "'"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
295 |
str = str.replace(" , ", ", "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
296 |
str = str.replace(" \" ", " \""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
297 |
str = str.replace(" . ", ". "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
298 |
str = str.replace("( ", "("); //$NON-NLS-1$ //$NON-NLS-2$ |
|
299 |
str = str.replace(" )", ")"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
300 |
str = str.replace("[ ", "["); //$NON-NLS-1$ //$NON-NLS-2$ |
|
301 |
str = str.replace(" ]", "]"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
302 |
str = str.replace("{ ", "{"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
303 |
str = str.replace(" }", "}"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
304 |
return str; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* Returns a string representing the left context. |
|
309 |
* |
|
310 |
* @param propertySeparator The string used to separate the dif ferent view properties for |
|
311 |
* each word |
|
312 |
* @param wordSeparator The string used to separate the dif ferent words |
|
313 |
* @param limit the limit |
|
314 |
* @return The string representation |
|
315 |
*/ |
|
316 |
public String leftContextToString(String propertySeparator, |
|
317 |
String wordSeparator, int limit) { |
|
318 |
int currentPos = keywordpos - getLeftContextSize(); |
|
319 |
|
|
320 |
List<String> words = new ArrayList<String>(); |
|
321 |
Map<Property, List<String>> values = getLeftCtxViewProperties(); |
|
322 |
int max = (limit == -1) ? (values.get(concordance |
|
323 |
.getLeftViewProperties().get(0)).size()) : (limit); |
|
324 |
int start = this.getLeftContextSize() - max; |
|
325 |
for (int i = start; i < this.getLeftContextSize(); i++) { |
|
326 |
List<String> word = new ArrayList<String>(); |
|
327 |
for (Property property : concordance.getLeftViewProperties()) |
|
328 |
word.add(values.get(property).get(i)); |
|
329 |
|
|
330 |
words.add(StringUtils.join(word, propertySeparator)); |
|
331 |
|
|
332 |
if (annotation != null) { |
|
333 |
if (currentPos == annotation.getStart()) { |
|
334 |
words.set(i, "< "+words.get(i)); |
|
335 |
} else if (currentPos == annotation.getEnd()) { |
|
336 |
words.set(i, words.get(i)+" >"); |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
currentPos++; // next position |
|
341 |
} |
|
342 |
|
|
343 |
return LangFormater.format(StringUtils.join(words, wordSeparator), |
|
344 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
345 |
// return fieldToString(getLeftCtxViewProperties(), propertySeparator, |
|
346 |
// wordSeparator); |
|
347 |
} |
|
348 |
|
|
349 |
/** |
|
350 |
* Returns a string representing the keywords. |
|
351 |
* |
|
352 |
* @param propertySeparator The string used to separate the dif ferent view properties for |
|
353 |
* each word |
|
354 |
* @param wordSeparator The string used to separate the dif ferent words |
|
355 |
* @return The string representation |
|
356 |
*/ |
|
357 |
public String keywordToString(String propertySeparator, String wordSeparator) { |
|
358 |
|
|
359 |
int currentPos = keywordpos; |
|
360 |
|
|
361 |
List<String> words = new ArrayList<String>(); |
|
362 |
Map<Property, List<String>> values = getKeywordsViewProperties(); |
|
363 |
int s = values.get(concordance.getKeywordViewProperties().get(0)).size(); |
|
364 |
int keywordEndPos = keywordpos + s - 1; |
|
365 |
//System.out.println("Build STR of currentpos="+currentPos+" length="+s); |
|
366 |
for (int i = 0; i < s; i++) { |
|
367 |
List<String> word = new ArrayList<String>(); |
|
368 |
for (Property property : concordance.getKeywordViewProperties()) |
|
369 |
word.add(values.get(property).get(i)); |
|
370 |
|
|
371 |
if (currentPos == targetpos) { // highlight the @ target |
|
372 |
words.add("["+StringUtils.join(word, propertySeparator)+"]"); |
|
373 |
} else { |
|
374 |
words.add(StringUtils.join(word, propertySeparator)); |
|
375 |
} |
|
376 |
if (annotation != null && (annotation.getStart() != keywordpos || annotation.getEnd() != keywordEndPos)) { |
|
377 |
if (currentPos == annotation.getStart()) { |
|
378 |
words.set(i, "< "+words.get(i)); |
|
379 |
} |
|
380 |
if (currentPos == annotation.getEnd()) { |
|
381 |
words.set(i, words.get(i)+" >"); |
|
382 |
} |
|
383 |
} |
|
384 |
|
|
385 |
currentPos++; // next position |
|
386 |
} |
|
387 |
return LangFormater.format(StringUtils.join(words, wordSeparator), |
|
388 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
389 |
// return fieldToString(getKeywordsViewProperties(), propertySeparator, |
|
390 |
// wordSeparator); |
|
391 |
} |
|
392 |
|
|
393 |
/** |
|
394 |
* Returns a string representing the right context. |
|
395 |
* |
|
396 |
* @param propertySeparator The string used to separate the dif ferent view properties for |
|
397 |
* each word |
|
398 |
* @param wordSeparator The string used to separate the dif ferent words |
|
399 |
* @param limit the limit |
|
400 |
* @return The string representation |
|
401 |
*/ |
|
402 |
public String rightContextToString(String propertySeparator, |
|
403 |
String wordSeparator, int limit) { |
|
404 |
List<String> words = new ArrayList<String>(); |
|
405 |
Map<Property, List<String>> values = getRightCtxViewProperties(); |
|
406 |
int max = (limit == -1) ? (values.get(concordance.getRightViewProperties().get(0)).size()) : (limit); |
|
407 |
|
|
408 |
int s = getKeywordsSize(); |
|
409 |
int currentPos = keywordpos + s; |
|
410 |
//System.out.println("Line "+keywordToString()+" right context, currentpos="+currentPos+" keywordpos="+keywordpos+" keywordlength="+s); |
|
411 |
for (int i = 0; i < max; i++) { |
|
412 |
List<String> word = new ArrayList<String>(); |
|
413 |
for (Property property : concordance.getRightViewProperties()) |
|
414 |
word.add(values.get(property).get(i)); |
|
415 |
words.add(StringUtils.join(word, propertySeparator)); |
|
416 |
|
|
417 |
if (annotation != null) { |
|
418 |
if (currentPos == annotation.getStart()) { |
|
419 |
words.set(i, "< "+words.get(i)); |
|
420 |
} else if (currentPos == annotation.getEnd()) { |
|
421 |
words.set(i, words.get(i)+" >"); |
|
422 |
} |
|
423 |
} |
|
424 |
currentPos++; |
|
425 |
} |
|
426 |
return LangFormater.format(StringUtils.join(words, wordSeparator), |
|
427 |
concordance.getCorpus().getLang()); |
|
428 |
// return fieldToString(getRightCtxViewProperties(), propertySeparator, |
|
429 |
// wordSeparator); |
|
430 |
} |
|
431 |
|
|
432 |
/** The properties to process. */ |
|
433 |
protected static HashSet<String> propertiesToProcess; |
|
434 |
|
|
435 |
/** |
|
436 |
* Right context render. |
|
437 |
* |
|
438 |
* @param limit the limit |
|
439 |
* @return the string |
|
440 |
*/ |
|
441 |
public String rightContextRender(int limit) |
|
442 |
{ |
|
443 |
// if(propertiesToProcess == null) |
|
444 |
// propertiesToProcess = TxmRenderer.getPropertyToRender(concordance, "jsesh"); //$NON-NLS-1$ |
|
445 |
|
|
446 |
List<String> words = new ArrayList<String>(); |
|
447 |
Map<Property, List<String>> values = getRightCtxViewProperties(); |
|
448 |
int max = (limit == -1) ? (values.get(concordance.getRightViewProperties().get(0)).size()) : (limit); |
|
449 |
|
|
450 |
for (int i = 0; i < max; i++) |
|
451 |
{ |
|
452 |
List<String> word = new ArrayList<String>(); |
|
453 |
for (Property property : concordance.getRightViewProperties()) |
|
454 |
{ |
|
455 |
// if(propertiesToProcess.contains(property.getName())) |
|
456 |
// word.add(TxmRenderer.jseshrenderer.render(values.get(property).get(i))); |
|
457 |
// else |
|
458 |
word.add(values.get(property).get(i)); |
|
459 |
} |
|
460 |
words.add(StringUtils.join(word, "_")); //$NON-NLS-1$ |
|
461 |
} |
|
462 |
return LangFormater.format(StringUtils.join(words, " "), //$NON-NLS-1$ |
|
463 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
464 |
} |
|
465 |
|
|
466 |
/** |
|
467 |
* Keyword render. |
|
468 |
* |
|
469 |
* @param wordSeparator the word separator |
|
470 |
* @return the string |
|
471 |
*/ |
|
472 |
public String keywordRender(String wordSeparator) { |
|
473 |
// if(propertiesToProcess == null) |
|
474 |
// propertiesToProcess = TxmRenderer.getPropertyToRender(concordance, "jsesh"); //$NON-NLS-1$ |
|
475 |
|
|
476 |
List<String> words = new ArrayList<String>(); |
|
477 |
Map<Property, List<String>> values = getKeywordsViewProperties(); |
|
478 |
for (int i = 0; i < values.get( |
|
479 |
concordance.getKeywordViewProperties().get(0)).size(); i++) { |
|
480 |
List<String> word = new ArrayList<String>(); |
|
481 |
for (Property property : concordance.getKeywordViewProperties()) |
|
482 |
{ |
|
483 |
// if(propertiesToProcess.contains(property.getName())) |
|
484 |
// word.add(TxmRenderer.jseshrenderer.render(values.get(property).get(i))); |
|
485 |
// else |
|
486 |
word.add(values.get(property).get(i)); |
|
487 |
} |
|
488 |
words.add(StringUtils.join(word, wordSeparator)); |
|
489 |
} |
|
490 |
return LangFormater.format(StringUtils.join(words, wordSeparator), |
|
491 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Left context render. |
|
496 |
* |
|
497 |
* @param limit the limit |
|
498 |
* @return the string |
|
499 |
*/ |
|
500 |
public String leftContextRender(int limit) { |
|
501 |
List<String> words = new ArrayList<String>(); |
|
502 |
Map<Property, List<String>> values = getLeftCtxViewProperties(); |
|
503 |
int max = (limit == -1) ? (values.get(concordance |
|
504 |
.getLeftViewProperties().get(0)).size()) : (limit); |
|
505 |
int start = this.getLeftContextSize() - max; |
|
506 |
for (int i = start; i < this.getLeftContextSize(); i++) { |
|
507 |
List<String> word = new ArrayList<String>(); |
|
508 |
for (Property property : concordance.getLeftViewProperties()) |
|
509 |
{ |
|
510 |
// if(propertiesToProcess.contains(property.getName())) |
|
511 |
// word.add(TxmRenderer.jseshrenderer.render(values.get(property).get(i))); |
|
512 |
// else |
|
513 |
word.add(values.get(property).get(i)); |
|
514 |
} |
|
515 |
words.add(StringUtils.join(word, "_")); //$NON-NLS-1$ |
|
516 |
} |
|
517 |
|
|
518 |
return LangFormater.format(StringUtils.join(words, " "), //$NON-NLS-1$ |
|
519 |
concordance.getCorpus().getAttribute("lang")); //$NON-NLS-1$ |
|
520 |
// return fieldToString(getLeftCtxViewProperties(), propertySeparator, |
|
521 |
// wordSeparator); |
|
522 |
} |
|
523 |
|
|
524 |
/** |
|
525 |
* Returns a string representing the left context. Equivalent to |
|
526 |
* leftContextToString("/"," ") |
|
527 |
* |
|
528 |
* @return The string representation |
|
529 |
*/ |
|
530 |
public String leftContextToString() { |
|
531 |
return leftContextToString(PROP_SEPARTOR, " ", -1); //$NON-NLS-1$ |
|
532 |
} |
|
533 |
|
|
534 |
/** |
|
535 |
* Left context to string. |
|
536 |
* |
|
537 |
* @param limit the limit |
|
538 |
* @return the string |
|
539 |
*/ |
|
540 |
public String leftContextToString(int limit) { |
|
541 |
return leftContextToString(PROP_SEPARTOR, " ", limit); //$NON-NLS-1$ |
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* Returns a string representing the keywords. Equivalent to |
|
546 |
* keywordToString("/"," ") |
|
547 |
* |
|
548 |
* @return The string representation |
|
549 |
*/ |
|
550 |
public String keywordToString() { |
|
551 |
return keywordToString(PROP_SEPARTOR, " "); //$NON-NLS-1$ |
|
552 |
} |
|
553 |
|
|
554 |
/** |
|
555 |
* Returns a string representing the right context. Equivalent to |
|
556 |
* rightContextToString("/"," ") |
|
557 |
* |
|
558 |
* @return The string representation |
|
559 |
*/ |
|
560 |
public String rightContextToString() { |
|
561 |
return rightContextToString(PROP_SEPARTOR, " ", -1); //$NON-NLS-1$ |
|
562 |
} |
|
563 |
|
|
564 |
/** |
|
565 |
* Right context to string. |
|
566 |
* |
|
567 |
* @param limit the limit |
|
568 |
* @return the string |
|
569 |
*/ |
|
570 |
public String rightContextToString(int limit) { |
|
571 |
return rightContextToString(PROP_SEPARTOR, " ", limit); //$NON-NLS-1$ |
|
572 |
} |
|
573 |
|
|
574 |
/** |
|
575 |
* Match get start. |
|
576 |
* |
|
577 |
* @return the integer |
|
578 |
*/ |
|
579 |
public Integer matchGetStart() { |
|
580 |
return match.getStart(); |
|
581 |
} |
|
582 |
|
|
583 |
/** |
|
584 |
* Match get end. |
|
585 |
* |
|
586 |
* @return the integer |
|
587 |
*/ |
|
588 |
public Integer matchGetEnd() { |
|
589 |
return match.getEnd(); |
|
590 |
} |
|
591 |
|
|
592 |
/** |
|
593 |
* Match get col. |
|
594 |
* |
|
595 |
* @param corpus the corpus |
|
596 |
* @return the string |
|
597 |
* @throws CqiClientException the cqi client exception |
|
598 |
*/ |
|
599 |
public String matchGetCol(Corpus corpus) throws CqiClientException { |
|
600 |
return match.getValueForProperty(corpus.getProperty("col")); //$NON-NLS-1$ |
|
601 |
} |
|
602 |
|
|
603 |
/** |
|
604 |
* Match get id. |
|
605 |
* |
|
606 |
* @param corpus the corpus |
|
607 |
* @return the list |
|
608 |
* @throws CqiClientException the cqi client exception |
|
609 |
*/ |
|
610 |
public List<String> matchGetId(Corpus corpus) throws CqiClientException { |
|
611 |
return match.getValuesForProperty(corpus.getProperty("id")); //$NON-NLS-1$ |
|
612 |
} |
|
613 |
|
|
614 |
/** |
|
615 |
* Match get id. |
|
616 |
* |
|
617 |
* @param corpus the corpus |
|
618 |
* @param positions the positions |
|
619 |
* @return the list |
|
620 |
* @throws CqiClientException the cqi client exception |
|
621 |
*/ |
|
622 |
@SuppressWarnings("static-access") //$NON-NLS-1$ |
|
623 |
public List<String> matchGetId(Corpus corpus, int[] positions) |
|
624 |
throws CqiClientException { |
|
625 |
return match.getValuesForProperty(corpus.getProperty("id"), positions); //$NON-NLS-1$ |
|
626 |
} |
|
627 |
|
|
628 |
/** |
|
629 |
* Match get propertie. |
|
630 |
* |
|
631 |
* @param corpus the corpus |
|
632 |
* @param propertie the propertie |
|
633 |
* @param positions the positions |
|
634 |
* @return the list |
|
635 |
* @throws CqiClientException the cqi client exception |
|
636 |
*/ |
|
637 |
@SuppressWarnings("static-access") //$NON-NLS-1$ |
|
638 |
public List<String> matchGetPropertie(Corpus corpus, String propertie, |
|
639 |
int[] positions) throws CqiClientException { |
|
640 |
return match.getValuesForProperty(corpus.getProperty(propertie), |
|
641 |
positions); |
|
642 |
} |
|
643 |
|
|
644 |
/** |
|
645 |
* Match get properties. |
|
646 |
* |
|
647 |
* @param corpus the corpus |
|
648 |
* @param propertie the propertie |
|
649 |
* @param positions the positions |
|
650 |
* @return the list |
|
651 |
* @throws CqiClientException the cqi client exception |
|
652 |
*/ |
|
653 |
@SuppressWarnings("static-access") //$NON-NLS-1$ |
|
654 |
public List<String> matchGetProperties(Corpus corpus, Property propertie, |
|
655 |
int[] positions) throws CqiClientException { |
|
656 |
return match.getValuesForProperty(propertie, positions); |
|
657 |
} |
|
658 |
|
|
659 |
/** |
|
660 |
* Gets the text id. |
|
661 |
* |
|
662 |
* @return the text id |
|
663 |
*/ |
|
664 |
public Object getTextId() { |
|
665 |
return this.textId; |
|
666 |
} |
|
667 |
|
|
668 |
/** |
|
669 |
* Gets the concordance. |
|
670 |
* |
|
671 |
* @return the concordance |
|
672 |
*/ |
|
673 |
public Concordance getConcordance() { |
|
674 |
return concordance; |
|
675 |
} |
|
676 |
|
|
677 |
/** |
|
678 |
* Gets the keyword ids. |
|
679 |
* |
|
680 |
* @return the keyword ids |
|
681 |
*/ |
|
682 |
public Collection<? extends String> getKeywordIds() { |
|
683 |
return this.keywordsIdValues; |
|
684 |
} |
|
685 |
|
|
686 |
/** |
|
687 |
* Gets the keyword position. |
|
688 |
* |
|
689 |
* @return the keyword position |
|
690 |
*/ |
|
691 |
public int getKeywordPosition() { |
|
692 |
return keywordpos; |
|
693 |
} |
|
694 |
|
|
695 |
public Annotation getAnnotation() { |
|
696 |
return annotation; |
|
697 |
} |
|
698 |
} |
|
0 | 699 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/LexicographicLeftContextComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2014-07-15 09:42:00 +0200 (mar., 15 juil. 2014) $ |
|
25 |
// $LastChangedRevision: 2820 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.core.messages.TXMCoreMessages; |
|
34 |
import org.txm.functions.concordances.Concordance; |
|
35 |
import org.txm.functions.concordances.Line; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of left context of a concordance line @ author mdecorde. |
|
41 |
*/ |
|
42 |
public class LexicographicLeftContextComparator extends |
|
43 |
StringListBasedComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = TXMCoreMessages.LexicographicLeftContextComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic left context comparator. |
|
52 |
*/ |
|
53 |
public LexicographicLeftContextComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
|
|
63 |
this.conc = l1.getConcordance(); |
|
64 |
this.props = conc.getLeftAnalysisProperties(); |
|
65 |
if (props.size() == 0) |
|
66 |
return 0; |
|
67 |
int rez = 0; |
|
68 |
int i = 0; |
|
69 |
|
|
70 |
HashMap<Property, List<String>> values1 = l1.getLeftAnalysisProperty(); |
|
71 |
HashMap<Property, List<String>> values2 = l2.getLeftAnalysisProperty(); |
|
72 |
int j1 = l1.getLeftAnalysisProperty().get(props.get(0)).size() -1; |
|
73 |
int j2 = l2.getLeftAnalysisProperty().get(props.get(0)).size() -1; |
|
74 |
|
|
75 |
String v1, v2; |
|
76 |
|
|
77 |
while (rez == 0) { |
|
78 |
|
|
79 |
if ((j1 < 0) && (j2 < 0)) |
|
80 |
return 0; |
|
81 |
if (j1 < 0) |
|
82 |
return -1; // end of line 1 |
|
83 |
if (j2 < 0) |
|
84 |
return 1; // end of line 2 |
|
85 |
|
|
86 |
v1 = values1.get(props.get(i)).get(j1); |
|
87 |
v2 = values2.get(props.get(i)).get(j2); |
|
88 |
|
|
89 |
if (v1 == null) return -1; |
|
90 |
if (v2 == null) return 1; |
|
91 |
|
|
92 |
rez = collator.compare(v1, v2); |
|
93 |
if (++i >= props.size()) { // iterates over properties before tokens |
|
94 |
i = 0; |
|
95 |
j1--; |
|
96 |
j2--; |
|
97 |
} |
|
98 |
} |
|
99 |
return rez; |
|
100 |
} |
|
101 |
} |
|
0 | 102 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/StringListBasedComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
// TODO: Auto-generated Javadoc |
|
34 |
/** |
|
35 |
* The Class StringListBasedComparator. |
|
36 |
*/ |
|
37 |
public abstract class StringListBasedComparator extends LocalizedLineComparator { |
|
38 |
|
|
39 |
/** |
|
40 |
* Instantiates a new string list based comparator. |
|
41 |
* |
|
42 |
* @param name the name |
|
43 |
*/ |
|
44 |
StringListBasedComparator(String name) { |
|
45 |
super(name); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Compare list. |
|
50 |
* |
|
51 |
* @param l1 the l1 |
|
52 |
* @param l2 the l2 |
|
53 |
* @return the int |
|
54 |
*/ |
|
55 |
protected int compareList(List<String> l1, List<String> l2) { |
|
56 |
Iterator<String> it1 = l1.iterator(); |
|
57 |
Iterator<String> it2 = l2.iterator(); |
|
58 |
|
|
59 |
while (it1.hasNext() && it2.hasNext()) { |
|
60 |
int c = collator.compare(it1.next(), it2.next()); |
|
61 |
if (c != 0) |
|
62 |
return c; |
|
63 |
} |
|
64 |
if (it1.hasNext()) |
|
65 |
return 1; // it2 is a prefix of it1 |
|
66 |
if (it2.hasNext()) |
|
67 |
return -1; // it1 is a prefix of it2 |
|
68 |
return 0; |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/CompositeComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.txm.core.messages.TXMCoreMessages; |
|
33 |
import org.txm.functions.concordances.Line; |
|
34 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
35 |
|
|
36 |
// TODO: Auto-generated Javadoc |
|
37 |
/** |
|
38 |
* The Class CompositeComparator. |
|
39 |
*/ |
|
40 |
public class CompositeComparator extends LineComparator { |
|
41 |
|
|
42 |
/** The comparators. */ |
|
43 |
private List<LineComparator> comparators; |
|
44 |
|
|
45 |
/** |
|
46 |
* Instantiates a new composite comparator. A composite comparator C is made |
|
47 |
* of a list compartors [C0,...,Cn]. C.compare(l1,l2) == 1 (resp. -1) if and |
|
48 |
* only if their exists k such as Ci.compare(l1,l2)==0 for i<k and |
|
49 |
* Ck.compare(l1,l2)=1 (resp. -1) C.compare(l1,l2) == 0 if and only if |
|
50 |
* Ci.compare(l1,l2)==0 for all i |
|
51 |
* |
|
52 |
* @param name the name |
|
53 |
* @param comparators the comparators |
|
54 |
*/ |
|
55 |
public CompositeComparator(String name, List<LineComparator> comparators) { |
|
56 |
super(name); |
|
57 |
setComparators(comparators); |
|
58 |
} |
|
59 |
|
|
60 |
/*public CompositeComparator addComparator(LineComparator comparator) { |
|
61 |
this.comparators.add(comparator); |
|
62 |
return this; |
|
63 |
}*/ |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public int compare(Line l1, Line l2) { |
|
70 |
//System.out.println("compare: "+l1+" "+l2); |
|
71 |
for (LineComparator comparator : comparators) { |
|
72 |
int c = comparator.compare(l1, l2); |
|
73 |
//System.out.println("comparator: "+comparator+" = "+c); |
|
74 |
if (c != 0) |
|
75 |
return c; |
|
76 |
} |
|
77 |
return 0; |
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.txm.functions.concordances.comparators.LineComparator#initialize(org.txm.searchengine.cqp.corpus.Corpus) |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public void initialize(Corpus corpus) { |
|
85 |
for (LineComparator comparator : comparators) |
|
86 |
comparator.initialize(corpus); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Gets the comparators. |
|
91 |
* |
|
92 |
* @return the comparators |
|
93 |
*/ |
|
94 |
public List<LineComparator> getComparators() { |
|
95 |
return comparators; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Sets the comparators. |
|
100 |
* |
|
101 |
* @param comp the new comparators |
|
102 |
*/ |
|
103 |
public void setComparators(List<LineComparator> comp) { |
|
104 |
this.comparators = comp; |
|
105 |
this.name = TXMCoreMessages.CompositeComparator_0; |
|
106 |
for(LineComparator c: comp) |
|
107 |
this.name += c.getName()+" "; //$NON-NLS-1$ |
|
108 |
} |
|
109 |
} |
|
0 | 110 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/LexicographicRightContextComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2014-07-15 09:42:00 +0200 (mar., 15 juil. 2014) $ |
|
25 |
// $LastChangedRevision: 2820 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.core.messages.TXMCoreMessages; |
|
34 |
import org.txm.functions.concordances.Concordance; |
|
35 |
import org.txm.functions.concordances.Line; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of right context of a concordance line @ author mdecorde. |
|
41 |
*/ |
|
42 |
public class LexicographicRightContextComparator extends |
|
43 |
StringListBasedComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = TXMCoreMessages.LexicographicRightContextComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic right context comparator. |
|
52 |
*/ |
|
53 |
public LexicographicRightContextComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
int rez = 0; |
|
63 |
int i = 0; // property counter |
|
64 |
int j = 0; // position counter |
|
65 |
HashMap<Property, List<String>> values1 = l1.getRightAnalysisProperty(); |
|
66 |
HashMap<Property, List<String>> values2 = l2.getRightAnalysisProperty(); |
|
67 |
this.conc = l1.getConcordance(); |
|
68 |
this.props = conc.getRightAnalysisProperties(); |
|
69 |
|
|
70 |
List<String> vals1; |
|
71 |
List<String> vals2; |
|
72 |
|
|
73 |
String v1, v2; |
|
74 |
|
|
75 |
int size1 = values1.get(props.get(0)).size(); |
|
76 |
int size2 = values2.get(props.get(0)).size(); |
|
77 |
|
|
78 |
while (rez == 0) { |
|
79 |
// vals1 = values1.get(props.get(i)); |
|
80 |
// vals2 = values2.get(props.get(i)); |
|
81 |
|
|
82 |
//System.out.println("LINE 1: "+vals1); |
|
83 |
//System.out.println("LINE 2: "+vals2); |
|
84 |
if(size1 <= j && size2 <= j) |
|
85 |
return 0; // end of line 1 |
|
86 |
if (size1 <= j) |
|
87 |
return -1; // end of line 1 |
|
88 |
if (size2 <= j) |
|
89 |
return 1; // end of line 2 |
|
90 |
|
|
91 |
v1 = values1.get(props.get(i)).get(j); |
|
92 |
v2 = values2.get(props.get(i)).get(j); |
|
93 |
|
|
94 |
//System.out.println("COMP "+j+" : "+v1+" "+v2); |
|
95 |
if (v1 == null) return -1; |
|
96 |
if (v2 == null) return 1; |
|
97 |
|
|
98 |
rez = collator.compare(v1, v2); |
|
99 |
if (++i >= props.size()) { // iterates over properties before tokens |
|
100 |
i = 0; |
|
101 |
j++; |
|
102 |
} |
|
103 |
} |
|
104 |
return rez; |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/LexicographicKeywordComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.core.messages.TXMCoreMessages; |
|
34 |
import org.txm.functions.concordances.Concordance; |
|
35 |
import org.txm.functions.concordances.Line; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of keyword of a concordance line |
|
41 |
* @author mdecorde. |
|
42 |
*/ |
|
43 |
public class LexicographicKeywordComparator extends LocalizedLineComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = TXMCoreMessages.LexicographicKeywordComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic keyword comparator. |
|
52 |
*/ |
|
53 |
public LexicographicKeywordComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
int rez = 0; |
|
63 |
int i = 0; |
|
64 |
int j = 0; |
|
65 |
HashMap<Property, List<String>> values1 = l1.getKeywordsAnalysisProperty(); |
|
66 |
HashMap<Property, List<String>> values2 = l2.getKeywordsAnalysisProperty(); |
|
67 |
this.conc = l1.getConcordance(); |
|
68 |
this.props = conc.getKeywordAnalysisProperties(); |
|
69 |
while(rez == 0) { |
|
70 |
List<String> vals1 = values1.get(props.get(i)); |
|
71 |
List<String> vals2 = values2.get(props.get(i)); |
|
72 |
if(vals1.size() <= j && vals2.size() <= j) |
|
73 |
return 0; // end of line 1 |
|
74 |
if(vals1.size() <= j) |
|
75 |
return -1; // end of line 1 |
|
76 |
if(vals2.size() <= j) |
|
77 |
return 1; // end of line 2 |
|
78 |
rez = collator.compare(vals1.get(j), vals2.get(j)); |
|
79 |
if(++i >= props.size()) { // iterates over properties before tokens |
|
80 |
i = 0; |
|
81 |
j++; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
return rez; |
|
86 |
} |
|
87 |
} |
|
0 | 88 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/package.html (revision 317) | ||
---|---|---|
1 |
<html> |
|
2 |
<body> |
|
3 |
<p>Sorters for displaying concordance.</p> |
|
4 |
</body> |
|
5 |
</html> |
|
0 | 6 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/LineComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import java.util.Comparator; |
|
31 |
|
|
32 |
import org.txm.functions.concordances.Line; |
|
33 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
34 |
|
|
35 |
// TODO: Auto-generated Javadoc |
|
36 |
/** |
|
37 |
* Abstract comparator of concordance line @ author mdecorde. |
|
38 |
*/ |
|
39 |
public abstract class LineComparator implements Comparator<Line> { |
|
40 |
|
|
41 |
/** The name. */ |
|
42 |
protected String name; |
|
43 |
|
|
44 |
/** The available comparator. */ |
|
45 |
private static String[] availableComparator = new String[] { |
|
46 |
"org.txm.functions.concordances.comparators.LexicographicKeywordComparator", //$NON-NLS-1$ |
|
47 |
"org.txm.functions.concordances.comparators.LexicographicLeftContextComparator", //$NON-NLS-1$ |
|
48 |
"org.txm.functions.concordances.comparators.LexicographicRightContextComparator", //$NON-NLS-1$ |
|
49 |
"org.txm.functions.concordances.comparators.PropertiesReferenceComparator" //$NON-NLS-1$ |
|
50 |
}; |
|
51 |
|
|
52 |
/** |
|
53 |
* Return the list of all the known comparators. Any non-abstract class |
|
54 |
* extending LineComparator should be mentionned in the availableComparator |
|
55 |
* list |
|
56 |
* |
|
57 |
* @return the available comparators |
|
58 |
*/ |
|
59 |
static public String[] getAvailableComparators() { |
|
60 |
return availableComparator; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Instantiates a new line comparator. |
|
65 |
* |
|
66 |
* @param name the name |
|
67 |
*/ |
|
68 |
public LineComparator(String name) { |
|
69 |
this.name = name; |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Gets the name. |
|
75 |
* |
|
76 |
* @return the name |
|
77 |
*/ |
|
78 |
public String getName() { |
|
79 |
return name; |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see java.lang.Object#toString() |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public String toString() { |
|
87 |
return "C:" + name; //$NON-NLS-1$ |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Initialize. |
|
92 |
* |
|
93 |
* @param corpus the corpus |
|
94 |
*/ |
|
95 |
public abstract void initialize(Corpus corpus); |
|
96 |
|
|
97 |
} |
|
0 | 98 |
tmp/org.txm.concordance.core/src/org/txm/functions/concordances/comparators/NullComparator.java (revision 317) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions.concordances.comparators; |
|
29 |
|
|
30 |
import org.txm.core.messages.TXMCoreMessages; |
|
31 |
import org.txm.functions.concordances.Line; |
|
32 |
|
|
33 |
// TODO: Auto-generated Javadoc |
|
34 |
/** |
|
35 |
* return the order of the text. |
|
36 |
* |
|
37 |
* @author mdecorde |
|
38 |
*/ |
|
39 |
public class NullComparator extends LocalizedLineComparator { |
|
40 |
|
|
41 |
/** The Constant NAME. */ |
Formats disponibles : Unified diff