Révision 2132
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java (revision 2132) | ||
|---|---|---|
| 8 | 8 |
public class EmptySelection extends Selection {
|
| 9 | 9 |
|
| 10 | 10 |
private static final List<? extends Match> EMPTY = new ArrayList<Match>(); |
| 11 |
protected Query query; |
|
| 11 |
protected IQuery query;
|
|
| 12 | 12 |
|
| 13 |
public EmptySelection(Query query) {
|
|
| 13 |
public EmptySelection(IQuery query) {
|
|
| 14 | 14 |
this.query = query; |
| 15 | 15 |
} |
| 16 | 16 |
|
| ... | ... | |
| 26 | 26 |
return 0; |
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
public Query getQuery() {
|
|
| 29 |
public IQuery getQuery() {
|
|
| 30 | 30 |
return query; |
| 31 | 31 |
} |
| 32 | 32 |
|
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/ISearchEngine.java (revision 2132) | ||
|---|---|---|
| 5 | 5 |
|
| 6 | 6 |
public interface ISearchEngine extends Engine {
|
| 7 | 7 |
|
| 8 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception; |
|
| 8 |
public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception;
|
|
| 9 | 9 |
|
| 10 | 10 |
/** |
| 11 | 11 |
* |
| 12 | 12 |
* @return an empty Query for the engine implementation |
| 13 | 13 |
*/ |
| 14 |
public Query newQuery(); |
|
| 14 |
public IQuery newQuery();
|
|
| 15 | 15 |
|
| 16 | 16 |
/** |
| 17 | 17 |
* |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java (revision 2132) | ||
|---|---|---|
| 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 |
// |
|
| 1 | 28 |
package org.txm.searchengine.core; |
| 2 | 29 |
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 33 |
import org.txm.core.preferences.TXMPreferences; |
|
| 34 |
|
|
| 3 | 35 |
/** |
| 4 |
* Represent a search engine query
|
|
| 36 |
* Implements a SearchEngine generic query with a query and a search engine.
|
|
| 5 | 37 |
* |
| 6 |
* @author mdecorde |
|
| 7 |
* |
|
| 38 |
* TODO stop using CQLQuery and TIGERQuery with this class |
|
| 8 | 39 |
*/ |
| 9 |
public interface Query {
|
|
| 10 |
|
|
| 11 |
public String getQueryString(); |
|
| 12 |
|
|
| 13 |
public boolean isEmpty(); |
|
| 14 | 40 |
|
| 41 |
public class Query implements IQuery {
|
|
| 42 |
|
|
| 15 | 43 |
/** |
| 44 |
* Converts the specified list of Query to a string. |
|
| 45 |
* Queries strings are separated by a tabulation. |
|
| 46 |
* @param queries |
|
| 47 |
* @return |
|
| 48 |
*/ |
|
| 49 |
public static String queriesToString(List<Query> queries) {
|
|
| 50 |
String str = ""; |
|
| 51 |
for (int i = 0; i < queries.size(); i++) {
|
|
| 52 |
if(i > 0) {
|
|
| 53 |
str += TXMPreferences.LIST_SEPARATOR; |
|
| 54 |
} |
|
| 55 |
str += queries.get(i).getQueryString(); |
|
| 56 |
str += TXMPreferences.LIST_SEPARATOR+queries.get(i).getSearchEngine().getName(); |
|
| 57 |
} |
|
| 58 |
return str; |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
/** |
|
| 62 |
* Converts the specified string to a list of Query. |
|
| 63 |
* Input string must contains queries separated by a tabulation. |
|
| 64 |
* @param str |
|
| 65 |
* @return |
|
| 66 |
*/ |
|
| 67 |
public static List<Query> stringToQueries(String str) {
|
|
| 68 |
ArrayList<Query> queries = new ArrayList<Query>(); |
|
| 69 |
if (str == null || str.length() == 0) {
|
|
| 70 |
return queries; |
|
| 71 |
} |
|
| 72 |
String[] split = str.split(TXMPreferences.LIST_SEPARATOR); |
|
| 73 |
for (int i = 0 ; i +1 < split.length ; i = i+2) {
|
|
| 74 |
String s = split[i]; |
|
| 75 |
String eName = split[i]; |
|
| 76 |
SearchEngine e = SearchEnginesManager.getSearchEngine(eName); |
|
| 77 |
queries.add(new Query(s, e)); |
|
| 78 |
} |
|
| 79 |
return queries; |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
/** |
|
| 83 |
* Converts the specified string to a Query. |
|
| 84 |
* Input string must contains queries separated by a tabulation. |
|
| 85 |
* @param str |
|
| 86 |
* @return |
|
| 87 |
*/ |
|
| 88 |
public static Query stringToQuery(String str) {
|
|
| 89 |
|
|
| 90 |
String[] split = str.split(TXMPreferences.LIST_SEPARATOR, 2); |
|
| 91 |
String eName = split[1]; |
|
| 92 |
SearchEngine e = SearchEnginesManager.getSearchEngine(eName); |
|
| 93 |
return new Query(split[0], e); |
|
| 94 |
|
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
/** |
|
| 98 |
* The query string. |
|
| 99 |
*/ |
|
| 100 |
protected SearchEngine engine = null; |
|
| 101 |
|
|
| 102 |
/** |
|
| 103 |
* The query string. |
|
| 104 |
*/ |
|
| 105 |
protected String queryString = ""; |
|
| 106 |
|
|
| 107 |
|
|
| 108 |
/** |
|
| 109 |
* Instantiates a new query. |
|
| 16 | 110 |
* |
| 17 |
* @return the Query SearchEngine that can resolve the query |
|
| 111 |
* @param queryString |
|
| 112 |
* the query string |
|
| 113 |
* |
|
| 114 |
* public Query(String queryString){
|
|
| 115 |
* this.queryString=queryString.trim(); } |
|
| 18 | 116 |
*/ |
| 19 |
public SearchEngine getSearchEngine(); |
|
| 117 |
public Query(String queryString, SearchEngine engine) {
|
|
| 118 |
if (queryString != null) {
|
|
| 119 |
this.queryString = queryString.trim(); |
|
| 120 |
} |
|
| 121 |
else {
|
|
| 122 |
this.queryString = ""; |
|
| 123 |
} |
|
| 20 | 124 |
|
| 125 |
this.engine = engine; |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
@Override |
|
| 129 |
public boolean equals(IQuery q) {
|
|
| 130 |
return this.engine.equals(q.getSearchEngine()) && this.getQueryString().equals(q.getQueryString()); |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
@Override |
|
| 134 |
public boolean equals(Object obj) {
|
|
| 135 |
if (obj == null) return false; |
|
| 136 |
if (!(obj instanceof Query)) {
|
|
| 137 |
return false; |
|
| 138 |
} |
|
| 139 |
if (this.queryString == null) return false; |
|
| 140 |
if (this.engine == null) return false; |
|
| 141 |
|
|
| 142 |
return this.queryString.equals(((Query) obj).queryString) && this.engine.equals(((Query) obj).engine); |
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
@Override |
|
| 146 |
public IQuery fixQuery() {
|
|
| 147 |
return new Query(queryString, this.engine); |
|
| 148 |
} |
|
| 149 |
|
|
| 150 |
|
|
| 21 | 151 |
/** |
| 22 |
* update the query
|
|
| 152 |
* Gets the query string.
|
|
| 23 | 153 |
* |
| 24 |
* @param rawQuery |
|
| 25 |
* @return this |
|
| 154 |
* @return the query string |
|
| 26 | 155 |
*/ |
| 27 |
public Query setQuery(String rawQuery); |
|
| 28 |
|
|
| 156 |
public final String getQueryString() {
|
|
| 157 |
return queryString; |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
@Override |
|
| 161 |
public SearchEngine getSearchEngine() {
|
|
| 162 |
return engine; |
|
| 163 |
} |
|
| 164 |
|
|
| 29 | 165 |
/** |
| 30 |
* fix the query using sugar syntax rules
|
|
| 31 |
* @return this
|
|
| 166 |
* Checks whatever the query is empty (null, empty or contains only double quotes) or not.
|
|
| 167 |
* @return true if empty otherwise false
|
|
| 32 | 168 |
*/ |
| 33 |
public Query fixQuery(); |
|
| 34 |
|
|
| 35 |
public boolean equals(Query q); |
|
| 169 |
public boolean isEmpty() {
|
|
| 170 |
return queryString == null || queryString.length() == 0 || "\"\"".equals(queryString); |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
@Override |
|
| 174 |
public IQuery setQuery(String rawQuery) {
|
|
| 175 |
queryString = rawQuery; |
|
| 176 |
return this; |
|
| 177 |
} |
|
| 178 |
|
|
| 179 |
/* (non-Javadoc) |
|
| 180 |
* @see java.lang.Object#toString() |
|
| 181 |
*/ |
|
| 182 |
@Override |
|
| 183 |
public String toString() {
|
|
| 184 |
return queryString; |
|
| 185 |
} |
|
| 36 | 186 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java (revision 2132) | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
public abstract int getNMatch() throws Exception; |
| 15 | 15 |
|
| 16 |
public abstract Query getQuery(); |
|
| 16 |
public abstract IQuery getQuery();
|
|
| 17 | 17 |
|
| 18 | 18 |
public abstract boolean isTargetUsed() throws Exception; |
| 19 | 19 |
|
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java (revision 2132) | ||
|---|---|---|
| 31 | 31 |
public static SearchEngine getTIGERSearchEngine() {
|
| 32 | 32 |
return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine("TIGER");
|
| 33 | 33 |
} |
| 34 |
|
|
| 35 |
/** |
|
| 36 |
* |
|
| 37 |
* @return |
|
| 38 |
*/ |
|
| 39 |
public static SearchEngine getSearchEngine(String name) {
|
|
| 40 |
return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine(name); |
|
| 41 |
} |
|
| 34 | 42 |
|
| 35 | 43 |
@Override |
| 36 | 44 |
public boolean fetchEngines() {
|
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java (revision 2132) | ||
|---|---|---|
| 19 | 19 |
return start(new LogMonitor("Starting "+getName()));
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
public abstract Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception; |
|
| 22 |
public abstract Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception;
|
|
| 23 | 23 |
|
| 24 |
public abstract Query newQuery(); |
|
| 24 |
public abstract IQuery newQuery();
|
|
| 25 | 25 |
|
| 26 | 26 |
/** |
| 27 | 27 |
* |
| ... | ... | |
| 34 | 34 |
return this.getClass()+ " "+this.toString(); |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
public boolean equals(SearchEngine e) {
|
|
| 38 |
|
|
| 39 |
if (e == null) return false; |
|
| 40 |
if (this.getName() == null) return false; |
|
| 41 |
|
|
| 42 |
return this.getName().equals(e.getName()); |
|
| 43 |
} |
|
| 44 |
|
|
| 37 | 45 |
/** |
| 38 | 46 |
* |
| 39 | 47 |
* @param match |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java (revision 2132) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.core; |
|
| 2 |
|
|
| 3 |
/** |
|
| 4 |
* Represent a search engine query |
|
| 5 |
* |
|
| 6 |
* @author mdecorde |
|
| 7 |
* |
|
| 8 |
*/ |
|
| 9 |
public interface IQuery {
|
|
| 10 |
|
|
| 11 |
public String getQueryString(); |
|
| 12 |
|
|
| 13 |
public boolean isEmpty(); |
|
| 14 |
|
|
| 15 |
/** |
|
| 16 |
* |
|
| 17 |
* @return the Query SearchEngine that can resolve the query |
|
| 18 |
*/ |
|
| 19 |
public SearchEngine getSearchEngine(); |
|
| 20 |
|
|
| 21 |
/** |
|
| 22 |
* update the query |
|
| 23 |
* |
|
| 24 |
* @param rawQuery |
|
| 25 |
* @return this |
|
| 26 |
*/ |
|
| 27 |
public IQuery setQuery(String rawQuery); |
|
| 28 |
|
|
| 29 |
/** |
|
| 30 |
* fix the query using sugar syntax rules |
|
| 31 |
* @return this |
|
| 32 |
*/ |
|
| 33 |
public IQuery fixQuery(); |
|
| 34 |
|
|
| 35 |
public boolean equals(IQuery q); |
|
| 36 |
} |
|
| 0 | 37 | |
| tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 2132) | ||
|---|---|---|
| 51 | 51 |
import org.txm.core.results.TXMParameters; |
| 52 | 52 |
import org.txm.core.results.TXMResult; |
| 53 | 53 |
import org.txm.objects.Match; |
| 54 |
import org.txm.searchengine.core.Query; |
|
| 54 |
import org.txm.searchengine.core.IQuery;
|
|
| 55 | 55 |
import org.txm.searchengine.core.Selection; |
| 56 | 56 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
| 57 | 57 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| ... | ... | |
| 114 | 114 |
|
| 115 | 115 |
/** The query. */ |
| 116 | 116 |
@Parameter(key=ConcordancePreferences.QUERY) |
| 117 |
protected Query pQuery; |
|
| 117 |
protected IQuery pQuery;
|
|
| 118 | 118 |
|
| 119 | 119 |
|
| 120 | 120 |
/** The keyword analysis properties */ |
| ... | ... | |
| 291 | 291 |
|
| 292 | 292 |
if (!this.getCorpus().equals(other.getCorpus())) return false; |
| 293 | 293 |
|
| 294 |
Query q1 = other.getQuery(); |
|
| 295 |
Query q2 = this.getQuery(); |
|
| 294 |
IQuery q1 = other.getQuery();
|
|
| 295 |
IQuery q2 = this.getQuery();
|
|
| 296 | 296 |
if (q1 != null && q2 != null) return q1.equals(q2); |
| 297 | 297 |
|
| 298 | 298 |
return true; |
| ... | ... | |
| 859 | 859 |
* |
| 860 | 860 |
* @return the query |
| 861 | 861 |
*/ |
| 862 |
public Query getQuery() {
|
|
| 862 |
public IQuery getQuery() {
|
|
| 863 | 863 |
return pQuery; |
| 864 | 864 |
} |
| 865 | 865 |
|
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERQuery.java (revision 2132) | ||
|---|---|---|
| 1 | 1 |
package org.txm.searchengine.ts; |
| 2 | 2 |
|
| 3 |
import org.txm.searchengine.core.Query; |
|
| 3 |
import org.txm.searchengine.core.IQuery;
|
|
| 4 | 4 |
import org.txm.searchengine.core.SearchEngine; |
| 5 | 5 |
import org.txm.searchengine.core.SearchEnginesManager; |
| 6 | 6 |
|
| 7 |
public class TIGERQuery implements Query {
|
|
| 7 |
public class TIGERQuery implements IQuery {
|
|
| 8 | 8 |
|
| 9 | 9 |
String query; |
| 10 | 10 |
|
| ... | ... | |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
@Override |
| 27 |
public Query setQuery(String rawQuery) {
|
|
| 27 |
public IQuery setQuery(String rawQuery) {
|
|
| 28 | 28 |
query = rawQuery; |
| 29 | 29 |
return this; |
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
@Override |
| 33 |
public Query fixQuery() {
|
|
| 33 |
public IQuery fixQuery() {
|
|
| 34 | 34 |
return this; |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 | 37 |
@Override |
| 38 |
public boolean equals(Query q) {
|
|
| 38 |
public boolean equals(IQuery q) {
|
|
| 39 | 39 |
return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString()); |
| 40 | 40 |
} |
| 41 | 41 |
|
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSelection.java (revision 2132) | ||
|---|---|---|
| 4 | 4 |
import java.util.List; |
| 5 | 5 |
|
| 6 | 6 |
import org.txm.objects.Match; |
| 7 |
import org.txm.searchengine.core.Query; |
|
| 7 |
import org.txm.searchengine.core.IQuery;
|
|
| 8 | 8 |
import org.txm.searchengine.core.Selection; |
| 9 | 9 |
|
| 10 | 10 |
public class TIGERSelection extends Selection {
|
| 11 | 11 |
|
| 12 | 12 |
List<? extends Match> matches; |
| 13 |
Query query; |
|
| 13 |
IQuery query;
|
|
| 14 | 14 |
|
| 15 |
public TIGERSelection(Query query, List<? extends Match> result2) {
|
|
| 15 |
public TIGERSelection(IQuery query, List<? extends Match> result2) {
|
|
| 16 | 16 |
this.query = query; |
| 17 | 17 |
matches = result2; |
| 18 | 18 |
} |
| ... | ... | |
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
@Override |
| 37 |
public Query getQuery() {
|
|
| 37 |
public IQuery getQuery() {
|
|
| 38 | 38 |
return query; |
| 39 | 39 |
} |
| 40 | 40 |
|
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java (revision 2132) | ||
|---|---|---|
| 11 | 11 |
import org.txm.objects.Match; |
| 12 | 12 |
import org.txm.objects.Project; |
| 13 | 13 |
import org.txm.searchengine.core.EmptySelection; |
| 14 |
import org.txm.searchengine.core.Query; |
|
| 14 |
import org.txm.searchengine.core.IQuery;
|
|
| 15 | 15 |
import org.txm.searchengine.core.SearchEngine; |
| 16 | 16 |
import org.txm.searchengine.core.SearchEngineProperty; |
| 17 | 17 |
import org.txm.searchengine.core.Selection; |
| ... | ... | |
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 | 58 |
@Override |
| 59 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
|
|
| 59 |
public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception {
|
|
| 60 | 60 |
|
| 61 | 61 |
File tigerDirectory = new File(corpus.getProjectDirectory(), "tiger"); |
| 62 | 62 |
File configfile = new File(tigerDirectory, "tigersearch.logprop"); |
| ... | ... | |
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 | 151 |
@Override |
| 152 |
public Query newQuery() {
|
|
| 152 |
public IQuery newQuery() {
|
|
| 153 | 153 |
return new TIGERQuery(); |
| 154 | 154 |
} |
| 155 | 155 |
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java (revision 2132) | ||
|---|---|---|
| 14 | 14 |
import org.txm.objects.CorpusBuild; |
| 15 | 15 |
import org.txm.objects.Match; |
| 16 | 16 |
import org.txm.searchengine.core.EmptySelection; |
| 17 |
import org.txm.searchengine.core.Query; |
|
| 17 |
import org.txm.searchengine.core.IQuery;
|
|
| 18 | 18 |
import org.txm.searchengine.core.SearchEngine; |
| 19 | 19 |
import org.txm.searchengine.core.SearchEngineProperty; |
| 20 | 20 |
import org.txm.searchengine.core.Selection; |
| ... | ... | |
| 410 | 410 |
} |
| 411 | 411 |
|
| 412 | 412 |
@Override |
| 413 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws CqiClientException {
|
|
| 413 |
public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws CqiClientException {
|
|
| 414 | 414 |
if (query instanceof CQLQuery && corpus instanceof CQPCorpus) {
|
| 415 | 415 |
return ((CQPCorpus)corpus).query((CQLQuery)query, name, saveQuery); |
| 416 | 416 |
} else {
|
| ... | ... | |
| 419 | 419 |
} |
| 420 | 420 |
|
| 421 | 421 |
@Override |
| 422 |
public Query newQuery() {
|
|
| 422 |
public IQuery newQuery() {
|
|
| 423 | 423 |
return new CQLQuery(""); //$NON-NLS-1$
|
| 424 | 424 |
} |
| 425 | 425 |
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java (revision 2132) | ||
|---|---|---|
| 33 | 33 |
import java.util.regex.Pattern; |
| 34 | 34 |
|
| 35 | 35 |
import org.txm.core.preferences.TXMPreferences; |
| 36 |
import org.txm.searchengine.core.Query; |
|
| 36 |
import org.txm.searchengine.core.IQuery;
|
|
| 37 | 37 |
import org.txm.searchengine.core.SearchEngine; |
| 38 | 38 |
import org.txm.searchengine.core.SearchEnginesManager; |
| 39 | 39 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| ... | ... | |
| 47 | 47 |
* @author sjacquot |
| 48 | 48 |
*/ |
| 49 | 49 |
|
| 50 |
public class CQLQuery implements Query {
|
|
| 50 |
public class CQLQuery implements IQuery {
|
|
| 51 | 51 |
|
| 52 | 52 |
/** The Constant NoStrategy. */ |
| 53 | 53 |
private static final Integer NoStrategy = 0; |
| ... | ... | |
| 396 | 396 |
} |
| 397 | 397 |
|
| 398 | 398 |
@Override |
| 399 |
public Query setQuery(String rawQuery) {
|
|
| 399 |
public IQuery setQuery(String rawQuery) {
|
|
| 400 | 400 |
this.queryString = rawQuery; |
| 401 | 401 |
return this; |
| 402 | 402 |
} |
| 403 | 403 |
|
| 404 | 404 |
@Override |
| 405 |
public Query fixQuery() {
|
|
| 405 |
public IQuery fixQuery() {
|
|
| 406 | 406 |
this.queryString = fixQuery(this.queryString); |
| 407 | 407 |
return this; |
| 408 | 408 |
} |
| 409 | 409 |
|
| 410 | 410 |
@Override |
| 411 |
public boolean equals(Query q) {
|
|
| 411 |
public boolean equals(IQuery q) {
|
|
| 412 | 412 |
return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString()); |
| 413 | 413 |
} |
| 414 | 414 |
} |
| tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 2132) | ||
|---|---|---|
| 44 | 44 |
import org.txm.rcp.swt.widget.structures.StructuralUnitPropertiesComboViewer; |
| 45 | 45 |
import org.txm.rcp.swt.widget.structures.StructuralUnitsComboViewer; |
| 46 | 46 |
import org.txm.rcp.swt.widget.structures.StructuralUnitsCombosGroup; |
| 47 |
import org.txm.searchengine.core.Query; |
|
| 47 |
import org.txm.searchengine.core.IQuery;
|
|
| 48 | 48 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 49 | 49 |
import org.txm.utils.io.IOUtils; |
| 50 | 50 |
import org.txm.utils.logger.Log; |
| ... | ... | |
| 533 | 533 |
assistedQueryWidget.setText(query); |
| 534 | 534 |
} |
| 535 | 535 |
|
| 536 |
public Query getQuery() {
|
|
| 536 |
public IQuery getQuery() {
|
|
| 537 | 537 |
return assistedQueryWidget.getQuery(); |
| 538 | 538 |
} |
| 539 | 539 |
|
| ... | ... | |
| 633 | 633 |
|
| 634 | 634 |
// initialize query fields |
| 635 | 635 |
if (queryWidgets.size() == 0 && queryList != null) {
|
| 636 |
for (Query q : queryList) {
|
|
| 636 |
for (IQuery q : queryList) {
|
|
| 637 | 637 |
addFocusQueryField(q.getQueryString()); |
| 638 | 638 |
} |
| 639 | 639 |
} |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 2132) | ||
|---|---|---|
| 51 | 51 |
import org.txm.index.core.messages.IndexCoreMessages; |
| 52 | 52 |
import org.txm.index.core.preferences.IndexPreferences; |
| 53 | 53 |
import org.txm.objects.Match; |
| 54 |
import org.txm.searchengine.core.Query; |
|
| 54 |
import org.txm.searchengine.core.IQuery;
|
|
| 55 | 55 |
import org.txm.searchengine.core.Selection; |
| 56 | 56 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 57 | 57 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| ... | ... | |
| 127 | 127 |
* The CQP query. |
| 128 | 128 |
*/ |
| 129 | 129 |
@Parameter(key=TXMPreferences.QUERY) |
| 130 |
protected Query pQuery; |
|
| 130 |
protected IQuery pQuery;
|
|
| 131 | 131 |
|
| 132 | 132 |
/** |
| 133 | 133 |
* The line index of the current index page. |
| ... | ... | |
| 675 | 675 |
* |
| 676 | 676 |
* @return the query used |
| 677 | 677 |
*/ |
| 678 |
public Query getQuery() {
|
|
| 678 |
public IQuery getQuery() {
|
|
| 679 | 679 |
return pQuery; |
| 680 | 680 |
} |
| 681 | 681 |
|
| tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 2132) | ||
|---|---|---|
| 50 | 50 |
import org.txm.index.core.messages.IndexCoreMessages; |
| 51 | 51 |
import org.txm.index.core.preferences.IndexPreferences; |
| 52 | 52 |
import org.txm.objects.Match; |
| 53 |
import org.txm.searchengine.core.Query; |
|
| 53 |
import org.txm.searchengine.core.IQuery;
|
|
| 54 | 54 |
import org.txm.searchengine.core.Selection; |
| 55 | 55 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 56 | 56 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| ... | ... | |
| 140 | 140 |
* The CQP query. |
| 141 | 141 |
*/ |
| 142 | 142 |
@Parameter(key=TXMPreferences.QUERY) |
| 143 |
protected Query pQuery; |
|
| 143 |
protected IQuery pQuery;
|
|
| 144 | 144 |
|
| 145 | 145 |
/** |
| 146 | 146 |
* The line index of the current index page. |
| ... | ... | |
| 728 | 728 |
* |
| 729 | 729 |
* @return the query used |
| 730 | 730 |
*/ |
| 731 |
public Query getQuery() {
|
|
| 731 |
public IQuery getQuery() {
|
|
| 732 | 732 |
return pQuery; |
| 733 | 733 |
} |
| 734 | 734 |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2132) | ||
|---|---|---|
| 82 | 82 |
import org.txm.rcp.utils.SWTEditorsUtils; |
| 83 | 83 |
import org.txm.rcp.views.corpora.CorporaView; |
| 84 | 84 |
import org.txm.rcp.views.debug.TXMResultDebugView; |
| 85 |
import org.txm.searchengine.core.Query; |
|
| 85 |
import org.txm.searchengine.core.IQuery;
|
|
| 86 | 86 |
import org.txm.searchengine.cqp.ReferencePattern; |
| 87 | 87 |
import org.txm.searchengine.cqp.corpus.Property; |
| 88 | 88 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| ... | ... | |
| 1234 | 1234 |
((NewNavigationWidget)object).setCurrentPosition((Integer) value); |
| 1235 | 1235 |
} |
| 1236 | 1236 |
else if(object instanceof AssistedChoiceQueryWidget) {
|
| 1237 |
if(!((Query)value).getQueryString().isEmpty()) {
|
|
| 1238 |
((AssistedChoiceQueryWidget)object).setText(((Query)value).getQueryString()); |
|
| 1239 |
((AssistedChoiceQueryWidget)object).setSearchEngine(((Query)value).getSearchEngine()); |
|
| 1237 |
if(!((IQuery)value).getQueryString().isEmpty()) {
|
|
| 1238 |
((AssistedChoiceQueryWidget)object).setText(((IQuery)value).getQueryString());
|
|
| 1239 |
((AssistedChoiceQueryWidget)object).setSearchEngine(((IQuery)value).getSearchEngine());
|
|
| 1240 | 1240 |
} |
| 1241 | 1241 |
} |
| 1242 | 1242 |
else if(object instanceof AssistedQueryWidget) {
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java (revision 2132) | ||
|---|---|---|
| 41 | 41 |
import org.txm.rcp.messages.TXMUIMessages; |
| 42 | 42 |
import org.txm.rcp.swt.GLComposite; |
| 43 | 43 |
import org.txm.rcp.swt.dialog.QueryAssistDialog; |
| 44 |
import org.txm.searchengine.core.Query; |
|
| 44 |
import org.txm.searchengine.core.IQuery;
|
|
| 45 | 45 |
import org.txm.searchengine.core.SearchEngine; |
| 46 | 46 |
import org.txm.searchengine.core.SearchEnginesManager; |
| 47 | 47 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| ... | ... | |
| 179 | 179 |
querywidget.setText(query); |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 |
public Query getQuery() {
|
|
| 182 |
public IQuery getQuery() {
|
|
| 183 | 183 |
return this.querywidget.getQuery(); |
| 184 | 184 |
} |
| 185 | 185 |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java (revision 2132) | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
import org.eclipse.swt.widgets.Combo; |
| 34 | 34 |
import org.eclipse.swt.widgets.Composite; |
| 35 |
import org.txm.searchengine.core.Query; |
|
| 35 |
import org.txm.searchengine.core.IQuery;
|
|
| 36 | 36 |
import org.txm.searchengine.core.SearchEngine; |
| 37 | 37 |
import org.txm.searchengine.core.SearchEnginesManager; |
| 38 | 38 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| ... | ... | |
| 130 | 130 |
* |
| 131 | 131 |
* @return the query |
| 132 | 132 |
*/ |
| 133 |
public Query getQuery() {
|
|
| 133 |
public IQuery getQuery() {
|
|
| 134 | 134 |
if (!this.getQueryString().isEmpty()) {
|
| 135 | 135 |
return se.newQuery().setQuery(this.getQueryString()); |
| 136 | 136 |
} else {
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java (revision 2132) | ||
|---|---|---|
| 7 | 7 |
import org.eclipse.swt.widgets.Label; |
| 8 | 8 |
import org.kohsuke.args4j.NamedOptionDef; |
| 9 | 9 |
import org.txm.rcp.swt.widget.QueryWidget; |
| 10 |
import org.txm.searchengine.core.Query; |
|
| 10 |
import org.txm.searchengine.core.IQuery;
|
|
| 11 | 11 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 12 | 12 |
|
| 13 | 13 |
public class QueryField extends ParameterField {
|
| ... | ... | |
| 31 | 31 |
resetToDefault(); |
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
public Query getWidgetValue() {
|
|
| 34 |
public IQuery getWidgetValue() {
|
|
| 35 | 35 |
return w.getQuery(); |
| 36 | 36 |
} |
| 37 | 37 |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java (revision 2132) | ||
|---|---|---|
| 52 | 52 |
import org.txm.rcp.swt.dialog.QueryAssistDialog; |
| 53 | 53 |
import org.txm.rcp.swt.provider.ListContentProvider; |
| 54 | 54 |
import org.txm.rcp.swt.provider.SimpleLabelProvider; |
| 55 |
import org.txm.searchengine.core.Query; |
|
| 55 |
import org.txm.searchengine.core.IQuery;
|
|
| 56 | 56 |
import org.txm.searchengine.core.SearchEngine; |
| 57 | 57 |
import org.txm.searchengine.core.SearchEnginesManager; |
| 58 | 58 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| ... | ... | |
| 242 | 242 |
querywidget.setText(query); |
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 |
public Query getQuery() {
|
|
| 245 |
public IQuery getQuery() {
|
|
| 246 | 246 |
return this.querywidget.getQuery(); |
| 247 | 247 |
} |
| 248 | 248 |
} |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSQuery.java (revision 2132) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import org.txm.Toolbox; |
| 4 | 4 |
import org.txm.core.engines.EngineType; |
| 5 |
import org.txm.searchengine.core.Query; |
|
| 5 |
import org.txm.searchengine.core.IQuery;
|
|
| 6 | 6 |
import org.txm.searchengine.core.SearchEngine; |
| 7 | 7 |
|
| 8 | 8 |
/** |
| ... | ... | |
| 12 | 12 |
* @author mdecorde |
| 13 | 13 |
* |
| 14 | 14 |
*/ |
| 15 |
public class URSQuery implements Query {
|
|
| 15 |
public class URSQuery implements IQuery {
|
|
| 16 | 16 |
|
| 17 | 17 |
String query = ""; //$NON-NLS-1$ |
| 18 | 18 |
|
| ... | ... | |
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
@Override |
| 35 |
public Query setQuery(String rawQuery) {
|
|
| 35 |
public IQuery setQuery(String rawQuery) {
|
|
| 36 | 36 |
query = rawQuery; |
| 37 | 37 |
return this; |
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
@Override |
| 41 |
public Query fixQuery() {
|
|
| 41 |
public IQuery fixQuery() {
|
|
| 42 | 42 |
return this; |
| 43 | 43 |
} |
| 44 | 44 |
|
| ... | ... | |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
@Override |
| 51 |
public boolean equals(Query q) {
|
|
| 51 |
public boolean equals(IQuery q) {
|
|
| 52 | 52 |
return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString()); |
| 53 | 53 |
} |
| 54 | 54 |
} |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java (revision 2132) | ||
|---|---|---|
| 4 | 4 |
import java.util.List; |
| 5 | 5 |
|
| 6 | 6 |
import org.txm.objects.Match; |
| 7 |
import org.txm.searchengine.core.Query; |
|
| 7 |
import org.txm.searchengine.core.IQuery;
|
|
| 8 | 8 |
import org.txm.searchengine.core.Selection; |
| 9 | 9 |
|
| 10 | 10 |
public class URSSelection extends Selection {
|
| 11 | 11 |
|
| 12 | 12 |
ArrayList<URSMatch> matches; |
| 13 |
Query query; |
|
| 13 |
IQuery query;
|
|
| 14 | 14 |
|
| 15 |
public URSSelection(Query query, ArrayList<URSMatch> matches2) {
|
|
| 15 |
public URSSelection(IQuery query, ArrayList<URSMatch> matches2) {
|
|
| 16 | 16 |
this.query = query; |
| 17 | 17 |
matches = matches2; |
| 18 | 18 |
} |
| ... | ... | |
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
@Override |
| 37 |
public Query getQuery() {
|
|
| 37 |
public IQuery getQuery() {
|
|
| 38 | 38 |
return query; |
| 39 | 39 |
} |
| 40 | 40 |
|
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSearchEngine.java (revision 2132) | ||
|---|---|---|
| 11 | 11 |
import org.txm.core.results.TXMResult; |
| 12 | 12 |
import org.txm.objects.CorpusBuild; |
| 13 | 13 |
import org.txm.objects.Match; |
| 14 |
import org.txm.searchengine.core.Query; |
|
| 14 |
import org.txm.searchengine.core.IQuery;
|
|
| 15 | 15 |
import org.txm.searchengine.core.SearchEngine; |
| 16 | 16 |
import org.txm.searchengine.core.SearchEngineProperty; |
| 17 | 17 |
import org.txm.searchengine.core.Selection; |
| ... | ... | |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 | 61 |
@Override |
| 62 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
|
|
| 62 |
public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception {
|
|
| 63 | 63 |
|
| 64 | 64 |
ArrayList<Element> elements = findAllInCorpus(0, URSCorpora.getCorpus(corpus), corpus, Unite.class, query.getQueryString()); |
| 65 | 65 |
ArrayList<URSMatch> matches = new ArrayList<URSMatch>(); |
| ... | ... | |
| 251 | 251 |
} |
| 252 | 252 |
|
| 253 | 253 |
@Override |
| 254 |
public Query newQuery() {
|
|
| 254 |
public IQuery newQuery() {
|
|
| 255 | 255 |
return new URSQuery(); |
| 256 | 256 |
} |
| 257 | 257 |
|
| tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 2132) | ||
|---|---|---|
| 64 | 64 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
| 65 | 65 |
import org.txm.rcp.swt.widget.ThresholdsGroup; |
| 66 | 66 |
import org.txm.rcp.views.QueriesView; |
| 67 |
import org.txm.searchengine.core.Query; |
|
| 67 |
import org.txm.searchengine.core.IQuery;
|
|
| 68 | 68 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 69 | 69 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 70 | 70 |
import org.txm.searchengine.cqp.corpus.Property; |
| ... | ... | |
| 540 | 540 |
* Gets the query of the query widget. |
| 541 | 541 |
* @return |
| 542 | 542 |
*/ |
| 543 |
public Query getQuery() {
|
|
| 543 |
public IQuery getQuery() {
|
|
| 544 | 544 |
return queryWidget.getQuery(); |
| 545 | 545 |
} |
| 546 | 546 |
} |
| tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java (revision 2132) | ||
|---|---|---|
| 65 | 65 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
| 66 | 66 |
import org.txm.rcp.swt.widget.ThresholdsGroup; |
| 67 | 67 |
import org.txm.rcp.views.QueriesView; |
| 68 |
import org.txm.searchengine.core.Query; |
|
| 68 |
import org.txm.searchengine.core.IQuery;
|
|
| 69 | 69 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 70 | 70 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 71 | 71 |
import org.txm.searchengine.cqp.corpus.Part; |
| ... | ... | |
| 655 | 655 |
this.queryWidget.setText(query); |
| 656 | 656 |
} |
| 657 | 657 |
|
| 658 |
public Query getQuery() {
|
|
| 658 |
public IQuery getQuery() {
|
|
| 659 | 659 |
return queryWidget.getQuery(); |
| 660 | 660 |
} |
| 661 | 661 |
} |
Formats disponibles : Unified diff