Révision 2130
| tmp/org.txm.tigersearch.rcp/groovy/org/txm/scripts/importer/tigersearch/TSImport.groovy (revision 2130) | ||
|---|---|---|
| 81 | 81 |
File tigerBinDir = new File(tigerDir, corpusName) |
| 82 | 82 |
tigerBinDir.mkdir() |
| 83 | 83 |
try {
|
| 84 |
IndexBuilderErrorHandler handler = new SimpleErrorHandler(tigerBinDir.getAbsolutePath()); |
|
| 84 |
IndexBuilderErrorHandler handler = new SimpleErrorHandler(tigerBinDir.getAbsolutePath()) {
|
|
| 85 |
public void setMessage(String message) { }
|
|
| 86 |
public void setNumberOfSentences(int number) { }
|
|
| 87 |
public void setProgressBar(int value) { }
|
|
| 88 |
}; |
|
| 85 | 89 |
XMLIndexing indexing = new XMLIndexing(corpusName, uri, tigerBinDir.getAbsolutePath(), handler,false); |
| 86 | 90 |
indexing.startIndexing(); |
| 87 | 91 |
File logs = new File(tigerBinDir, "indexing.log"); |
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSCorpus.java (revision 2130) | ||
|---|---|---|
| 142 | 142 |
*/ |
| 143 | 143 |
public TSResult query(String query) throws Exception |
| 144 | 144 |
{
|
| 145 |
return query(query, -1, -1, -1); |
|
| 146 |
} |
|
| 147 |
|
|
| 148 |
/** |
|
| 149 |
* Query. |
|
| 150 |
* |
|
| 151 |
* @param query the query |
|
| 152 |
* @return the tS result |
|
| 153 |
* @throws Exception |
|
| 154 |
*/ |
|
| 155 |
public TSResult query(String query, int sent_min, int sent_max, int match_max) throws Exception |
|
| 156 |
{
|
|
| 145 | 157 |
if (results.containsKey(query.hashCode())) |
| 146 | 158 |
return results.get(query.hashCode()); |
| 147 | 159 |
|
| 148 |
TSResult rez = new TSResult(query, this); |
|
| 160 |
TSResult rez = new TSResult(query, this, sent_min, sent_max, match_max);
|
|
| 149 | 161 |
results.put(query.hashCode(), rez); |
| 150 | 162 |
return rez; |
| 151 | 163 |
} |
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSResult.java (revision 2130) | ||
|---|---|---|
| 99 | 99 |
* @throws QueryNormalizationException |
| 100 | 100 |
* @throws Exception |
| 101 | 101 |
*/ |
| 102 |
public TSResult(String query, TSCorpus tsCorpus) throws Exception {
|
|
| 102 |
public TSResult(String query, TSCorpus tsCorpus, int sent_min, int sent_max, int match_max) throws Exception {
|
|
| 103 | 103 |
|
| 104 | 104 |
this.query = query; |
| 105 | 105 |
this.manager = tsCorpus.manager; |
| 106 | 106 |
//this.corpus = tsCorpus; |
| 107 | 107 |
this.tsCorpus = tsCorpus; |
| 108 | 108 |
|
| 109 |
result = tsCorpus.manager.processQuery(query); |
|
| 109 |
result = tsCorpus.manager.processQuery(query, sent_min, sent_max, match_max);
|
|
| 110 | 110 |
if (result.size() > 0) {
|
| 111 | 111 |
forest = new ResultForest(result, tsCorpus.manager); |
| 112 | 112 |
header = forest.getHeader(); |
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java (revision 2130) | ||
|---|---|---|
| 15 | 15 |
import org.txm.searchengine.core.SearchEngine; |
| 16 | 16 |
import org.txm.searchengine.core.SearchEngineProperty; |
| 17 | 17 |
import org.txm.searchengine.core.Selection; |
| 18 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
| 19 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
| 20 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
| 18 | 21 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 19 | 22 |
import org.txm.utils.DeleteDir; |
| 23 |
import org.txm.utils.logger.Log; |
|
| 20 | 24 |
|
| 21 | 25 |
import ims.tiger.index.reader.Index; |
| 22 | 26 |
import ims.tiger.query.api.MatchResult; |
| ... | ... | |
| 59 | 63 |
TSCorpusManager manager = new TSCorpusManager(tigerDirectory, configfile); |
| 60 | 64 |
|
| 61 | 65 |
TSCorpus tcorpus = manager.getCorpus(corpus.getRootCorpusBuild().getID()); |
| 62 |
TSResult result = tcorpus.query(query.getQueryString().replace("\n", " "));
|
|
| 66 |
TSResult result = null; |
|
| 67 |
if (corpus == corpus.getRootCorpusBuild() || !(corpus instanceof CQPCorpus)) { // root corpus or something not a CQPCorpus
|
|
| 68 |
result = tcorpus.query(query.getQueryString().replace("\n", " "));
|
|
| 69 |
} else {
|
|
| 70 |
CQPCorpus cqpCorpus = (CQPCorpus)corpus; |
|
| 71 |
AbstractCqiClient CQI = CQPSearchEngine.getCqiClient(); |
|
| 72 |
List<org.txm.searchengine.cqp.corpus.query.Match> matches = cqpCorpus.getMatches(); |
|
| 73 |
if (matches.size() == 0) {
|
|
| 74 |
return new EmptySelection(query); |
|
| 75 |
} |
|
| 76 |
int[] cpos = {matches.get(0).getStart(), matches.get(matches.size()-1).getEnd()};
|
|
| 77 |
int[] structs = CQI.cpos2Struc(cqpCorpus.getStructuralUnit("s").getProperty("n").getQualifiedName(), cpos);
|
|
| 78 |
if (structs.length == 0) {
|
|
| 79 |
return new EmptySelection(query); |
|
| 80 |
} |
|
| 81 |
int sent_min = structs[0]; |
|
| 82 |
int sent_max = structs[structs.length-1]; |
|
| 83 |
Log.finest("QUERYING sentences: "+sent_min+" -> "+sent_max);
|
|
| 84 |
result = tcorpus.query(query.getQueryString().replace("\n", " "), sent_min, sent_max+1, -1);
|
|
| 85 |
} |
|
| 63 | 86 |
MatchResult mresult = result.getMatchResult(); |
| 64 | 87 |
int size = mresult.size(); |
| 65 | 88 |
//System.out.println("size: "+size);
|
Formats disponibles : Unified diff