Révision 1061
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/tests/TestSubcorpus.java (revision 1061) | ||
---|---|---|
11 | 11 |
import org.txm.searchengine.cqp.corpus.Corpus; |
12 | 12 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
13 | 13 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
14 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
14 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
15 | 15 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
16 | 16 |
|
17 | 17 |
public class TestSubcorpus { |
... | ... | |
26 | 26 |
public boolean test1(File outdir) { |
27 | 27 |
try { |
28 | 28 |
Corpus corpus = CorpusManager.getCorpusManager().getCorpus(CORPUS); |
29 |
Subcorpus sub = corpus.createSubcorpus(new Query("\"je\" expand to p"), "JEP"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
29 |
Subcorpus sub = corpus.createSubcorpus(new CQLQuery("\"je\" expand to p"), "JEP"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
30 | 30 |
|
31 | 31 |
writePositions(sub, new File(outdir, TestSubcorpus.class.getName()+"_test1.csv")); //$NON-NLS-1$ |
32 | 32 |
} catch (Exception e) { |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/functions/summary/Summary.java (revision 1061) | ||
---|---|---|
15 | 15 |
import org.txm.searchengine.cqp.corpus.Property; |
16 | 16 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
17 | 17 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
18 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
18 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
19 | 19 |
|
20 | 20 |
public class Summary extends TXMResult { |
21 | 21 |
|
... | ... | |
68 | 68 |
String suname = properties.get(j).getStructuralUnit().getName(); |
69 | 69 |
//System.out.println("getting : "+properties.get(j).getFullName()); |
70 | 70 |
|
71 |
QueryResult result = corpus.query(new Query("<"+properties.get(j).getFullName()+">[]"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
71 |
QueryResult result = corpus.query(new CQLQuery("<"+properties.get(j).getFullName()+">[]"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
72 | 72 |
int[] starts = result.getStarts(); |
73 | 73 |
result.drop(); |
74 |
result = corpus.query(new Query("[]</"+properties.get(j).getFullName()+">"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
74 |
result = corpus.query(new CQLQuery("[]</"+properties.get(j).getFullName()+">"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
75 | 75 |
int[] ends = result.getStarts(); |
76 | 76 |
result.drop(); |
77 | 77 |
//System.out.println("starts: "+Arrays.toString(starts)); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/functions/selection/Selection.java (revision 1061) | ||
---|---|---|
47 | 47 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
49 | 49 |
import org.txm.searchengine.cqp.corpus.query.Match; |
50 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
50 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
51 | 51 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
52 | 52 |
import org.txm.utils.logger.Log; |
53 | 53 |
|
... | ... | |
64 | 64 |
Corpus corpus; |
65 | 65 |
|
66 | 66 |
/** The query to get texts metadatas and number. */ |
67 |
Query query; |
|
67 |
CQLQuery query;
|
|
68 | 68 |
|
69 | 69 |
/** The cqp positions of the texts start element. */ |
70 | 70 |
int[] positions; |
... | ... | |
103 | 103 |
public Selection(MainCorpus corpus) { |
104 | 104 |
super(corpus); |
105 | 105 |
// this query returns N results, where N is the number of text |
106 |
this.query = new Query("<text>[]"); //$NON-NLS-1$ |
|
106 |
this.query = new CQLQuery("<text>[]"); //$NON-NLS-1$
|
|
107 | 107 |
this.corpus = corpus; |
108 | 108 |
init(); |
109 | 109 |
} |
... | ... | |
168 | 168 |
this.metadatasValuesPerText.put(textids.get(i), new HashMap<String, String>()); |
169 | 169 |
|
170 | 170 |
//QueryResult result2 = corpus.query(new Query("[_.text_id=\""+textids.get(i)+"\"] expand to text"), "temp", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
171 |
QueryResult result2 = corpus.query(new Query("/region[text,a]:: a.text_id=\""+textids.get(i)+"\""), "temp", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
171 |
QueryResult result2 = corpus.query(new CQLQuery("/region[text,a]:: a.text_id=\""+textids.get(i)+"\""), "temp", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
172 | 172 |
int tot = 0; |
173 | 173 |
for (Match m : result2.getMatches(0,0)) |
174 | 174 |
tot += m.getEnd()- m.getStart(); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Alignement.java (revision 1061) | ||
---|---|---|
11 | 11 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
12 | 12 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
13 | 13 |
import org.txm.searchengine.cqp.corpus.query.Match; |
14 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
14 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
15 | 15 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
16 | 16 |
|
17 | 17 |
public class Alignement { |
... | ... | |
62 | 62 |
|
63 | 63 |
if (struct.equals("w")) |
64 | 64 |
{ |
65 |
QueryResult rez = src.query(new Query("[_.text_id=\""+textid+"\" & id=\""+wordid+"\"]"), "Align", false); |
|
65 |
QueryResult rez = src.query(new CQLQuery("[_.text_id=\""+textid+"\" & id=\""+wordid+"\"]"), "Align", false);
|
|
66 | 66 |
int[] position = {rez.getMatch(0).getStart()}; |
67 | 67 |
int[] struct_align_pos = CQPSearchEngine.getCqiClient().cpos2Struc(align_src.getQualifiedName(), position); |
68 | 68 |
String[] struct_align_str = CQPSearchEngine.getCqiClient().struc2Str(align_src.getQualifiedName(), struct_align_pos); |
... | ... | |
70 | 70 |
{ |
71 | 71 |
String aligned_struct = struct_align_str[0]; // the struct align value |
72 | 72 |
// get the position of the first token of this struct |
73 |
QueryResult rez2 = dest.query(new Query("<"+struct+"_align=\""+aligned_struct+"\">[]"), "Align", false); |
|
73 |
QueryResult rez2 = dest.query(new CQLQuery("<"+struct+"_align=\""+aligned_struct+"\">[]"), "Align", false);
|
|
74 | 74 |
int[] position2 = {rez2.getMatch(0).getStart()}; |
75 | 75 |
// get the id of this position |
76 | 76 |
int[] struct_text_pos = CQPSearchEngine.getCqiClient().cpos2Struc(text_dest.getQualifiedName(), position2); |
... | ... | |
87 | 87 |
//get the position for the word id and the text |
88 | 88 |
String query = "[_.text_id=\""+textid+"\" & id=\""+wordid+"\"]"; |
89 | 89 |
//System.out.println("query: "+query); |
90 |
QueryResult rez = src.query(new Query(query), "Align", false); |
|
90 |
QueryResult rez = src.query(new CQLQuery(query), "Align", false);
|
|
91 | 91 |
//System.out.println(rez.getMatches()); |
92 | 92 |
int[] position = {rez.getMatch(0).getStart()}; |
93 | 93 |
//get the struct@align value for this position |
... | ... | |
98 | 98 |
String aligned_struct = struct_align_str[0]; // the struct align value |
99 | 99 |
// get the position of the first token of this struct |
100 | 100 |
query = "<"+struct+"_align=\""+aligned_struct+"\">[]"; |
101 |
QueryResult rez2 = dest.query(new Query(query), "Align", false); |
|
101 |
QueryResult rez2 = dest.query(new CQLQuery(query), "Align", false);
|
|
102 | 102 |
int[] position2 = {rez2.getMatch(0).getStart()}; |
103 | 103 |
// get the id of this position |
104 | 104 |
String[] ids = CQPSearchEngine.getCqiClient().cpos2Str(id_dest.getQualifiedName(), position2); |
... | ... | |
161 | 161 |
Corpus dest = CorpusManager.getCorpusManager().getCorpus(to); |
162 | 162 |
String query = "<"+struct+"_align=\""+seg_id+"\">[]"; |
163 | 163 |
//System.out.println("query: "+query); |
164 |
QueryResult rez = dest.query(new Query(query), "Align", false); |
|
164 |
QueryResult rez = dest.query(new CQLQuery(query), "Align", false);
|
|
165 | 165 |
//System.out.println("rez: "+rez.getMatches()); |
166 | 166 |
int[] position = {rez.getMatch(0).getStart()}; |
167 | 167 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Query.java (revision 1061) | ||
---|---|---|
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: 2015-05-13 09:46:56 +0200 (Wed, 13 May 2015) $ |
|
25 |
// $LastChangedRevision: 2967 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.searchengine.cqp.corpus.query; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
import java.util.regex.Matcher; |
|
33 |
import java.util.regex.Pattern; |
|
34 |
|
|
35 |
import org.txm.core.preferences.TXMPreferences; |
|
36 |
|
|
37 |
/** |
|
38 |
* Implements a CQL query. Use fixQuery to use query sugar. |
|
39 |
* |
|
40 |
* @author sloiseau |
|
41 |
* @author jpmague |
|
42 |
* @author sheiden |
|
43 |
* @author sjacquot |
|
44 |
*/ |
|
45 |
|
|
46 |
public class Query { |
|
47 |
|
|
48 |
/** The Constant NoStrategy. */ |
|
49 |
private static final Integer NoStrategy = 0; |
|
50 |
|
|
51 |
/** The Constant JPMStrategy. */ |
|
52 |
private static final Integer JPMStrategy = 1; |
|
53 |
|
|
54 |
/** The Constant WLXStrategy. */ |
|
55 |
private static final Integer WLXStrategy = 2; |
|
56 |
|
|
57 |
/** The Constant ElectricStrategy. */ |
|
58 |
private static final Integer ElectricStrategy = 3; |
|
59 |
|
|
60 |
|
|
61 |
/** espace char |"{()}+*. */ |
|
62 |
private static String chars = "^$<>|\\\"{([])}?+*."; //$NON-NLS-1$ |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* The query string. |
|
67 |
*/ |
|
68 |
protected String queryString; |
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
/** |
|
73 |
* Instantiates a new query. |
|
74 |
*/ |
|
75 |
protected Query() { |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Instantiates a new query. |
|
80 |
* |
|
81 |
* @param queryString |
|
82 |
* the query string |
|
83 |
* |
|
84 |
* public Query(String queryString){ |
|
85 |
* this.queryString=queryString.trim(); } |
|
86 |
*/ |
|
87 |
public Query(String queryString) { |
|
88 |
if (queryString != null) { |
|
89 |
this.queryString = queryString.trim(); |
|
90 |
} |
|
91 |
else { |
|
92 |
this.queryString = ""; |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Converts the specified string to a list of Query. |
|
98 |
* Input string must contains queries separated by a tabulation. |
|
99 |
* @param str |
|
100 |
* @return |
|
101 |
*/ |
|
102 |
public static List<Query> stringToQueries(String str) { |
|
103 |
ArrayList<Query> queries = new ArrayList<Query>(); |
|
104 |
if (str == null || str.length() == 0) { |
|
105 |
return queries; |
|
106 |
} |
|
107 |
String[] split = str.split(TXMPreferences.LIST_SEPARATOR); |
|
108 |
for (String s : split) { |
|
109 |
queries.add(new Query(s)); |
|
110 |
} |
|
111 |
return queries; |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
/** |
|
116 |
* Converts the specified list of Query to a string. |
|
117 |
* Queries strings are separated by a tabulation. |
|
118 |
* @param queries |
|
119 |
* @return |
|
120 |
*/ |
|
121 |
public static String queriesToString(List<Query> queries) { |
|
122 |
String str = ""; |
|
123 |
for (int i = 0; i < queries.size(); i++) { |
|
124 |
if(i > 0) { |
|
125 |
str += TXMPreferences.LIST_SEPARATOR; |
|
126 |
} |
|
127 |
str += queries.get(i).getQueryString(); |
|
128 |
} |
|
129 |
return str; |
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
/** |
|
134 |
* Gets the query string. |
|
135 |
* |
|
136 |
* @return the query string |
|
137 |
*/ |
|
138 |
public String getQueryString() { |
|
139 |
return queryString; |
|
140 |
} |
|
141 |
|
|
142 |
/* (non-Javadoc) |
|
143 |
* @see java.lang.Object#toString() |
|
144 |
*/ |
|
145 |
@Override |
|
146 |
public String toString() { |
|
147 |
return queryString; |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* Normalize white chars. |
|
152 |
* |
|
153 |
* SLH algorithm : |
|
154 |
* - first normalize white chars : We don't know from where the query |
|
155 |
* comes from and how it was produced (pasted from a text editor after |
|
156 |
* having been double-clicked and copied, typed in the query input |
|
157 |
* field, etc.) The CQP syntax analyzer is sensible to white chars, so |
|
158 |
* we have to normalize what the user may have leaved inadvertently |
|
159 |
* because she may not see well the true query string (white chars are |
|
160 |
* invisible), and it is dif ficult to accept and manage a syntax error |
|
161 |
* when you can't "see" the source of the problem. That strategy decides |
|
162 |
* to interpret every white chars contiguous sequence as one space |
|
163 |
* character. |
|
164 |
* |
|
165 |
* Please note that this may be compatible (or not) with other Search |
|
166 |
* Engines query scanners. |
|
167 |
* |
|
168 |
* Please note also that this may be compatible (or not) with the |
|
169 |
* tokenization policy of a given corpus dealing with compound words. |
|
170 |
* That strategy is compatible with a policy which separates words in |
|
171 |
* compound words by one space character. |
|
172 |
* |
|
173 |
* - then remove outer white chars : What is not seen should not be |
|
174 |
* there if no explicit expression deals with it from the user's point |
|
175 |
* of view. So white chars at the beginning or at the end of the query |
|
176 |
* are removed. Those characters often come from rapid copy/paste or |
|
177 |
* double-click/copy/paste (in a word processing software, the |
|
178 |
* double-click strategy can for example select the white chars on the |
|
179 |
* right of the selected strings to help the user move words around with |
|
180 |
* their delimiters). |
|
181 |
* |
|
182 |
* That strategy may seem aggressive, but experience shows that this |
|
183 |
* little service helps silently users a lot and is rarely |
|
184 |
* inappropriate. |
|
185 |
* |
|
186 |
* In case of doubt, the user should be able to switch to another |
|
187 |
* strategy. |
|
188 |
* |
|
189 |
* @param str the str |
|
190 |
* @return the string with white chars normalized |
|
191 |
*/ |
|
192 |
public static String normalizeWhiteChars(String str) { |
|
193 |
|
|
194 |
// normalize everything white to space |
|
195 |
String str1 = str.replaceAll("\\s+", " "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
196 |
// remove border whites |
|
197 |
str1 = str1.replaceFirst("^ ", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
198 |
str1 = str1.replaceFirst(" $", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
199 |
return str1; |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* Transforms a simplified query string into a proper CQP query string |
|
204 |
* |
|
205 |
* Follows several different strategies to do that : |
|
206 |
* |
|
207 |
* JPM Strategy : if the input query matches \w quote are added if the input |
|
208 |
* query matches \w*="\w*", square brackets are added if the input query |
|
209 |
* matches .\w=.\w (i.e. without quotes), quotes and square brackets are |
|
210 |
* added (i.e. -> [$1="$2"]) otherwise, the query is left as if |
|
211 |
* |
|
212 |
* Weblex Strategy : normalize white chars add double quotes if no double |
|
213 |
* quotes and no brackets |
|
214 |
* |
|
215 |
* Electric Strategy : normalize white chars add double quote, equal, |
|
216 |
* brackets, etc. depending on the presence/absence of those chars in the |
|
217 |
* original query |
|
218 |
* |
|
219 |
* No Strategy : do nothing |
|
220 |
* |
|
221 |
* @param query |
|
222 |
* The query string to fix |
|
223 |
* @return the fixed query string |
|
224 |
*/ |
|
225 |
static public String fixQuery(String query) { |
|
226 |
|
|
227 |
//if (query.startsWith("intersect ")) return query; |
|
228 |
|
|
229 |
if ("\"".equals(query)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
230 |
|
|
231 |
Integer QueryFixStrategy = WLXStrategy; |
|
232 |
|
|
233 |
if (QueryFixStrategy == JPMStrategy) { |
|
234 |
|
|
235 |
// query = abc -> put double quotes |
|
236 |
Pattern simple = Pattern.compile("\\p{L}*"); //$NON-NLS-1$ |
|
237 |
if (simple.matcher(query).matches()) { |
|
238 |
// System.out.println("match 1"); |
|
239 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
240 |
} |
|
241 |
|
|
242 |
// query = prop="abc" -> put square brackets |
|
243 |
Pattern equalsWithQuotes = Pattern.compile("\\p{L}+=\"\\p{L}*\""); //$NON-NLS-1$ |
|
244 |
if (equalsWithQuotes.matcher(query).matches()) { |
|
245 |
// System.out.println("match 2"); |
|
246 |
return '[' + query + ']'; |
|
247 |
} |
|
248 |
|
|
249 |
// query = abc=def -> put brackets + equal sign + double quotes |
|
250 |
Pattern equalsWithoutQuotes = Pattern |
|
251 |
.compile("(\\p{L}*)=(\\p{L}*)"); //$NON-NLS-1$ |
|
252 |
Matcher matcher = equalsWithoutQuotes.matcher(query); |
|
253 |
if (matcher.matches()) { |
|
254 |
// System.out.println("match 2"); |
|
255 |
return '[' + matcher.group(1) + '=' + '"' + matcher.group(2) |
|
256 |
+ '"' + ']'; |
|
257 |
} |
|
258 |
|
|
259 |
// query doesn't start with ", ' and [ -> put double quotes |
|
260 |
if (!query.startsWith("\"") && !query.startsWith("\'") && !query.startsWith("[")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
261 |
{ |
|
262 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
263 |
} |
|
264 |
|
|
265 |
// do nothing |
|
266 |
return query; |
|
267 |
|
|
268 |
} else if (QueryFixStrategy == WLXStrategy) { |
|
269 |
|
|
270 |
query = normalizeWhiteChars(query); |
|
271 |
|
|
272 |
// empty query |
|
273 |
if(query.isEmpty()) { |
|
274 |
return query; |
|
275 |
} |
|
276 |
// query contains double quotes |
|
277 |
else if (query.contains("\"")) { //$NON-NLS-1$ |
|
278 |
return query; |
|
279 |
} |
|
280 |
// query contains brackets |
|
281 |
else if (query.contains("[") && query.contains("]")) { //$NON-NLS-1$ //$NON-NLS-2$ |
|
282 |
return query; // probably [] or [...] |
|
283 |
} |
|
284 |
else { |
|
285 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
286 |
} |
|
287 |
} else if (QueryFixStrategy == ElectricStrategy) { |
|
288 |
|
|
289 |
// DON'T USE THAT STRATEGY : CODE NEEDS TO BE FIXED |
|
290 |
query = normalizeWhiteChars(query); |
|
291 |
|
|
292 |
if (query.contains("\"")) { //$NON-NLS-1$ |
|
293 |
if (query.contains("=")) { //$NON-NLS-1$ |
|
294 |
if (query.contains("[")) { //$NON-NLS-1$ |
|
295 |
return query; |
|
296 |
} else { |
|
297 |
return '[' + query + ']'; |
|
298 |
} |
|
299 |
} else { |
|
300 |
return query; |
|
301 |
} |
|
302 |
} else { |
|
303 |
if (query.contains("=")) { //$NON-NLS-1$ |
|
304 |
return query.replaceAll("=([^= \"]+)", "=\"$1\""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
305 |
} else { |
|
306 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
307 |
} |
|
308 |
} |
|
309 |
} else if (QueryFixStrategy == NoStrategy) { |
|
310 |
|
|
311 |
// no strategy to apply : do nothing |
|
312 |
return query; |
|
313 |
|
|
314 |
} else { |
|
315 |
|
|
316 |
// we shouldn't be there |
|
317 |
// let silently return the query for the moment |
|
318 |
return query; |
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
/** |
|
325 |
* Adds the back slash. |
|
326 |
* |
|
327 |
* @param squery the squery |
|
328 |
* @return the string |
|
329 |
*/ |
|
330 |
public static String addBackSlash(String squery) { |
|
331 |
if ("\"".equals(squery)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
332 |
StringBuffer buff = new StringBuffer(); |
|
333 |
//for(char c : chars.) |
|
334 |
for(int i = 0 ; i < squery.length() ; i++) { |
|
335 |
int j = chars.indexOf(squery.charAt(i)); |
|
336 |
//System.out.println(""+i+" : "+squery.charAt(i)+ " >> "+j); |
|
337 |
|
|
338 |
if ( j >= 0 ) { |
|
339 |
buff.append("\\"+squery.charAt(i)); //$NON-NLS-1$ |
|
340 |
} |
|
341 |
else { |
|
342 |
buff.append(squery.charAt(i)); |
|
343 |
} |
|
344 |
} |
|
345 |
return buff.toString(); |
|
346 |
} |
|
347 |
|
|
348 |
|
|
349 |
/** |
|
350 |
* Sets the string of the query. |
|
351 |
* @param queryString |
|
352 |
*/ |
|
353 |
public void setQueryString(String queryString) { |
|
354 |
this.queryString = queryString; |
|
355 |
} |
|
356 |
|
|
357 |
/** |
|
358 |
* Checks whatever the query is empty (null, empty or contains only double quotes) or not. |
|
359 |
* @return true if empty otherwise false |
|
360 |
*/ |
|
361 |
public boolean isEmpty() { |
|
362 |
return queryString == null || queryString.length() == 0 || "\"\"".equals(queryString); |
|
363 |
} |
|
364 |
|
|
365 |
|
|
366 |
@Override |
|
367 |
public boolean equals(Object obj) { |
|
368 |
if (!(obj instanceof Query)) { |
|
369 |
return false; |
|
370 |
} |
|
371 |
return this.queryString.equals(((Query) obj).queryString); |
|
372 |
} |
|
373 |
|
|
374 |
|
|
375 |
|
|
376 |
/** |
|
377 |
* The main method. |
|
378 |
* |
|
379 |
* @param args the arguments |
|
380 |
*/ |
|
381 |
public static void main(String[] args) { |
|
382 |
String test = "^$sdf<>sdf|\\sdf\"{(sdf)}?+sdf*."; //$NON-NLS-1$ |
|
383 |
System.out.println(Query.addBackSlash(test)); |
|
384 |
} |
|
385 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java (revision 1061) | ||
---|---|---|
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: 2015-05-13 09:46:56 +0200 (Wed, 13 May 2015) $ |
|
25 |
// $LastChangedRevision: 2967 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.searchengine.cqp.corpus.query; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
import java.util.regex.Matcher; |
|
33 |
import java.util.regex.Pattern; |
|
34 |
|
|
35 |
import org.txm.core.preferences.TXMPreferences; |
|
36 |
import org.txm.searchengine.core.Query; |
|
37 |
|
|
38 |
/** |
|
39 |
* Implements a CQL query. Use fixQuery to use query sugar. |
|
40 |
* |
|
41 |
* @author sloiseau |
|
42 |
* @author jpmague |
|
43 |
* @author sheiden |
|
44 |
* @author sjacquot |
|
45 |
*/ |
|
46 |
|
|
47 |
public class CQLQuery implements Query { |
|
48 |
|
|
49 |
/** The Constant NoStrategy. */ |
|
50 |
private static final Integer NoStrategy = 0; |
|
51 |
|
|
52 |
/** The Constant JPMStrategy. */ |
|
53 |
private static final Integer JPMStrategy = 1; |
|
54 |
|
|
55 |
/** The Constant WLXStrategy. */ |
|
56 |
private static final Integer WLXStrategy = 2; |
|
57 |
|
|
58 |
/** The Constant ElectricStrategy. */ |
|
59 |
private static final Integer ElectricStrategy = 3; |
|
60 |
|
|
61 |
|
|
62 |
/** espace char |"{()}+*. */ |
|
63 |
private static String chars = "^$<>|\\\"{([])}?+*."; //$NON-NLS-1$ |
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* The query string. |
|
68 |
*/ |
|
69 |
protected String queryString; |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
/** |
|
74 |
* Instantiates a new query. |
|
75 |
*/ |
|
76 |
protected CQLQuery() { |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Instantiates a new query. |
|
81 |
* |
|
82 |
* @param queryString |
|
83 |
* the query string |
|
84 |
* |
|
85 |
* public Query(String queryString){ |
|
86 |
* this.queryString=queryString.trim(); } |
|
87 |
*/ |
|
88 |
public CQLQuery(String queryString) { |
|
89 |
if (queryString != null) { |
|
90 |
this.queryString = queryString.trim(); |
|
91 |
} |
|
92 |
else { |
|
93 |
this.queryString = ""; |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Converts the specified string to a list of Query. |
|
99 |
* Input string must contains queries separated by a tabulation. |
|
100 |
* @param str |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
public static List<CQLQuery> stringToQueries(String str) { |
|
104 |
ArrayList<CQLQuery> queries = new ArrayList<CQLQuery>(); |
|
105 |
if (str == null || str.length() == 0) { |
|
106 |
return queries; |
|
107 |
} |
|
108 |
String[] split = str.split(TXMPreferences.LIST_SEPARATOR); |
|
109 |
for (String s : split) { |
|
110 |
queries.add(new CQLQuery(s)); |
|
111 |
} |
|
112 |
return queries; |
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
/** |
|
117 |
* Converts the specified list of Query to a string. |
|
118 |
* Queries strings are separated by a tabulation. |
|
119 |
* @param queries |
|
120 |
* @return |
|
121 |
*/ |
|
122 |
public static String queriesToString(List<CQLQuery> queries) { |
|
123 |
String str = ""; |
|
124 |
for (int i = 0; i < queries.size(); i++) { |
|
125 |
if(i > 0) { |
|
126 |
str += TXMPreferences.LIST_SEPARATOR; |
|
127 |
} |
|
128 |
str += queries.get(i).getQueryString(); |
|
129 |
} |
|
130 |
return str; |
|
131 |
} |
|
132 |
|
|
133 |
|
|
134 |
/** |
|
135 |
* Gets the query string. |
|
136 |
* |
|
137 |
* @return the query string |
|
138 |
*/ |
|
139 |
public String getQueryString() { |
|
140 |
return queryString; |
|
141 |
} |
|
142 |
|
|
143 |
/* (non-Javadoc) |
|
144 |
* @see java.lang.Object#toString() |
|
145 |
*/ |
|
146 |
@Override |
|
147 |
public String toString() { |
|
148 |
return queryString; |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* Normalize white chars. |
|
153 |
* |
|
154 |
* SLH algorithm : |
|
155 |
* - first normalize white chars : We don't know from where the query |
|
156 |
* comes from and how it was produced (pasted from a text editor after |
|
157 |
* having been double-clicked and copied, typed in the query input |
|
158 |
* field, etc.) The CQP syntax analyzer is sensible to white chars, so |
|
159 |
* we have to normalize what the user may have leaved inadvertently |
|
160 |
* because she may not see well the true query string (white chars are |
|
161 |
* invisible), and it is dif ficult to accept and manage a syntax error |
|
162 |
* when you can't "see" the source of the problem. That strategy decides |
|
163 |
* to interpret every white chars contiguous sequence as one space |
|
164 |
* character. |
|
165 |
* |
|
166 |
* Please note that this may be compatible (or not) with other Search |
|
167 |
* Engines query scanners. |
|
168 |
* |
|
169 |
* Please note also that this may be compatible (or not) with the |
|
170 |
* tokenization policy of a given corpus dealing with compound words. |
|
171 |
* That strategy is compatible with a policy which separates words in |
|
172 |
* compound words by one space character. |
|
173 |
* |
|
174 |
* - then remove outer white chars : What is not seen should not be |
|
175 |
* there if no explicit expression deals with it from the user's point |
|
176 |
* of view. So white chars at the beginning or at the end of the query |
|
177 |
* are removed. Those characters often come from rapid copy/paste or |
|
178 |
* double-click/copy/paste (in a word processing software, the |
|
179 |
* double-click strategy can for example select the white chars on the |
|
180 |
* right of the selected strings to help the user move words around with |
|
181 |
* their delimiters). |
|
182 |
* |
|
183 |
* That strategy may seem aggressive, but experience shows that this |
|
184 |
* little service helps silently users a lot and is rarely |
|
185 |
* inappropriate. |
|
186 |
* |
|
187 |
* In case of doubt, the user should be able to switch to another |
|
188 |
* strategy. |
|
189 |
* |
|
190 |
* @param str the str |
|
191 |
* @return the string with white chars normalized |
|
192 |
*/ |
|
193 |
public static String normalizeWhiteChars(String str) { |
|
194 |
|
|
195 |
// normalize everything white to space |
|
196 |
String str1 = str.replaceAll("\\s+", " "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
197 |
// remove border whites |
|
198 |
str1 = str1.replaceFirst("^ ", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
199 |
str1 = str1.replaceFirst(" $", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
200 |
return str1; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* Transforms a simplified query string into a proper CQP query string |
|
205 |
* |
|
206 |
* Follows several different strategies to do that : |
|
207 |
* |
|
208 |
* JPM Strategy : if the input query matches \w quote are added if the input |
|
209 |
* query matches \w*="\w*", square brackets are added if the input query |
|
210 |
* matches .\w=.\w (i.e. without quotes), quotes and square brackets are |
|
211 |
* added (i.e. -> [$1="$2"]) otherwise, the query is left as if |
|
212 |
* |
|
213 |
* Weblex Strategy : normalize white chars add double quotes if no double |
|
214 |
* quotes and no brackets |
|
215 |
* |
|
216 |
* Electric Strategy : normalize white chars add double quote, equal, |
|
217 |
* brackets, etc. depending on the presence/absence of those chars in the |
|
218 |
* original query |
|
219 |
* |
|
220 |
* No Strategy : do nothing |
|
221 |
* |
|
222 |
* @param query |
|
223 |
* The query string to fix |
|
224 |
* @return the fixed query string |
|
225 |
*/ |
|
226 |
static public String fixQuery(String query) { |
|
227 |
|
|
228 |
//if (query.startsWith("intersect ")) return query; |
|
229 |
|
|
230 |
if ("\"".equals(query)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
231 |
|
|
232 |
Integer QueryFixStrategy = WLXStrategy; |
|
233 |
|
|
234 |
if (QueryFixStrategy == JPMStrategy) { |
|
235 |
|
|
236 |
// query = abc -> put double quotes |
|
237 |
Pattern simple = Pattern.compile("\\p{L}*"); //$NON-NLS-1$ |
|
238 |
if (simple.matcher(query).matches()) { |
|
239 |
// System.out.println("match 1"); |
|
240 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
241 |
} |
|
242 |
|
|
243 |
// query = prop="abc" -> put square brackets |
|
244 |
Pattern equalsWithQuotes = Pattern.compile("\\p{L}+=\"\\p{L}*\""); //$NON-NLS-1$ |
|
245 |
if (equalsWithQuotes.matcher(query).matches()) { |
|
246 |
// System.out.println("match 2"); |
|
247 |
return '[' + query + ']'; |
|
248 |
} |
|
249 |
|
|
250 |
// query = abc=def -> put brackets + equal sign + double quotes |
|
251 |
Pattern equalsWithoutQuotes = Pattern |
|
252 |
.compile("(\\p{L}*)=(\\p{L}*)"); //$NON-NLS-1$ |
|
253 |
Matcher matcher = equalsWithoutQuotes.matcher(query); |
|
254 |
if (matcher.matches()) { |
|
255 |
// System.out.println("match 2"); |
|
256 |
return '[' + matcher.group(1) + '=' + '"' + matcher.group(2) |
|
257 |
+ '"' + ']'; |
|
258 |
} |
|
259 |
|
|
260 |
// query doesn't start with ", ' and [ -> put double quotes |
|
261 |
if (!query.startsWith("\"") && !query.startsWith("\'") && !query.startsWith("[")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
262 |
{ |
|
263 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
264 |
} |
|
265 |
|
|
266 |
// do nothing |
|
267 |
return query; |
|
268 |
|
|
269 |
} else if (QueryFixStrategy == WLXStrategy) { |
|
270 |
|
|
271 |
query = normalizeWhiteChars(query); |
|
272 |
|
|
273 |
// empty query |
|
274 |
if(query.isEmpty()) { |
|
275 |
return query; |
|
276 |
} |
|
277 |
// query contains double quotes |
|
278 |
else if (query.contains("\"")) { //$NON-NLS-1$ |
|
279 |
return query; |
|
280 |
} |
|
281 |
// query contains brackets |
|
282 |
else if (query.contains("[") && query.contains("]")) { //$NON-NLS-1$ //$NON-NLS-2$ |
|
283 |
return query; // probably [] or [...] |
|
284 |
} |
|
285 |
else { |
|
286 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
287 |
} |
|
288 |
} else if (QueryFixStrategy == ElectricStrategy) { |
|
289 |
|
|
290 |
// DON'T USE THAT STRATEGY : CODE NEEDS TO BE FIXED |
|
291 |
query = normalizeWhiteChars(query); |
|
292 |
|
|
293 |
if (query.contains("\"")) { //$NON-NLS-1$ |
|
294 |
if (query.contains("=")) { //$NON-NLS-1$ |
|
295 |
if (query.contains("[")) { //$NON-NLS-1$ |
|
296 |
return query; |
|
297 |
} else { |
|
298 |
return '[' + query + ']'; |
|
299 |
} |
|
300 |
} else { |
|
301 |
return query; |
|
302 |
} |
|
303 |
} else { |
|
304 |
if (query.contains("=")) { //$NON-NLS-1$ |
|
305 |
return query.replaceAll("=([^= \"]+)", "=\"$1\""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
306 |
} else { |
|
307 |
return '"' + query + '"'; //$NON-NLS-1$ |
|
308 |
} |
|
309 |
} |
|
310 |
} else if (QueryFixStrategy == NoStrategy) { |
|
311 |
|
|
312 |
// no strategy to apply : do nothing |
|
313 |
return query; |
|
314 |
|
|
315 |
} else { |
|
316 |
|
|
317 |
// we shouldn't be there |
|
318 |
// let silently return the query for the moment |
|
319 |
return query; |
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
/** |
|
326 |
* Adds the back slash. |
|
327 |
* |
|
328 |
* @param squery the squery |
|
329 |
* @return the string |
|
330 |
*/ |
|
331 |
public static String addBackSlash(String squery) { |
|
332 |
if ("\"".equals(squery)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
333 |
StringBuffer buff = new StringBuffer(); |
|
334 |
//for(char c : chars.) |
|
335 |
for(int i = 0 ; i < squery.length() ; i++) { |
|
336 |
int j = chars.indexOf(squery.charAt(i)); |
|
337 |
//System.out.println(""+i+" : "+squery.charAt(i)+ " >> "+j); |
|
338 |
|
|
339 |
if ( j >= 0 ) { |
|
340 |
buff.append("\\"+squery.charAt(i)); //$NON-NLS-1$ |
|
341 |
} |
|
342 |
else { |
|
343 |
buff.append(squery.charAt(i)); |
|
344 |
} |
|
345 |
} |
|
346 |
return buff.toString(); |
|
347 |
} |
|
348 |
|
|
349 |
|
|
350 |
/** |
|
351 |
* Sets the string of the query. |
|
352 |
* @param queryString |
|
353 |
*/ |
|
354 |
public void setQueryString(String queryString) { |
|
355 |
this.queryString = queryString; |
|
356 |
} |
|
357 |
|
|
358 |
/** |
|
359 |
* Checks whatever the query is empty (null, empty or contains only double quotes) or not. |
|
360 |
* @return true if empty otherwise false |
|
361 |
*/ |
|
362 |
public boolean isEmpty() { |
|
363 |
return queryString == null || queryString.length() == 0 || "\"\"".equals(queryString); |
|
364 |
} |
|
365 |
|
|
366 |
|
|
367 |
@Override |
|
368 |
public boolean equals(Object obj) { |
|
369 |
if (!(obj instanceof CQLQuery)) { |
|
370 |
return false; |
|
371 |
} |
|
372 |
return this.queryString.equals(((CQLQuery) obj).queryString); |
|
373 |
} |
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
/** |
|
378 |
* The main method. |
|
379 |
* |
|
380 |
* @param args the arguments |
|
381 |
*/ |
|
382 |
public static void main(String[] args) { |
|
383 |
String test = "^$sdf<>sdf|\\sdf\"{(sdf)}?+sdf*."; //$NON-NLS-1$ |
|
384 |
System.out.println(CQLQuery.addBackSlash(test)); |
|
385 |
} |
|
386 |
} |
|
0 | 387 |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryFocus.java (revision 1061) | ||
---|---|---|
31 | 31 |
/** |
32 | 32 |
* The Class QueryFocus. |
33 | 33 |
*/ |
34 |
public class QueryFocus extends Query { |
|
34 |
public class QueryFocus extends CQLQuery {
|
|
35 | 35 |
|
36 | 36 |
/** The focus. */ |
37 | 37 |
private final Focus focus; |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryPart.java (revision 1061) | ||
---|---|---|
39 | 39 |
* @author Jean Philippe Magué |
40 | 40 |
* @author sloiseau |
41 | 41 |
*/ |
42 |
public class QueryPart extends Query { |
|
42 |
public class QueryPart extends CQLQuery {
|
|
43 | 43 |
|
44 | 44 |
/** The structure. */ |
45 | 45 |
private StructuralUnit structure; |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java (revision 1061) | ||
---|---|---|
43 | 43 |
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException; |
44 | 44 |
import org.txm.searchengine.cqp.core.functions.selection.SelectionResult; |
45 | 45 |
import org.txm.searchengine.cqp.corpus.query.Match; |
46 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
46 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
47 | 47 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
48 | 48 |
import org.txm.utils.logger.Log; |
49 | 49 |
import org.w3c.dom.Document; |
... | ... | |
64 | 64 |
protected Subcorpus motherSubcorpus; |
65 | 65 |
|
66 | 66 |
/** The query. */ |
67 |
protected Query query; |
|
67 |
protected CQLQuery query;
|
|
68 | 68 |
|
69 | 69 |
private SelectionResult selectionResult; |
70 | 70 |
protected QueryResult qresult; |
... | ... | |
77 | 77 |
* @param query |
78 | 78 |
* @throws InvalidCqpIdException |
79 | 79 |
*/ |
80 |
protected Subcorpus(String cqpId, String name, Corpus parent, Query query) throws InvalidCqpIdException { |
|
80 |
protected Subcorpus(String cqpId, String name, Corpus parent, CQLQuery query) throws InvalidCqpIdException {
|
|
81 | 81 |
this(cqpId, name, parent, query, true); |
82 | 82 |
} |
83 | 83 |
|
... | ... | |
91 | 91 |
* @param parent the parent |
92 | 92 |
* @param query the query |
93 | 93 |
* @throws InvalidCqpIdException the invalid cqp id exception |
94 |
* {@link Corpus#createSubcorpus(Query, String)} |
|
94 |
* {@link Corpus#createSubcorpus(CQLQuery, String)}
|
|
95 | 95 |
*/ |
96 |
protected Subcorpus(String cqpId, String name, Corpus parent, Query query, boolean addToParent) throws InvalidCqpIdException { |
|
96 |
protected Subcorpus(String cqpId, String name, Corpus parent, CQLQuery query, boolean addToParent) throws InvalidCqpIdException {
|
|
97 | 97 |
super(cqpId); |
98 | 98 |
|
99 | 99 |
// FIXME: to validate |
... | ... | |
274 | 274 |
@Override |
275 | 275 |
protected boolean _load() { |
276 | 276 |
if (getSelfElement() != null) { |
277 |
this.query = new Query(getSelfElement().getAttribute("query")); //$NON-NLS-1$ |
|
277 |
this.query = new CQLQuery(getSelfElement().getAttribute("query")); //$NON-NLS-1$
|
|
278 | 278 |
|
279 | 279 |
NodeList subcorpusElems = getSelfElement().getElementsByTagName("subcorpus"); //$NON-NLS-1$ |
280 | 280 |
for (int i = 0 ; i < subcorpusElems.getLength() ; i++) { |
... | ... | |
338 | 338 |
* @param subcorpusName the subcorpus name |
339 | 339 |
* @param query the query |
340 | 340 |
*/ |
341 |
private void registerToParent(String subcorpusName, Query query) { |
|
341 |
private void registerToParent(String subcorpusName, CQLQuery query) {
|
|
342 | 342 |
if (this.getSelfElement() == null && this.getParent() != null) |
343 | 343 |
try { |
344 | 344 |
Element parentElem = (Element) this.getParent().getSelfElement(); |
... | ... | |
377 | 377 |
* |
378 | 378 |
* @return the query |
379 | 379 |
*/ |
380 |
public Query getQuery() { |
|
380 |
public CQLQuery getQuery() {
|
|
381 | 381 |
return query; |
382 | 382 |
} |
383 | 383 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/FakeQueryResult.java (revision 1061) | ||
---|---|---|
35 | 35 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
36 | 36 |
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException; |
37 | 37 |
import org.txm.searchengine.cqp.corpus.query.Match; |
38 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
38 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
39 | 39 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
40 | 40 |
|
41 | 41 |
// TODO: Auto-generated Javadoc |
... | ... | |
53 | 53 |
/** |
54 | 54 |
* Instantiates a new query result. |
55 | 55 |
* |
56 |
* Not intended to be used directly. See {@link Corpus#query(Query, String)} |
|
56 |
* Not intended to be used directly. See {@link Corpus#query(CQLQuery, String)}
|
|
57 | 57 |
* |
58 | 58 |
* @param cqpId |
59 | 59 |
* the cqp id |
... | ... | |
68 | 68 |
* the invalid cqp id exception |
69 | 69 |
*/ |
70 | 70 |
public FakeQueryResult(String name, Corpus queriedCorpus, |
71 |
Query query, int[] starts, int[] ends, int[] targets) throws InvalidCqpIdException { |
|
71 |
CQLQuery query, int[] starts, int[] ends, int[] targets) throws InvalidCqpIdException {
|
|
72 | 72 |
super("Fakeqr", name, queriedCorpus, query); |
73 | 73 |
this.starts = starts; |
74 | 74 |
this.ends = ends; |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java (revision 1061) | ||
---|---|---|
38 | 38 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
39 | 39 |
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException; |
40 | 40 |
import org.txm.searchengine.cqp.corpus.query.Match; |
41 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
41 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
42 | 42 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
43 | 43 |
|
44 | 44 |
/** |
... | ... | |
64 | 64 |
protected Corpus queriedCorpus; |
65 | 65 |
|
66 | 66 |
/** The query. */ |
67 |
protected Query query; |
|
67 |
protected CQLQuery query;
|
|
68 | 68 |
|
69 | 69 |
/** The size. */ |
70 | 70 |
protected int size = -1; |
... | ... | |
72 | 72 |
/** |
73 | 73 |
* Instantiates a new query result. |
74 | 74 |
* |
75 |
* Not intended to be used directly. See {@link Corpus#query(Query, String)} |
|
75 |
* Not intended to be used directly. See {@link Corpus#query(CQLQuery, String)}
|
|
76 | 76 |
* |
77 | 77 |
* @param cqpId |
78 | 78 |
* the cqp id |
... | ... | |
87 | 87 |
* the invalid cqp id exception |
88 | 88 |
*/ |
89 | 89 |
public QueryResult(String cqpId, String name, Corpus queriedCorpus, |
90 |
Query query) throws InvalidCqpIdException { |
|
90 |
CQLQuery query) throws InvalidCqpIdException {
|
|
91 | 91 |
// super(cqpId); |
92 | 92 |
checkCqpId(cqpId); |
93 | 93 |
this.cqpId = cqpId; |
... | ... | |
326 | 326 |
* |
327 | 327 |
* @return the query |
328 | 328 |
*/ |
329 |
public Query getQuery() { |
|
329 |
public CQLQuery getQuery() {
|
|
330 | 330 |
return query; |
331 | 331 |
} |
332 | 332 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java (revision 1061) | ||
---|---|---|
31 | 31 |
import org.txm.objects.Project; |
32 | 32 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
33 | 33 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
34 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
34 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
35 | 35 |
import org.w3c.dom.Element; |
36 | 36 |
|
37 | 37 |
/** |
... | ... | |
60 | 60 |
* @param query the query |
61 | 61 |
* @throws InvalidCqpIdException the invalid cqp id exception |
62 | 62 |
*/ |
63 |
protected Part(String cqpId, String partitionName, String shortName, Partition partition, Query query) throws InvalidCqpIdException { |
|
63 |
protected Part(String cqpId, String partitionName, String shortName, Partition partition, CQLQuery query) throws InvalidCqpIdException {
|
|
64 | 64 |
super(cqpId, partitionName + "_" + shortName, partition.getParent(), query, false); //$NON-NLS-1$ |
65 | 65 |
this.shortName = shortName; |
66 | 66 |
this.name = shortName; |
... | ... | |
164 | 164 |
* @param pquery the new query |
165 | 165 |
*/ |
166 | 166 |
public void setQuery(String pquery) { |
167 |
this.query = new Query(pquery); |
|
167 |
this.query = new CQLQuery(pquery);
|
|
168 | 168 |
} |
169 | 169 |
|
170 | 170 |
/* (non-Javadoc) |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1061) | ||
---|---|---|
53 | 53 |
import org.txm.searchengine.cqp.CQPPreferences; |
54 | 54 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
55 | 55 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
56 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
56 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
57 | 57 |
import org.txm.searchengine.cqp.corpus.query.QueryPart; |
58 | 58 |
import org.txm.utils.io.IOUtils; |
59 | 59 |
import org.txm.utils.logger.Log; |
... | ... | |
274 | 274 |
for (String value : pValues) { |
275 | 275 |
String partName = value.replace("\\",""); //$NON-NLS-1$ //$NON-NLS-2$ |
276 | 276 |
pPartNames.add(partName); |
277 |
Query query = new QueryPart(pProperty.getStructuralUnit(), pProperty, Query.addBackSlash(value));
|
|
277 |
CQLQuery query = new QueryPart(pProperty.getStructuralUnit(), pProperty, CQLQuery.addBackSlash(value));
|
|
278 | 278 |
pQueries.add(query.getQueryString()); |
279 | 279 |
} |
280 | 280 |
|
... | ... | |
378 | 378 |
long start = System.currentTimeMillis(); |
379 | 379 |
try { |
380 | 380 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
381 |
part = new Part(partCqpId, partitionName, partName, this, new Query(query)); |
|
381 |
part = new Part(partCqpId, partitionName, partName, this, new CQLQuery(query));
|
|
382 | 382 |
|
383 | 383 |
// FIXME: persistence tests: define the UUID as the concatenation of all part CQP id |
384 | 384 |
// this.uniqueID += partCqpId; |
... | ... | |
574 | 574 |
* @throws CqiClientException |
575 | 575 |
* the cqi client exception |
576 | 576 |
*/ |
577 |
public List<QueryResult> query(Query query, String name) throws CqiClientException { |
|
577 |
public List<QueryResult> query(CQLQuery query, String name) throws CqiClientException {
|
|
578 | 578 |
Log.finest(TXMCoreMessages.QUERYING_PARTITION + this.name); |
579 | 579 |
List<Part> parts = getParts(); |
580 | 580 |
List<QueryResult> results = new ArrayList<QueryResult>(parts.size()); |
... | ... | |
797 | 797 |
private static List<String> getSafeValues(StructuralUnitProperty property, Corpus corpus) throws CqiClientException { |
798 | 798 |
List<String> values = property.getValues(corpus); |
799 | 799 |
for(int i = 0 ; i < values.size() ; i++) |
800 |
values.set(i, Query.addBackSlash(values.get(i))); |
|
800 |
values.set(i, CQLQuery.addBackSlash(values.get(i)));
|
|
801 | 801 |
return values; |
802 | 802 |
} |
803 | 803 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java (revision 1061) | ||
---|---|---|
46 | 46 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
47 | 47 |
import org.txm.searchengine.cqp.core.functions.selection.SelectionResult; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.query.Match; |
49 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
49 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
50 | 50 |
import org.txm.searchengine.cqp.corpus.query.QueryPart; |
51 | 51 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
52 | 52 |
import org.txm.utils.logger.Log; |
... | ... | |
152 | 152 |
* @throws CqiClientException the cqi client exception |
153 | 153 |
*/ |
154 | 154 |
public Subcorpus createSubcorpus(Element elem) throws CqiClientException { |
155 |
Query query = new Query(elem.getAttribute("query")); //$NON-NLS-1$
|
|
155 |
CQLQuery query = new CQLQuery(elem.getAttribute("query")); //$NON-NLS-1$
|
|
156 | 156 |
String subcorpusName = elem.getAttribute("name"); //$NON-NLS-1$ |
157 | 157 |
|
158 | 158 |
Subcorpus subcorpus; |
... | ... | |
184 | 184 |
* @throws CqiClientException |
185 | 185 |
* the cqi client exception |
186 | 186 |
*/ |
187 |
public Subcorpus createSubcorpus(Query query, String subcorpusName) |
|
187 |
public Subcorpus createSubcorpus(CQLQuery query, String subcorpusName)
|
|
188 | 188 |
throws CqiClientException { |
189 | 189 |
Subcorpus sc = createSubcorpus(query, subcorpusName, false); |
190 | 190 |
return sc; |
... | ... | |
199 | 199 |
* @return the subcorpus |
200 | 200 |
* @throws CqiClientException the cqi client exception |
201 | 201 |
*/ |
202 |
public Subcorpus createSubcorpus(Query query, String subcorpusName, |
|
202 |
public Subcorpus createSubcorpus(CQLQuery query, String subcorpusName,
|
|
203 | 203 |
boolean registered) throws CqiClientException { |
204 | 204 |
Subcorpus subcorpus; |
205 | 205 |
String subcorpusCqpId = subcorpusNamePrefix + getNextSubcorpusCounter().toString(); |
... | ... | |
266 | 266 |
} |
267 | 267 |
String value = ""; //$NON-NLS-1$ |
268 | 268 |
for (String v : values) |
269 |
value += Query.addBackSlash(v) + "|"; //$NON-NLS-1$ |
|
269 |
value += CQLQuery.addBackSlash(v) + "|"; //$NON-NLS-1$
|
|
270 | 270 |
value = value.substring(0, value.length() - 1); |
271 | 271 |
|
272 |
Query query = new QueryPart(structuralUnit, structuralUnitProperty, value); |
|
272 |
CQLQuery query = new QueryPart(structuralUnit, structuralUnitProperty, value);
|
|
273 | 273 |
return createSubcorpus(query, subcorpusName); |
274 | 274 |
//return createSubcorpus(structuralUnit, structuralUnitProperty, value, subcorpusName); |
275 | 275 |
} |
... | ... | |
289 | 289 |
public Subcorpus createSubcorpus(StructuralUnit structuralUnit, |
290 | 290 |
StructuralUnitProperty structuralUnitProperty, String value, |
291 | 291 |
String subcorpusName) throws CqiClientException { |
292 |
Query query = new QueryPart(structuralUnit, structuralUnitProperty, |
|
293 |
Query.addBackSlash(value)); |
|
292 |
CQLQuery query = new QueryPart(structuralUnit, structuralUnitProperty,
|
|
293 |
CQLQuery.addBackSlash(value));
|
|
294 | 294 |
// System.out.println("forged query : "+query.getQueryString()); |
295 | 295 |
return createSubcorpus(query, subcorpusName); |
296 | 296 |
} |
... | ... | |
310 | 310 |
public Subcorpus createSubcorpusWithQueryString(StructuralUnit structuralUnit, |
311 | 311 |
StructuralUnitProperty structuralUnitProperty, String value, |
312 | 312 |
String subcorpusName) throws CqiClientException { |
313 |
Query query = new QueryPart(structuralUnit, structuralUnitProperty, |
|
313 |
CQLQuery query = new QueryPart(structuralUnit, structuralUnitProperty,
|
|
314 | 314 |
value); |
315 | 315 |
// System.out.println("forged query : "+query.getQueryString()); |
316 | 316 |
return createSubcorpus(query, subcorpusName); |
... | ... | |
842 | 842 |
* @throws CqiClientException |
843 | 843 |
* the cqi client exception |
844 | 844 |
*/ |
845 |
public QueryResult query(Query query, String queryResultName, boolean save) |
|
845 |
public QueryResult query(CQLQuery query, String queryResultName, boolean save)
|
|
846 | 846 |
throws CqiClientException { |
847 |
|
|
847 | 848 |
QueryResult queryResult = null; |
848 | 849 |
//String queryResultId = queryResultNamePrefix + UUID.randomUUID().toString(); |
849 | 850 |
String queryResultId = queryResultNamePrefix + getNextQueryCounter(); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java (revision 1061) | ||
---|---|---|
36 | 36 |
import org.txm.core.preferences.TXMPreferences; |
37 | 37 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
38 | 38 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
39 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
39 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
40 | 40 |
import org.txm.utils.logger.Log; |
41 | 41 |
|
42 | 42 |
/** |
... | ... | |
193 | 193 |
*/ |
194 | 194 |
public Integer getNumberOfValues(Corpus corpus) { |
195 | 195 |
try { |
196 |
QueryResult tmp = corpus.query(new Query("<" + this.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$ |
|
196 |
QueryResult tmp = corpus.query(new CQLQuery("<" + this.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
197 | 197 |
int ret = tmp.getNMatch(); |
198 | 198 |
tmp.drop(); |
199 | 199 |
return ret; |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 1061) | ||
---|---|---|
48 | 48 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
49 | 49 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
50 | 50 |
import org.txm.searchengine.cqp.corpus.query.Match; |
51 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
51 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
52 | 52 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
53 | 53 |
import org.txm.utils.DeleteDir; |
54 | 54 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1061) | ||
---|---|---|
47 | 47 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
48 | 48 |
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException; |
49 | 49 |
import org.txm.searchengine.cqp.corpus.query.Match; |
50 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
50 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
51 | 51 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
52 | 52 |
import org.txm.utils.DeleteDir; |
53 | 53 |
|
... | ... | |
505 | 505 |
+ UUID.randomUUID().toString(); |
506 | 506 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery( |
507 | 507 |
this.getQualifiedCqpId(), queryResultId, "<text>[] expand to text"); //$NON-NLS-1$ |
508 |
QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this, new Query("<text>[] expand to text")); //$NON-NLS-1$ |
|
508 |
QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this, new CQLQuery("<text>[] expand to text")); //$NON-NLS-1$
|
|
509 | 509 |
textEndLimits = queryResult.getEnds(); |
510 | 510 |
} |
511 | 511 |
return textEndLimits; |
... | ... | |
530 | 530 |
String queryResultId = queryResultNamePrefix + UUID.randomUUID().toString(); |
531 | 531 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery( |
532 | 532 |
this.getQualifiedCqpId(), queryResultId, cql_limit); //$NON-NLS-1$ |
533 |
QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this, new Query(cql_limit)); |
|
533 |
QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this, new CQLQuery(cql_limit));
|
|
534 | 534 |
|
535 | 535 |
int[] rez = queryResult.getStarts(); |
536 | 536 |
queryResult.drop(); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java (revision 1061) | ||
---|---|---|
46 | 46 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
47 | 47 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.query.Match; |
49 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
49 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
50 | 50 |
import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus; |
51 | 51 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
52 | 52 |
import org.txm.utils.logger.Log; |
... | ... | |
97 | 97 |
|
98 | 98 |
if (!isWordProperty) { |
99 | 99 |
StructuralUnitProperty sprop = (StructuralUnitProperty) prop; |
100 |
QueryResult qresult = prop.getCorpus().query(new Query("<"+sprop.getFullName()+">[] expand to "+sprop.getName()), "TMP", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
100 |
QueryResult qresult = prop.getCorpus().query(new CQLQuery("<"+sprop.getFullName()+">[] expand to "+sprop.getName()), "TMP", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
101 | 101 |
int[] strucs = this.cpos2Struc(qname, qresult.getStarts()); |
102 | 102 |
return Arrays.asList(cqiClient.struc2Str(qname, strucs)); |
103 | 103 |
} else { |
... | ... | |
185 | 185 |
* @throws CqiClientException the cqi client exception |
186 | 186 |
*/ |
187 | 187 |
public List<String> getData(StructuralUnitProperty property, Corpus corpus) throws CqiClientException { |
188 |
QueryResult tmp = corpus.query(new Query("<" + property.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$ |
|
188 |
QueryResult tmp = corpus.query(new CQLQuery("<" + property.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
189 | 189 |
List<Match> matches = tmp.getMatches(); |
190 | 190 |
tmp.drop(); |
191 | 191 |
ArrayList<String> ret = new ArrayList<String>(new HashSet<String>(Match |
... | ... | |
204 | 204 |
|
205 | 205 |
QueryResult tmp = prop.getCorpus() |
206 | 206 |
.query( |
207 |
new Query("<" + prop.getFullName() + ">[] expand to "+prop.getName()), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$ |
|
207 |
new CQLQuery("<" + prop.getFullName() + ">[] expand to "+prop.getName()), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
|
|
208 | 208 |
if (number > tmp.getNMatch()) number = tmp.getNMatch(); |
209 | 209 |
List<Match> matches = tmp.getMatches(0, number); |
210 | 210 |
tmp.drop(); |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/functions/Referencer.java (revision 1061) | ||
---|---|---|
69 | 69 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
70 | 70 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
71 | 71 |
import org.txm.searchengine.cqp.corpus.query.Match; |
72 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
72 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
73 | 73 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
74 | 74 |
import org.txm.statsengine.r.core.RWorkspace; |
75 | 75 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
... | ... | |
136 | 136 |
|
137 | 137 |
/** The query. */ |
138 | 138 |
@Parameter(key=ReferencerPreferences.QUERY) |
139 |
protected Query pQuery; |
|
139 |
protected CQLQuery pQuery;
|
|
140 | 140 |
|
141 | 141 |
|
142 | 142 |
|
... | ... | |
385 | 385 |
* |
386 | 386 |
* @return the query |
387 | 387 |
*/ |
388 |
public Query getQuery() { |
|
388 |
public CQLQuery getQuery() {
|
|
389 | 389 |
return pQuery; |
390 | 390 |
} |
391 | 391 |
|
... | ... | |
480 | 480 |
return true; |
481 | 481 |
} |
482 | 482 |
|
483 |
public void setParameters(Query query, Property prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) { |
|
483 |
public void setParameters(CQLQuery query, Property prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) {
|
|
484 | 484 |
if (query != null) this.pQuery = query; |
485 | 485 |
if (pattern != null) this.pPattern = pattern; |
486 | 486 |
if (prop != null) this.pProperty = prop; |
... | ... | |
578 | 578 |
@Override |
579 | 579 |
public boolean loadParameters() throws CqiClientException { |
580 | 580 |
if(!this.getStringParameterValue(ReferencerPreferences.QUERY).isEmpty()) { |
581 |
this.pQuery = new Query(this.getStringParameterValue(ReferencerPreferences.QUERY)); |
|
581 |
this.pQuery = new CQLQuery(this.getStringParameterValue(ReferencerPreferences.QUERY));
|
|
582 | 582 |
} |
583 | 583 |
this.pPattern = StructuralUnitProperty.stringToProperties(this.getCorpus(), this.getStringParameterValue(ReferencerPreferences.PATTERN)); |
584 | 584 |
this.pProperty = this.getCorpus().getProperty(this.getStringParameterValue(ReferencerPreferences.UNIT_PROPERTY)); |
... | ... | |
735 | 735 |
} |
736 | 736 |
} |
737 | 737 |
|
738 |
public void setQuery(Query query) { |
|
738 |
public void setQuery(CQLQuery query) {
|
|
739 | 739 |
this.pQuery = query; |
740 | 740 |
} |
741 | 741 |
|
... | ... | |
767 | 767 |
|
768 | 768 |
for (Line line : lines) { |
769 | 769 |
String s = line.getPropValue(); |
770 |
s = Query.addBackSlash(s); |
|
770 |
s = CQLQuery.addBackSlash(s);
|
|
771 | 771 |
query += s + "|"; //$NON-NLS-1$ |
772 | 772 |
} |
773 | 773 |
query = query.substring(0, query.length() - 1); |
tmp/org.txm.para.core/src/org/txm/para/core/functions/ParallelContexts.java (revision 1061) | ||
---|---|---|
18 | 18 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
19 | 19 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
20 | 20 |
import org.txm.searchengine.cqp.corpus.query.Match; |
21 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
21 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
22 | 22 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
23 | 23 |
|
24 | 24 |
public class ParallelContexts { |
... | ... | |
60 | 60 |
//String lang = corpus.getLang(); |
61 | 61 |
String query = queries.get(num); |
62 | 62 |
System.out.println(corpus.getName()+" query: "+query); |
63 |
QueryResult result = corpus.query(new Query(query), "TMP", true); |
|
63 |
QueryResult result = corpus.query(new CQLQuery(query), "TMP", true);
|
|
64 | 64 |
|
65 | 65 |
try { |
66 | 66 |
List<Match> matches = result.getMatches(); |
... | ... | |
162 | 162 |
ref = corpus.getStructuralUnit(split[0]).getProperty(split[1]); |
163 | 163 |
|
164 | 164 |
// get the seg that actually are in the corpus |
165 |
QueryResult resul2t = corpus.query(new Query(segquery), "TMP", true); |
|
165 |
QueryResult resul2t = corpus.query(new CQLQuery(segquery), "TMP", true);
|
|
166 | 166 |
int[] struct_starts = resul2t.getStarts(); |
167 | 167 |
int[] struct_pos = CQPSearchEngine.getCqiClient().cpos2Struc(align_id.getQualifiedName(), struct_starts); |
168 | 168 |
String[] struct_ids = CQPSearchEngine.getCqiClient().struc2Str(align_id.getQualifiedName(), struct_pos); |
... | ... | |
178 | 178 |
//System.out.println("ref values: "+Arrays.toString(ref_values)); |
179 | 179 |
|
180 | 180 |
// get the words values of segs |
181 |
QueryResult result = corpus.query(new Query(segquery+"+</"+struct+">"), "TMP", false); |
|
181 |
QueryResult result = corpus.query(new CQLQuery(segquery+"+</"+struct+">"), "TMP", false);
|
|
182 | 182 |
List<Match> matches = result.getMatches(); |
183 | 183 |
//System.out.println("seg matches: "+matches); |
184 | 184 |
ArrayList<Integer> positions = new ArrayList<Integer>(); |
tmp/org.txm.para.core/src/org/txm/para/core/functions/ParaBrowser.java (revision 1061) | ||
---|---|---|
18 | 18 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
19 | 19 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
20 | 20 |
import org.txm.searchengine.cqp.corpus.query.Match; |
21 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
21 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
|
|
22 | 22 |
import org.txm.searchengine.cqp.corpus.query.QueryPart; |
23 | 23 |
import org.txm.utils.Pair; |
24 | 24 |
import org.txm.utils.i18n.LangFormater; |
... | ... | |
47 | 47 |
public String getNextOrPrevious(MainCorpus corpus, StructuralUnit unit, |
Formats disponibles : Unified diff