Revision 645
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 645) | ||
---|---|---|
42 | 42 |
import org.txm.core.results.Parameter; |
43 | 43 |
import org.txm.core.results.TXMParameters; |
44 | 44 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
45 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
46 | 45 |
import org.txm.statsengine.core.StatException; |
47 | 46 |
|
48 | 47 |
/** |
tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryAutoCooccurrence.java (revision 645) | ||
---|---|---|
10 | 10 |
import org.txm.ca.core.functions.CA; |
11 | 11 |
import org.txm.ca.core.functions.ICAComputable; |
12 | 12 |
import org.txm.core.results.TXMParameters; |
13 |
import org.txm.functions.TXMCommand;
|
|
13 |
import org.txm.core.results.TXMResult;
|
|
14 | 14 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
15 | 15 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
16 | 16 |
import org.txm.rcp.IImageKeys; |
... | ... | |
25 | 25 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
26 | 26 |
import org.txm.utils.logger.Log; |
27 | 27 |
|
28 |
public class QueryAutoCooccurrence extends TXMCommand implements ICAComputable, IAdaptable {
|
|
28 |
public class QueryAutoCooccurrence extends TXMResult implements ICAComputable, IAdaptable {
|
|
29 | 29 |
|
30 | 30 |
protected Corpus corpus; |
31 | 31 |
protected int[][] coocs; |
... | ... | |
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
@Override |
67 |
public boolean compute(IProgressMonitor watcher) throws Exception {
|
|
67 |
public boolean _compute() throws Exception {
|
|
68 | 68 |
coocs = new int[queries.size()][queries.size()]; |
69 |
if (monitor != null) monitor.beginTask("Querying cooccurrences...", nNodes); |
|
69 |
|
|
70 |
this.beginTask("Querying cooccurrences...", nNodes); |
|
71 |
|
|
70 | 72 |
for (int i = 0 ; i < queries.size() ; i++) { |
71 | 73 |
int j = i; |
72 | 74 |
if (oriented) j = 0; // if the graph is not oriented, we don't need to evaluate all queries |
73 | 75 |
for (; j < queries.size() ; j++) { |
74 |
if (monitor != null) monitor.worked(1);
|
|
76 |
this.worked(1);
|
|
75 | 77 |
String query = null; |
76 |
if (oriented) |
|
78 |
if (oriented) {
|
|
77 | 79 |
query = "("+queries.get(i)+"[]{0,"+dist+"}"+queries.get(j)+") "+this.struct; |
78 |
else |
|
80 |
} |
|
81 |
else { |
|
79 | 82 |
query = "("+queries.get(i)+"[]{0,"+dist+"}"+queries.get(j)+")|("+queries.get(j)+"[]{0,"+dist+"}"+queries.get(i)+") "+this.struct; |
83 |
} |
|
80 | 84 |
|
81 |
|
|
82 | 85 |
Log.info("ListCooc: query "+query); |
83 | 86 |
QueryResult result = corpus.query(new Query(query), "tmp", false); |
84 | 87 |
coocs[i][j] = result.getNMatch(); |
... | ... | |
97 | 100 |
coocs[j][i] = coocs[i][j]; |
98 | 101 |
} |
99 | 102 |
} |
100 |
if (monitor != null) monitor.done();
|
|
103 |
this.done();
|
|
101 | 104 |
|
102 | 105 |
return true; |
103 | 106 |
} |
... | ... | |
249 | 252 |
org.txm.utils.logger.Log.printStackTrace(e); |
250 | 253 |
} |
251 | 254 |
LexicalTable table = this.toLexicalTable(); |
252 |
int fmin = table.getFmin();
|
|
255 |
int fmin = table.getFMin();
|
|
253 | 256 |
|
254 | 257 |
CA ca = new CA(table); |
255 | 258 |
ca.setParameters(analysisProperty, null, null); |
... | ... | |
311 | 314 |
} |
312 | 315 |
|
313 | 316 |
@Override |
314 |
public boolean validateParameters() {
|
|
317 |
public boolean canCompute() {
|
|
315 | 318 |
return corpus != null; |
316 | 319 |
} |
317 | 320 |
|
318 | 321 |
@Override |
319 | 322 |
public boolean setParameters(TXMParameters parameters) { |
323 |
//FIXME: not yet implemented. |
|
324 |
System.err.println("QueryAutoCooccurrence.setParameters(): not yet implemented."); |
|
320 | 325 |
return false; |
321 | 326 |
} |
322 | 327 |
|
328 |
@Override |
|
329 |
public boolean saveParameters() throws Exception { |
|
330 |
//FIXME: not yet implemented. |
|
331 |
System.err.println("QueryAutoCooccurrence.saveParameters(): not yet implemented."); |
|
332 |
return false; |
|
333 |
} |
|
334 |
|
|
335 |
@Override |
|
336 |
public boolean loadParameters() throws Exception { |
|
337 |
//FIXME: not yet implemented. |
|
338 |
System.err.println("QueryAutoCooccurrence.loadParameters(): not yet implemented."); |
|
339 |
return false; |
|
340 |
} |
|
341 |
|
|
323 | 342 |
} |
tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryCooccurrence.java (revision 645) | ||
---|---|---|
11 | 11 |
import org.txm.ca.core.functions.ICAComputable; |
12 | 12 |
import org.txm.core.results.TXMParameters; |
13 | 13 |
import org.txm.core.results.TXMResult; |
14 |
import org.txm.functions.TXMCommand; |
|
15 | 14 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
16 | 15 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
17 | 16 |
import org.txm.rcp.IImageKeys; |
... | ... | |
26 | 25 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
27 | 26 |
import org.txm.utils.logger.Log; |
28 | 27 |
|
29 |
public class QueryCooccurrence extends TXMCommand implements ICAComputable, IAdaptable {
|
|
28 |
public class QueryCooccurrence extends TXMResult implements ICAComputable, IAdaptable {
|
|
30 | 29 |
|
31 | 30 |
protected Corpus corpus; |
32 | 31 |
protected int[][] coocs; |
... | ... | |
50 | 49 |
ArrayList<Query> queries1, ArrayList<String> names1, |
51 | 50 |
ArrayList<Query> queries2, ArrayList<String> names2, |
52 | 51 |
int dist, int minCooc, String struct) throws CqiClientException, RWorkspaceException { |
52 |
|
|
53 |
super(corpus); |
|
53 | 54 |
this.queries1 = queries1; |
54 | 55 |
this.names1 = names1; |
55 | 56 |
this.queries2 = queries2; |
... | ... | |
57 | 58 |
this.corpus = corpus; |
58 | 59 |
this.dist = dist; |
59 | 60 |
this.minCooc = minCooc; |
60 |
if (struct != null) |
|
61 |
this.struct = "within "+struct; |
|
62 |
else |
|
61 |
if (struct != null) { |
|
62 |
this.struct = "within "+struct; |
|
63 |
} |
|
64 |
else { |
|
63 | 65 |
this.struct = "within text"; |
66 |
} |
|
64 | 67 |
|
65 | 68 |
nNodes = queries1.size(); |
66 | 69 |
|
... | ... | |
84 | 87 |
} |
85 | 88 |
} |
86 | 89 |
|
90 |
@Override |
|
87 | 91 |
public String getName() { |
88 |
return corpus.getName()+ " d="+dist+ " min="+minCooc;
|
|
92 |
return corpus.getName() + " d=" + dist + " min=" + minCooc;
|
|
89 | 93 |
} |
90 | 94 |
|
91 |
public Corpus getParent() { |
|
92 |
return corpus; |
|
93 |
} |
|
94 |
|
|
95 | 95 |
public String getSymbol() { |
96 | 96 |
return symbol; |
97 | 97 |
} |
... | ... | |
184 | 184 |
org.txm.utils.logger.Log.printStackTrace(e); |
185 | 185 |
} |
186 | 186 |
LexicalTable table = this.toLexicalTable(); |
187 |
int fmin = table.getFmin();
|
|
187 |
int fmin = table.getFMin();
|
|
188 | 188 |
|
189 | 189 |
CA ca = new CA(table); |
190 | 190 |
ca.setParameters(analysisProperty, null, null); |
... | ... | |
251 | 251 |
} |
252 | 252 |
|
253 | 253 |
@Override |
254 |
public boolean validateParameters() {
|
|
254 |
public boolean canCompute() {
|
|
255 | 255 |
return corpus != null; |
256 | 256 |
} |
257 | 257 |
|
258 | 258 |
@Override |
259 |
public boolean compute(IProgressMonitor watcher) throws Exception { |
|
260 |
System.out.println("QueryCooccurrence.compute() not implemented"); |
|
259 |
public boolean setParameters(TXMParameters parameters) { |
|
260 |
//FIXME: not yet implemented. |
|
261 |
System.err.println("QueryCooccurrence.setParameters(): not yet implemented."); |
|
261 | 262 |
return false; |
262 | 263 |
} |
263 | 264 |
|
264 | 265 |
@Override |
265 |
public boolean setParameters(TXMParameters parameters) { |
|
266 |
public boolean saveParameters() throws Exception { |
|
267 |
//FIXME: not yet implemented. |
|
268 |
System.err.println("QueryCooccurrence.saveParameters(): not yet implemented."); |
|
266 | 269 |
return false; |
267 | 270 |
} |
271 |
|
|
272 |
@Override |
|
273 |
public boolean loadParameters() throws Exception { |
|
274 |
//FIXME: not yet implemented. |
|
275 |
System.err.println("QueryCooccurrence.loadParameters(): not yet implemented."); |
|
276 |
return false; |
|
277 |
} |
|
278 |
|
|
268 | 279 |
} |
Also available in: Unified diff