Revision 1078

tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java (revision 1078)
34 34
import org.txm.core.messages.TXMCoreMessages;
35 35
import org.txm.searchengine.core.Selection;
36 36
import org.txm.searchengine.cqp.AbstractCqiClient;
37
import org.txm.searchengine.cqp.CQPSearchEngine;
38
import org.txm.searchengine.cqp.ICqiClient;
37 39
import org.txm.searchengine.cqp.NetCqiClient;
38 40
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
39 41
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
......
381 383
	public String toString() {
382 384
		return this.getQualifiedCqpId();
383 385
	}
386

  
387
	@Override
388
	public boolean isTargetUsed() throws UnexpectedAnswerException, IOException, CqiServerError {
389
		return CQPSearchEngine.getCqiClient().subCorpusHasField(this.getQualifiedCqpId(), ICqiClient.CQI_CONST_FIELD_TARGET);
390
	}
384 391
}
tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java (revision 1078)
27 27
	public Query getQuery() {
28 28
		return query;
29 29
	}
30

  
31
	@Override
32
	public boolean isTargetUsed() {
33
		return false;
34
	}
35

  
36
	@Override
37
	public void drop() throws Exception {
38
	}
30 39
}
tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java (revision 1078)
13 13
	public abstract int getNMatch() throws Exception;
14 14
	
15 15
	public abstract Query getQuery();
16

  
17
	public abstract boolean isTargetUsed() throws Exception;
18

  
19
	public abstract void drop() throws Exception;
16 20
}
tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java (revision 1078)
29 29
	 * @return
30 30
	 */
31 31
	public static SearchEngine getTIGERSearchEngine() {
32
		return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine("TIGERSearch");
32
		return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine("TIGER");
33 33
	}
34 34

  
35 35
	@Override
tmp/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java (revision 1078)
11 11
import org.eclipse.ui.plugin.AbstractUIPlugin;
12 12
import org.txm.core.results.TXMParameters;
13 13
import org.txm.core.results.TXMResult;
14
import org.txm.objects.CorpusBuild;
14 15
import org.txm.searchengine.cqp.corpus.Corpus;
15 16
import org.txm.searchengine.cqp.corpus.MainCorpus;
16 17
import org.txm.searchengine.ts.TSCorpus;
......
27 28
	protected boolean ready = false;
28 29
	protected TSResult tsresult;
29 30
	protected String T, NT;
30
	protected MainCorpus corpus;
31
	protected CorpusBuild corpus;
31 32
	protected String query;
