Révision 3207
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 3207) | ||
---|---|---|
206 | 206 |
|
207 | 207 |
try { |
208 | 208 |
|
209 |
this.setQuery(this.getStringParameterValue(ConcordancePreferences.QUERY));
|
|
209 |
this.pQuery = IQuery.fromPrefString(this.getStringParameterValue(ConcordancePreferences.QUERY));
|
|
210 | 210 |
|
211 | 211 |
this.setCQLSeparator(this.getCorpus().getCQLLimitQuery()); |
212 | 212 |
|
... | ... | |
1807 | 1807 |
public boolean saveParameters() { |
1808 | 1808 |
|
1809 | 1809 |
if (pQuery != null) { |
1810 |
this.saveParameter(ConcordancePreferences.QUERY, pQuery.getQueryString());
|
|
1810 |
this.saveParameter(ConcordancePreferences.QUERY, IQuery.toPrefString(pQuery));
|
|
1811 | 1811 |
} |
1812 | 1812 |
|
1813 | 1813 |
this.saveParameter(ConcordancePreferences.KEYWORD_VIEW_PROPERTIES, WordProperty.propertiesToString(this.pViewKeywordProperties)); |
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 3207) | ||
---|---|---|
393 | 393 |
this.saveParameter(TXMPreferences.UNIT_PROPERTIES, WordProperty.propertiesToString(pProperties)); |
394 | 394 |
|
395 | 395 |
if (pQuery != null) { |
396 |
this.saveParameter(TXMPreferences.QUERY, pQuery.getQueryString());
|
|
396 |
this.saveParameter(TXMPreferences.QUERY, IQuery.toPrefString(pQuery));
|
|
397 | 397 |
} |
398 | 398 |
|
399 | 399 |
return true; |
... | ... | |
402 | 402 |
@Override |
403 | 403 |
public boolean loadParameters() { |
404 | 404 |
this.pProperties = (List<WordProperty>) Property.stringToProperties(getCorpus(), this.getStringParameterValue(TXMPreferences.UNIT_PROPERTIES)); |
405 |
this.pQuery = new CQLQuery(this.getStringParameterValue(TXMPreferences.QUERY)); |
|
405 |
this.pQuery = IQuery.fromPrefString(this.getStringParameterValue(TXMPreferences.QUERY));//new CQLQuery(this.getStringParameterValue(TXMPreferences.QUERY));
|
|
406 | 406 |
return true; |
407 | 407 |
} |
408 | 408 |
|
tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java (revision 3207) | ||
---|---|---|
1 | 1 |
package org.txm.searchengine.core; |
2 | 2 |
|
3 |
import org.eclipse.osgi.util.NLS; |
|
4 |
|
|
5 |
import com.hp.hpl.jena.reasoner.IllegalParameterException; |
|
6 |
|
|
3 | 7 |
/** |
4 | 8 |
* Represent a search engine query |
5 | 9 |
* |
... | ... | |
36 | 40 |
public boolean equals(IQuery q); |
37 | 41 |
|
38 | 42 |
public String asString(); |
43 |
|
|
44 |
public static String toPrefString(IQuery query) { |
|
45 |
return query.getSearchEngine().getName()+"\t"+query.getQueryString(); |
|
46 |
} |
|
47 |
|
|
48 |
public static IQuery fromPrefString(String prefString) { |
|
49 |
|
|
50 |
String[] split = prefString.split("\t", 2); |
|
51 |
|
|
52 |
String engineName = null; |
|
53 |
String queryString = null; |
|
54 |
|
|
55 |
|
|
56 |
if (split.length == 2) { |
|
57 |
engineName = split[0]; |
|
58 |
queryString = split[1]; |
|
59 |
} else { |
|
60 |
engineName = "CQP"; |
|
61 |
queryString = split[0]; |
|
62 |
} |
|
63 |
|
|
64 |
SearchEngine se = SearchEnginesManager.getSearchEngine(engineName); |
|
65 |
if (se == null) { |
|
66 |
throw new IllegalParameterException(NLS.bind("No SearchEngine {0} found.", engineName)); |
|
67 |
} |
|
68 |
IQuery query = se.newQuery(); |
|
69 |
query.setQuery(queryString); |
|
70 |
return query; |
|
71 |
} |
|
39 | 72 |
} |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/editors/LineLabelProvider.java (revision 3207) | ||
---|---|---|
39 | 39 |
*/ |
40 | 40 |
public class LineLabelProvider implements ITableLabelProvider { |
41 | 41 |
|
42 |
Referencer referencer; |
|
43 |
|
|
44 |
public LineLabelProvider(Referencer referencer) { |
|
45 |
this.referencer = referencer; |
|
46 |
} |
|
47 |
|
|
42 | 48 |
/* (non-Javadoc) |
43 | 49 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
44 | 50 |
*/ |
... | ... | |
61 | 67 |
case 2: |
62 | 68 |
StringBuffer str = new StringBuffer(); |
63 | 69 |
for (String ref : line.getReferences()) { |
64 |
str.append(", "+ref+"("+line.getCount(ref)+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
70 |
if (this.referencer.getShowCounts()) { |
|
71 |
str.append(", "+ref+"("+line.getCount(ref)+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
72 |
} else { |
|
73 |
str.append(", "+ref); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
74 |
} |
|
65 | 75 |
} |
66 | 76 |
return str.substring(2); |
67 | 77 |
default: |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/editors/ReferencerEditor.java (revision 3207) | ||
---|---|---|
41 | 41 |
import org.eclipse.swt.graphics.Point; |
42 | 42 |
import org.eclipse.swt.layout.GridData; |
43 | 43 |
import org.eclipse.swt.layout.GridLayout; |
44 |
import org.eclipse.swt.widgets.Button; |
|
44 | 45 |
import org.eclipse.swt.widgets.Composite; |
45 | 46 |
import org.eclipse.swt.widgets.Display; |
46 | 47 |
import org.eclipse.swt.widgets.Label; |
... | ... | |
54 | 55 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
55 | 56 |
import org.txm.rcp.messages.TXMUIMessages; |
56 | 57 |
import org.txm.rcp.swt.GLComposite; |
58 |
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget; |
|
57 | 59 |
import org.txm.rcp.swt.widget.NavigationWidget; |
58 | 60 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
59 | 61 |
import org.txm.rcp.swt.widget.QueryWidget; |
... | ... | |
117 | 119 |
|
118 | 120 |
/** The querywidget. */ |
119 | 121 |
@Parameter(key = ReferencerPreferences.QUERY) |
120 |
protected QueryWidget querywidget; |
|
122 |
protected AssistedChoiceQueryWidget querywidget;
|
|
121 | 123 |
|
122 | 124 |
/** |
123 | 125 |
* Word property selector. |
... | ... | |
125 | 127 |
@Parameter(key = ReferencerPreferences.UNIT_PROPERTY) |
126 | 128 |
protected PropertiesSelector<Property> propertiesSelector; |
127 | 129 |
|
130 |
/** |
|
131 |
* Show counts button |
|
132 |
*/ |
|
133 |
@Parameter(key = ReferencerPreferences.SHOW_COUNTS) |
|
134 |
protected Button showCountsButton; |
|
135 |
|
|
128 | 136 |
/** The pattern area. */ |
129 | 137 |
@Parameter(key = ReferencerPreferences.PATTERN) |
130 | 138 |
protected PropertiesSelector<StructuralUnitProperty> patternArea; |
... | ... | |
152 | 160 |
queryLabel.setText(TXMUIMessages.ampQuery); |
153 | 161 |
queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
154 | 162 |
|
155 |
querywidget = new QueryWidget(getMainParametersComposite(), SWT.None);
|
|
163 |
querywidget = new AssistedChoiceQueryWidget(getMainParametersComposite(), SWT.None, this.corpus);
|
|
156 | 164 |
querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); |
157 | 165 |
querywidget.addKeyListener(computeKeyListener); |
158 | 166 |
|
... | ... | |
184 | 192 |
patternArea.setTitle(ReferencerUIMessages.referencePattern); |
185 | 193 |
patternArea.addSelectionListener(computeSelectionListener); |
186 | 194 |
|
195 |
// [show counts] |
|
196 |
showCountsButton = new Button(paramArea, SWT.CHECK); |
|
197 |
showCountsButton.setText("Show counts"); |
|
198 |
showCountsButton.setSelection(referencer.getShowCounts()); |
|
187 | 199 |
|
200 |
|
|
188 | 201 |
// pagination |
189 | 202 |
GLComposite navigationComposite = getBottomToolbar().installGLComposite("navigation", 1, false); |
190 | 203 |
navigationComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
... | ... | |
270 | 283 |
viewer.getTable().setLinesVisible(true); |
271 | 284 |
viewer.getTable().setHeaderVisible(true); |
272 | 285 |
|
273 |
viewer.setLabelProvider(new LineLabelProvider()); |
|
286 |
viewer.setLabelProvider(new LineLabelProvider(this.referencer));
|
|
274 | 287 |
viewer.setContentProvider(new LineContentProvider()); |
275 | 288 |
viewer.setInput(new ArrayList<Property>()); |
276 | 289 |
|
tmp/org.txm.referencer.core/src/org/txm/referencer/core/preferences/ReferencerPreferences.java (revision 3207) | ||
---|---|---|
14 | 14 |
|
15 | 15 |
public static final String SORT_BY_FREQUENCIES = "sort_by_frequencies"; //$NON-NLS-1$ |
16 | 16 |
public static final String PATTERN = "pattern"; //$NON-NLS-1$ |
17 |
public static final String SHOW_COUNTS = "show_counts"; |
|
17 | 18 |
|
18 | 19 |
|
19 | 20 |
/** |
... | ... | |
37 | 38 |
|
38 | 39 |
preferences.put(UNIT_PROPERTY, TXMPreferences.DEFAULT_UNIT_PROPERTY); //$NON-NLS-1$ |
39 | 40 |
preferences.put(PATTERN, "text_id"); //$NON-NLS-1$ |
41 |
preferences.putBoolean(SHOW_COUNTS, true); //$NON-NLS-1$ |
|
40 | 42 |
} |
41 | 43 |
} |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/functions/Referencer.java (revision 3207) | ||
---|---|---|
61 | 61 |
import org.txm.core.results.Parameter; |
62 | 62 |
import org.txm.core.results.TXMParameters; |
63 | 63 |
import org.txm.core.results.TXMResult; |
64 |
import org.txm.objects.Match; |
|
64 | 65 |
import org.txm.referencer.core.messages.ReferencerCoreMessages; |
65 | 66 |
import org.txm.referencer.core.preferences.ReferencerPreferences; |
67 |
import org.txm.searchengine.core.IQuery; |
|
68 |
import org.txm.searchengine.core.Query; |
|
69 |
import org.txm.searchengine.core.Selection; |
|
66 | 70 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
67 | 71 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
68 | 72 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
... | ... | |
71 | 75 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
72 | 76 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
73 | 77 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
74 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
75 | 78 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
79 |
//import org.txm.searchengine.cqp.corpus.query.Match; |
|
80 |
//import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
76 | 81 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
77 | 82 |
import org.txm.statsengine.r.core.RWorkspace; |
78 | 83 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
... | ... | |
100 | 105 |
List<Line> lines; |
101 | 106 |
|
102 | 107 |
/** The matches. */ |
103 |
List<Match> matches; |
|
108 |
List<? extends Match> matches;
|
|
104 | 109 |
|
105 | 110 |
/** The positions. */ |
106 | 111 |
int[] positions; |
... | ... | |
112 | 117 |
HashMap<Integer, Line> processedIdx; |
113 | 118 |
|
114 | 119 |
/** The result. */ |
115 |
QueryResult result;
|
|
120 |
Selection result;
|
|
116 | 121 |
|
117 | 122 |
/** The symbol. */ |
118 | 123 |
private String symbol; |
... | ... | |
137 | 142 |
|
138 | 143 |
/** The query. */ |
139 | 144 |
@Parameter(key = ReferencerPreferences.QUERY) |
140 |
protected CQLQuery pQuery; |
|
145 |
protected IQuery pQuery; |
|
146 |
|
|
147 |
/** The show counts boolean. */ |
|
148 |
@Parameter(key = ReferencerPreferences.SHOW_COUNTS) |
|
149 |
protected Boolean pShowCounts; |
|
141 | 150 |
|
142 |
|
|
143 | 151 |
/** |
144 | 152 |
* Creates a not computed referencer. |
145 | 153 |
* |
... | ... | |
238 | 246 |
return false; |
239 | 247 |
} |
240 | 248 |
} |
241 |
catch (CqiClientException e) { |
|
242 |
e.printStackTrace(); |
|
249 |
catch (Exception e) { |
|
250 |
Log.severe("** Error: "+e); |
|
251 |
Log.printStackTrace(e); |
|
243 | 252 |
return false; |
244 | 253 |
} |
245 | 254 |
|
... | ... | |
415 | 424 |
* |
416 | 425 |
* @return the query |
417 | 426 |
*/ |
418 |
public CQLQuery getQuery() {
|
|
427 |
public IQuery getQuery() {
|
|
419 | 428 |
return pQuery; |
420 | 429 |
} |
421 | 430 |
|
... | ... | |
446 | 455 |
* 1st step. |
447 | 456 |
* |
448 | 457 |
* @return the query matches |
449 |
* @throws CqiClientException
|
|
458 |
* @throws Exception
|
|
450 | 459 |
*/ |
451 |
public boolean getQueryMatches() throws CqiClientException { |
|
452 |
result = this.getCorpus().query(pQuery, ReferencerCoreMessages.RESULT_TYPE, false); |
|
460 |
public boolean getQueryMatches() throws Exception { |
|
461 |
|
|
462 |
result = pQuery.getSearchEngine().query(this.getCorpus(), pQuery, "TMP", false); |
|
463 |
|
|
464 |
// result = this.getCorpus().query(pQuery, ReferencerCoreMessages.RESULT_TYPE, false); |
|
453 | 465 |
if (result.getNMatch() == 0) { |
454 | 466 |
return false; |
455 | 467 |
} |
... | ... | |
501 | 513 |
return true; |
502 | 514 |
} |
503 | 515 |
|
504 |
public void setParameters(CQLQuery query, WordProperty prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) {
|
|
516 |
public void setParameters(IQuery query, WordProperty prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) {
|
|
505 | 517 |
if (query != null) this.pQuery = query; |
506 | 518 |
if (pattern != null) this.pPattern = pattern; |
507 | 519 |
if (prop != null) this.pProperty = prop; |
... | ... | |
576 | 588 |
|
577 | 589 |
@Override |
578 | 590 |
public boolean loadParameters() throws CqiClientException { |
579 |
this.pQuery = new CQLQuery(this.getStringParameterValue(ReferencerPreferences.QUERY)); |
|
591 |
|
|
592 |
this.pQuery = IQuery.fromPrefString(this.getStringParameterValue(ReferencerPreferences.QUERY));//new CQLQuery(this.getStringParameterValue(ReferencerPreferences.QUERY)); |
|
580 | 593 |
this.pPattern = StructuralUnitProperty.stringToProperties(this.getCorpus(), this.getStringParameterValue(ReferencerPreferences.PATTERN)); |
581 | 594 |
this.pProperty = this.getCorpus().getProperty(this.getStringParameterValue(ReferencerPreferences.UNIT_PROPERTY)); |
582 | 595 |
return true; |
... | ... | |
584 | 597 |
|
585 | 598 |
@Override |
586 | 599 |
public boolean saveParameters() { |
600 |
|
|
587 | 601 |
if (this.pQuery != null) { |
588 |
this.saveParameter(ReferencerPreferences.QUERY, this.pQuery.getQueryString());
|
|
602 |
this.saveParameter(ReferencerPreferences.QUERY, IQuery.toPrefString(pQuery));
|
|
589 | 603 |
} |
590 | 604 |
|
591 | 605 |
if (this.pPattern != null) { |
... | ... | |
734 | 748 |
} |
735 | 749 |
} |
736 | 750 |
|
737 |
public void setQuery(CQLQuery query) {
|
|
751 |
public void setQuery(Query query) { |
|
738 | 752 |
this.pQuery = query; |
739 | 753 |
} |
740 | 754 |
|
... | ... | |
779 | 793 |
return ReferencerCoreMessages.RESULT_TYPE; |
780 | 794 |
} |
781 | 795 |
|
796 |
public void setShowCounts(boolean showCounts) { |
|
797 |
|
|
798 |
pShowCounts = showCounts; |
|
799 |
} |
|
782 | 800 |
|
801 |
public boolean getShowCounts() { |
|
802 |
|
|
803 |
return pShowCounts; |
|
804 |
} |
|
783 | 805 |
} |
Formats disponibles : Unified diff