32 33

  
33
	public MainCorpus getCorpus() {
34
	public CorpusBuild getCorpus() {
34 35
		return corpus;
35 36
	}
36 37
	
37
	public TIGERSearch(Corpus corpus) {
38
		super(corpus);
39
		this.corpus = corpus.getMainCorpus();
38
	public TIGERSearch(CorpusBuild corpus2) {
39
		super(corpus2);
40
		this.corpus = corpus2;
40 41

  
41
		String id = corpus.getName();
42
		File configfile = new File(corpus.getProjectDirectory(),"tiger/tigersearch.logprop");
43
		File registrydir = new File(corpus.getProjectDirectory(), "tiger");
44
		File tscorpusdir = new File(corpus.getProjectDirectory(), "tiger/"+id);
42
		String id = corpus2.getName();
43
		File configfile = new File(corpus2.getProjectDirectory(),"tiger/tigersearch.logprop");
44
		File registrydir = new File(corpus2.getProjectDirectory(), "tiger");
45
		File tscorpusdir = new File(corpus2.getProjectDirectory(), "tiger/"+id);
45 46
		
46 47
		if (!tscorpusdir.exists()) {
47 48
			System.out.println("Error: can't find corpus directory: "+tscorpusdir);
......
75 76
		return true;
76 77
	}
77 78
	
79
	public TSResult getTSResult() {
80
		return tsresult;
81
	}
82
	
78 83
	public boolean isComputed() {
79 84
		return tsresult != null;
80 85
	}
......
118 123
		return ntFeatures.toArray(new String[ntFeatures.size()]);
119 124
	}
120 125

  
121
	public Corpus getParent() {
126
	public CorpusBuild getParent() {
122 127
		return corpus;
123 128
	}
124 129

  
tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERQuery.java (revision 1078)
1
package org.txm.searchengine.ts;
2

  
3
import org.txm.searchengine.core.Query;
4
import org.txm.searchengine.core.SearchEngine;
5
import org.txm.searchengine.core.SearchEnginesManager;
6

  
7
public class TIGERQuery implements Query {
8

  
9
	String query;
10
	
11
	@Override
12
	public String getQueryString() {
13
		return query;
14
	}
15

  
16
	@Override
17
	public boolean isEmpty() {
18
		return query.isEmpty();
19
	}
20

  
21
	@Override
22
	public SearchEngine getSearchEngine() {
23
		return SearchEnginesManager.getTIGERSearchEngine();
24
	}
25

  
26
	@Override
27
	public Query setQuery(String rawQuery) {
28
		query = rawQuery;
29
		return this;
30
	}
31

  
32
	@Override
33
	public Query fixQuery() {
34
		return this;
35
	}
36
}
0 37

  
tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java (revision 1078)
1
package org.txm.searchengine.ts;
2

  
3
import java.io.File;
4

  
5
import org.eclipse.core.runtime.IProgressMonitor;
6
import org.txm.function.tigersearch.TIGERSearch;
7
import org.txm.objects.CorpusBuild;
8
import org.txm.searchengine.core.EmptySelection;
9
import org.txm.searchengine.core.Query;
10
import org.txm.searchengine.core.SearchEngine;
11
import org.txm.searchengine.core.Selection;
12

  
13
import ims.tiger.gui.tigergraphviewer.forest.ResultForest;
14
import ims.tiger.query.api.MatchResult;
15

  
16
public class TIGERSearchEngine extends SearchEngine {
17

  
18
	@Override
19
	public boolean isRunning() {
20
		return true;
21
	}
22

  
23
	@Override
24
	public boolean initialize() throws Exception {
25
		return true;
26
	}
27

  
28
	@Override
29
	public boolean start(IProgressMonitor monitor) throws Exception {
30
		return true;
31
	}
32

  
33
	@Override
34
	public boolean stop() throws Exception {
35
		return true;
36
	}
37

  
38
	@Override
39
	public String getName() {
40
		return "TIGER";
41
	}
42

  
43
	@Override
44
	public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
45
		File tigerDirectory = new File(corpus.getProjectDirectory(), "tiger");
46
		File configfile = new File(tigerDirectory, "tigersearch.logprop");
47
		TSCorpusManager manager = new TSCorpusManager(tigerDirectory, configfile);
48
		
49
		TSResult result = manager.getCorpus(corpus.getName()).query(query.getQueryString());
50
		ResultForest forest = result.getForest();
51
		System.out.println("TIGERSearch: forest size="+forest.getForestSize());
52
		MatchResult mresult = result.getMatchResult();
53
		
54
		System.out.println("FIXME return EmptySelection for now...");
55
		return new EmptySelection(query);
56
	}
57

  
58
	@Override
59
	public Query newQuery() {
60
		return new TIGERQuery();
61
	}
62

  
63
	@Override
64
	public boolean hasIndexes(CorpusBuild corpus) {
65
		//TODO implement a corpora of TIGER corpus
66
		File buildDirectory = new File(corpus.getProjectDirectory(), "tiger");
67
		return	new File(buildDirectory, "tigersearch.logprop").exists() && 
68
		 new File(buildDirectory, corpus.getName()).exists();
69
	}
70

  
71
	
72
}
0 73

  
tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSCorpusManager.java (revision 1078)
27 27
//
28 28
package org.txm.searchengine.ts;
29 29

  
30
import ims.tiger.gui.tigergraphviewer.TIGERGraphViewerConfiguration;
31

  
32 30
import java.io.File;
33 31
import java.util.HashMap;
34 32

  
......
48 46
	private File registrydir;
49 47
	
50 48
	/** The configdir. */
51
	private File configdir;
49
	private File configFile;
52 50
	
53 51
	/** The initok. */
54 52
	private boolean initok = false;
......
62 60
	public TSCorpusManager(File registrydir, File configdir)
63 61
	{
64 62
		this.registrydir = registrydir;
65
		this.configdir = configdir;
63
		this.configFile = configdir;
66 64
			
67 65
		initok = true;
68 66
		
......
93 91
	 */
94 92
	public String getconfPath() 
95 93
	{
96
		return configdir.getAbsolutePath();
94
		return configFile.getAbsolutePath();
97 95
	}
98 96

  
99 97
	/**
tmp/org.txm.tigersearch.rcp/src/org/txm/tigersearch/editors/TIGERSearchEditor.java (revision 1078)
23 23
import org.eclipse.ui.IEditorSite;
24 24
import org.eclipse.ui.PartInitException;
25 25
import org.txm.Toolbox;
26
import org.txm.core.preferences.TBXPreferences;
27
import org.txm.core.preferences.TXMPreferences;
28 26
import org.txm.function.tigersearch.TIGERSearch;
27
import org.txm.objects.CorpusBuild;
29 28
import org.txm.rcp.JobsTimer;
30 29
import org.txm.rcp.editors.TXMEditor;
31 30
import org.txm.rcp.editors.TXMResultEditorInput;
......
33 32
import org.txm.rcp.utils.JobHandler;
34 33
import org.txm.rcp.views.QueriesView;
35 34
import org.txm.rcp.views.corpora.CorporaView;
36
import org.txm.searchengine.cqp.corpus.Corpus;
37 35
import org.txm.statsengine.r.rcp.views.RVariablesView;
38 36
//import org.txm.stat.engine.r.RDevice;
39 37
import org.txm.utils.logger.Log;
......
46 44
	public static final String ID = "org.txm.tigersearch.editors.TIGERSearchEditor"; //$NON-NLS-1$
47 45

  
48 46
	public Object source;
49
	public Corpus corpus;
47
	public CorpusBuild corpus;
50 48
	File svgFile;
51 49

  
52 50
	SVGComposite svgPanel;
tmp/org.txm.tigersearch.rcp/plugin.xml (revision 1078)
196 196
            name="Install TIGER Groovy Files">
197 197
      </PostTXMHOMEInstallationStep>
198 198
   </extension>
199
   <extension
200
         point="org.txm.searchengine.core.SearchEngine">
201
      <SearchEngine
202
            class="org.txm.searchengine.ts.TIGERSearchEngine">
203
      </SearchEngine>
204
   </extension>
199 205

  
200 206
</plugin>
tmp/org.txm.tigersearch.rcp/META-INF/MANIFEST.MF (revision 1078)
59 59
 org.txm.test,
60 60
 org.txm.tigersearch.commands,
61 61
 org.txm.tigersearch.editors,
62
 org.txm.tigersearch.rcp,
62 63
 org.txm.tigersearch.rcp.tester,
63 64
 tigerAPI,
64 65
 tigerAPI.converters,
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 1078)
49 49
import org.txm.index.core.functions.LineComparator.SortMode;
50 50
import org.txm.index.core.messages.IndexCoreMessages;
51 51
import org.txm.index.core.preferences.IndexPreferences;
52
import org.txm.searchengine.core.Match;
52 53
import org.txm.searchengine.core.Query;
54
import org.txm.searchengine.core.Selection;
53 55
import org.txm.searchengine.cqp.CQPSearchEngine;
54 56
import org.txm.searchengine.cqp.ICqiClient;
55 57
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
......
61 63
import org.txm.searchengine.cqp.corpus.QueryResult;
62 64
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
63 65
import org.txm.searchengine.cqp.corpus.WordProperty;
64
import org.txm.searchengine.cqp.corpus.query.Match;
65 66
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
66 67
import org.txm.searchengine.cqp.serverException.CqiServerError;
67 68
import org.txm.statsengine.r.core.RWorkspace;
......
864 865
		// get the cqp result of the query
865 866

  
866 867
		//long time = System.currentTimeMillis();
867
		QueryResult result = null;
868
		Selection result = null;
868 869
		if (pQuery instanceof CQLQuery) {
869 870
			result = corpus.query((CQLQuery)pQuery, "index", true); //$NON-NLS-1$
870 871
		} else {
871
			pQuery.getSearchEngine().query(corpus, pQuery, "index", true); //$NON-NLS-1$
872
			result = pQuery.getSearchEngine().query(corpus, pQuery, "index", true); //$NON-NLS-1$
872 873
		}
873
		boolean isTargetUsed = CQPSearchEngine.getCqiClient().subCorpusHasField(result.getQualifiedCqpId(), ICqiClient.CQI_CONST_FIELD_TARGET);
874
		boolean isTargetUsed = result.isTargetUsed();
874 875
		int nbresults = result.getNMatch();
875 876
		this.nTotalTokens += nbresults; // get number of tokens
876 877

  
877 878
		// System.out.println("nLines : "+nLines);
878
		List<Match> matches = null;
879
		List<? extends Match> matches = null;
879 880
		if (nbresults > 0) {
880 881
			matches = result.getMatches(0, nbresults - 1); // get the indexes sequences of result's tokens
881 882
		}

Also available in: Unified diff