Révision 626
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/themes/highcharts/defaulttheme/renderers/ItemSelectionXYStepRenderer.java (revision 626) | ||
---|---|---|
462 | 462 |
super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); |
463 | 463 |
|
464 | 464 |
// force shape rendering because the XYStepRenderer doesn't manage it by default |
465 |
EntityCollection entities = null; |
|
466 |
if(info != null) { |
|
467 |
entities = info.getOwner().getEntityCollection(); |
|
468 |
} |
|
469 |
|
|
470 |
drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); |
|
465 |
// EntityCollection entities = null;
|
|
466 |
// if(info != null) {
|
|
467 |
// entities = info.getOwner().getEntityCollection();
|
|
468 |
// }
|
|
469 |
// |
|
470 |
// drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities);
|
|
471 | 471 |
} |
472 | 472 |
|
473 | 473 |
} |
tmp/org.txm.index.rcp/src/org/txm/index/rcp/adapters/IndexAdapterFactory.java (revision 626) | ||
---|---|---|
22 | 22 |
public static final ImageDescriptor ICON = |
23 | 23 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(IndexAdapterFactory.class).getSymbolicName(), |
24 | 24 |
"platform:/plugin/"+ FrameworkUtil.getBundle(IndexAdapterFactory.class).getSymbolicName() + "/icons/index.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
25 |
|
|
25 | 26 |
public static final ImageDescriptor LEXICON_ICON = |
26 | 27 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(IndexAdapterFactory.class).getSymbolicName(), |
27 | 28 |
"platform:/plugin/"+ FrameworkUtil.getBundle(IndexAdapterFactory.class).getSymbolicName() + "/icons/lexicon.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 626) | ||
---|---|---|
675 | 675 |
paramArea.pack(); |
676 | 676 |
initializeFields(); |
677 | 677 |
|
678 |
createContextMenu(viewer); |
|
678 |
// Register the context menu |
|
679 |
TXMEditorPart.initContextMenu(this.viewer.getTable(), "IndexEditorContextMenu", this.getSite(), this.viewer); // $NON-NLS-1$ |
|
680 |
|
|
679 | 681 |
viewer.getTable().pack(); |
680 | 682 |
parent.layout(true); |
681 | 683 |
} |
... | ... | |
703 | 705 |
return 2; |
704 | 706 |
} |
705 | 707 |
|
706 |
/** |
|
707 |
* Creates the context menu. |
|
708 |
* |
|
709 |
* @param tableViewer the table viewer |
|
710 |
*/ |
|
711 |
private void createContextMenu(TableViewer tableViewer) { |
|
712 |
MenuManager menuManager = new MenuManager(); |
|
713 |
Menu menu = menuManager.createContextMenu(tableViewer.getTable()); |
|
714 |
tableViewer.getTable().setMenu(menu); |
|
715 |
getSite().registerContextMenu(menuManager, tableViewer); |
|
716 |
getSite().setSelectionProvider(tableViewer); |
|
717 |
} |
|
718 | 708 |
|
709 |
|
|
719 | 710 |
boolean initializing = false; // prevent properties widget listener to activate when adding new properties (and refresh the result) |
720 | 711 |
/** |
721 | 712 |
* Initialize fields. |
tmp/org.txm.index.rcp/plugin.xml (revision 626) | ||
---|---|---|
96 | 96 |
</visibleWhen> |
97 | 97 |
</command> |
98 | 98 |
</menuContribution> |
99 |
<menuContribution |
|
100 |
locationURI="popup:IndexEditorContextMenu"> |
|
101 |
<command |
|
102 |
commandId="org.txm.rcp.commands.link.ToConcordance" |
|
103 |
style="push"> |
|
104 |
</command> |
|
105 |
<command |
|
106 |
commandId="org.txm.rcp.commands.link.IndexToCooccurrence" |
|
107 |
style="push"> |
|
108 |
</command> |
|
109 |
<command |
|
110 |
commandId="org.txm.rcp.commands.link.ToProgression" |
|
111 |
style="push"> |
|
112 |
</command> |
|
113 |
</menuContribution> |
|
114 |
|
|
99 | 115 |
</extension> |
100 | 116 |
<extension |
101 | 117 |
point="org.eclipse.ui.editors"> |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/DiagnosticEditor.java (revision 626) | ||
---|---|---|
28 | 28 |
@Override |
29 | 29 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
30 | 30 |
super.init(site, input); |
31 |
if (getResultData() instanceof Diagnostic)
|
|
32 |
this.diag = (Diagnostic) getResultData();
|
|
31 |
if (getResult() instanceof Diagnostic) |
|
32 |
this.diag = (Diagnostic) getResult(); |
|
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
@Override |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java (revision 626) | ||
---|---|---|
624 | 624 |
subcorpus.dropAllSubcorpora(); |
625 | 625 |
subcorpus.dropAllPartitions(); |
626 | 626 |
try { |
627 |
CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus( |
|
628 |
subcorpus.getQualifiedCqpId()); |
|
627 |
CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(subcorpus.getQualifiedCqpId()); |
|
629 | 628 |
} catch (Exception e) { |
630 | 629 |
throw new CqiClientException(e); |
631 | 630 |
} |
... | ... | |
899 | 898 |
* @return the structural unit properties |
900 | 899 |
* @throws CqiClientException the cqi client exception |
901 | 900 |
*/ |
902 |
public List<StructuralUnitProperty> getStructuralUnitProperties() |
|
903 |
throws CqiClientException { |
|
901 |
public List<StructuralUnitProperty> getStructuralUnitProperties() throws CqiClientException { |
|
904 | 902 |
if (this.structuralUnits == null) |
905 | 903 |
getStructuralUnits(); |
906 | 904 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java (revision 626) | ||
---|---|---|
50 | 50 |
/** The values for this property corpus */ |
51 | 51 |
List<String> values; |
52 | 52 |
|
53 |
/** The strucutral unit. */
|
|
53 |
/** The structural unit. */
|
|
54 | 54 |
private StructuralUnit structuralUnit; |
55 | 55 |
|
56 | 56 |
public static List<StructuralUnitProperty> stringToStructuralUnitProperties(Corpus corpus, String v) { |
... | ... | |
78 | 78 |
return structs; |
79 | 79 |
} |
80 | 80 |
|
81 |
|
|
81 | 82 |
/** |
83 |
* |
|
84 |
* @param corpus |
|
85 |
* @param s the String to 'deserialize'. Each property is separated with 1 tabulation. Then calls fromString on each token |
|
86 |
* @return a list of StructuralUnitProperty if the s param is well formed |
|
87 |
* @throws CqiClientException |
|
88 |
*/ |
|
89 |
public static List<StructuralUnitProperty> fromStringToList(Corpus corpus, String s) { |
|
90 |
ArrayList<StructuralUnitProperty> properties = new ArrayList<StructuralUnitProperty>(); |
|
91 |
if (s == null) return properties; |
|
92 |
|
|
93 |
String[] split = s.split("\t"); |
|
94 |
for (String s2 : split) { |
|
95 |
try { |
|
96 |
StructuralUnitProperty sup = fromString(corpus, s2); |
|
97 |
if (sup != null) { |
|
98 |
properties.add(sup); |
|
99 |
} |
|
100 |
} catch (Exception e) { |
|
101 |
e.printStackTrace(); |
|
102 |
} |
|
103 |
} |
|
104 |
return properties; |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
/** |
|
82 | 109 |
* Instantiates a new structural unit property. |
83 | 110 |
* |
84 | 111 |
* Not intended to be used directly. See |
... | ... | |
88 | 115 |
* @param corpus the corpus |
89 | 116 |
* {@link StructuralUnit#getProperty(String)} |
90 | 117 |
*/ |
91 |
public StructuralUnitProperty(StructuralUnit structuralUnit, |
|
92 |
String name, Corpus corpus) { |
|
118 |
public StructuralUnitProperty(StructuralUnit structuralUnit, String name, Corpus corpus) { |
|
93 | 119 |
super(name, corpus); |
94 | 120 |
this.structuralUnit = structuralUnit; |
95 | 121 |
} |
... | ... | |
251 | 277 |
return null; |
252 | 278 |
} |
253 | 279 |
|
254 |
/** |
|
255 |
* |
|
256 |
* @param corpus |
|
257 |
* @param s the String to 'deserialize'. Each property is separated with 1 tabulation. Then calls fromString on each token |
|
258 |
* @return a list of StructuralUnitProperty if the s param is well formed |
|
259 |
* @throws CqiClientException |
|
260 |
*/ |
|
261 |
public static List<StructuralUnitProperty> fromStringToList(Corpus corpus, String s) { |
|
262 |
ArrayList<StructuralUnitProperty> properties = new ArrayList<StructuralUnitProperty>(); |
|
263 |
if (s == null) return properties; |
|
264 | 280 |
|
265 |
String[] split = s.split("\t"); |
|
266 |
for (String s2 : split) { |
|
267 |
try { |
|
268 |
StructuralUnitProperty sup = fromString(corpus, s2); |
|
269 |
if (sup != null) { |
|
270 |
properties.add(sup); |
|
271 |
} |
|
272 |
} catch (Exception e) { |
|
273 |
e.printStackTrace(); |
|
274 |
} |
|
275 |
} |
|
276 |
return properties; |
|
277 |
} |
|
278 | 281 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Property.java (revision 626) | ||
---|---|---|
114 | 114 |
*/ |
115 | 115 |
@Override |
116 | 116 |
public int compareTo(Property p) { |
117 |
return (this.getQualifiedName().compareTo( |
|
118 |
(p).getQualifiedName())); |
|
117 |
return (this.getQualifiedName().compareTo((p).getQualifiedName())); |
|
119 | 118 |
} |
120 | 119 |
} |
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/CAUIMessages.java (revision 626) | ||
---|---|---|
5 | 5 |
|
6 | 6 |
public class CAUIMessages extends Utf8NLS { |
7 | 7 |
|
8 |
|
|
9 |
private static final String BUNDLE_NAME = "org.txm.ca.rcp.messages.messages"; //$NON-NLS-1$ |
|
10 |
|
|
8 | 11 |
static { |
9 | 12 |
Utf8NLS.initializeMessages(CAUIMessages.class); |
10 | 13 |
} |
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 626) | ||
---|---|---|
175 | 175 |
((ToolItem) e.getSource()).setSelection(true); |
176 | 176 |
return; |
177 | 177 |
} |
178 |
getResultData().setShowIndividuals(((ToolItem) e.getSource()).getSelection());
|
|
178 |
getResult().setShowIndividuals(((ToolItem) e.getSource()).getSelection()); |
|
179 | 179 |
} |
180 | 180 |
//Show/hide rows |
181 | 181 |
else if(e.getSource() == showVariables) { |
... | ... | |
186 | 186 |
return; |
187 | 187 |
} |
188 | 188 |
|
189 |
getResultData().setShowVariables(((ToolItem) e.getSource()).getSelection());
|
|
189 |
getResult().setShowVariables(((ToolItem) e.getSource()).getSelection()); |
|
190 | 190 |
} |
191 | 191 |
//Show/hide rows |
192 | 192 |
else if(e.getSource() == showPointShapes) { |
193 |
getResultData().setShowPointShapes(((ToolItem) e.getSource()).getSelection());
|
|
193 |
getResult().setShowPointShapes(((ToolItem) e.getSource()).getSelection()); |
|
194 | 194 |
} |
195 | 195 |
// Change factors |
196 | 196 |
else if(e.getSource() == plansCombo) { |
... | ... | |
212 | 212 |
dimension2 = Integer.parseInt(split[1]); |
213 | 213 |
|
214 | 214 |
// FIXME: persistence |
215 |
getResultData().setFirstDimension(dimension1);
|
|
216 |
getResultData().setSecondDimension(dimension2);
|
|
215 |
getResult().setFirstDimension(dimension1); |
|
216 |
getResult().setSecondDimension(dimension2); |
|
217 | 217 |
|
218 | 218 |
resetView = true; |
219 | 219 |
} |
220 |
getResultData().setChartDirty();
|
|
221 |
getResultData().setNeedsToResetView(resetView);
|
|
220 |
getResult().setChartDirty(); |
|
221 |
getResult().setNeedsToResetView(resetView); |
|
222 | 222 |
compute(true); |
223 | 223 |
// synchronize the part names |
224 |
((CAEditor)getParentMultiPagesEditor()).setName(getResultData().getName());
|
|
224 |
((CAEditor)getParentMultiPagesEditor()).setName(getResult().getName()); |
|
225 | 225 |
forceFocus(); |
226 | 226 |
} |
227 | 227 |
|
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 626) | ||
---|---|---|
38 | 38 |
import org.txm.ca.core.functions.CA; |
39 | 39 |
import org.txm.ca.rcp.editors.CAEditor; |
40 | 40 |
import org.txm.ca.rcp.messages.CAUIMessages; |
41 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
42 |
import org.txm.core.results.TXMResult; |
|
43 | 41 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
44 |
import org.txm.lexicaltable.core.functions.___LexicalTableFactory; |
|
45 | 42 |
import org.txm.lexicaltable.rcp.editors.LexicalTableDialog; |
46 | 43 |
import org.txm.rcp.RCPMessages; |
47 | 44 |
import org.txm.rcp.StatusLine; |
... | ... | |
112 | 109 |
|
113 | 110 |
Log.info(NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition, property)); |
114 | 111 |
|
115 |
//LexicalTable lexicalTable = LexicalTableFactory.getLexicalTable(partition, property, fMin); |
|
116 | 112 |
LexicalTable lexicalTable = new LexicalTable(partition, property, fMin, vMax); |
117 | 113 |
ca = new CA(lexicalTable); |
118 | 114 |
} |
tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/views/RVariablesView.java (revision 626) | ||
---|---|---|
64 | 64 |
import org.txm.concordance.core.functions.Concordance; |
65 | 65 |
import org.txm.cooccurrence.core.functions.Cooccurrence; |
66 | 66 |
import org.txm.core.results.TXMResult; |
67 |
import org.txm.functions.referencer.Referencer; |
|
68 | 67 |
import org.txm.index.core.functions.Index; |
69 | 68 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
70 | 69 |
import org.txm.lexicon.core.functions.Lexicon; |
... | ... | |
74 | 73 |
import org.txm.rcp.RCPMessages; |
75 | 74 |
import org.txm.rcp.commands.EditFile; |
76 | 75 |
import org.txm.rcp.commands.R.CopySelection; |
76 |
import org.txm.referencer.core.functions.Referencer; |
|
77 | 77 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
78 | 78 |
import org.txm.searchengine.cqp.corpus.Corpus; |
79 | 79 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/preferences/RPreferencePage.java (revision 626) | ||
---|---|---|
143 | 143 |
changeFieldStates(TXMPreferences.getBoolean(RPreferences.REMOTE, RPreferences.PREFERENCES_NODE)); |
144 | 144 |
|
145 | 145 |
|
146 |
addField(new BooleanFieldEditor(RPreferences.SHOW_EVAL_LOGS, "Log the R eval command lines.", getFieldEditorParent()));
|
|
146 |
addField(new BooleanFieldEditor(RPreferences.SHOW_EVAL_LOGS, "Log the R eval command lines", getFieldEditorParent())); |
|
147 | 147 |
|
148 | 148 |
} |
149 | 149 |
|
tmp/org.txm.referencer.core/plugin.xml (revision 626) | ||
---|---|---|
4 | 4 |
<extension |
5 | 5 |
point="org.eclipse.core.runtime.preferences"> |
6 | 6 |
<initializer |
7 |
class="org.txm.functions.referencer.ReferencerPreferences">
|
|
7 |
class="org.txm.referencer.core.preferences.ReferencerPreferences">
|
|
8 | 8 |
</initializer> |
9 | 9 |
</extension> |
10 | 10 |
|
tmp/org.txm.referencer.core/META-INF/MANIFEST.MF (revision 626) | ||
---|---|---|
9 | 9 |
org.txm.core;bundle-version="0.7.0", |
10 | 10 |
org.txm.searchengine.core;bundle-version="1.0.0", |
11 | 11 |
org.txm.searchengine.cqp.core;bundle-version="1.1.0" |
12 |
Export-Package: org.txm.functions.referencer |
|
12 |
Export-Package: org.txm.referencer.core.functions, |
|
13 |
org.txm.referencer.core.preferences |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/preferences/ReferencerPreferences.java (revision 626) | ||
---|---|---|
1 |
package org.txm.referencer.core.preferences; |
|
2 |
|
|
3 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
|
4 |
import org.osgi.framework.FrameworkUtil; |
|
5 |
import org.osgi.service.prefs.Preferences; |
|
6 |
import org.txm.core.preferences.TXMPreferences; |
|
7 |
|
|
8 |
public class ReferencerPreferences extends TXMPreferences { |
|
9 |
|
|
10 |
public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(ReferencerPreferences.class).getSymbolicName(); |
|
11 |
|
|
12 |
/** The Constant SORTBYFREQ. */ |
|
13 |
//FIXME: to extract to referencer plug-in |
|
14 |
public static final String SORT_BY_FREQ = "sorttype"; //$NON-NLS-1$ |
|
15 |
|
|
16 |
public static final String QUERY = "query"; //$NON-NLS-1$ |
|
17 |
public static final String PROPERTY = "property"; //$NON-NLS-1$ |
|
18 |
public static final String PATTERN = "pattern"; //$NON-NLS-1$ |
|
19 |
|
|
20 |
@Override |
|
21 |
public void initializeDefaultPreferences() { |
|
22 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
|
23 |
|
|
24 |
preferences.putBoolean(SORT_BY_FREQ, false); //$NON-NLS-1$ |
|
25 |
|
|
26 |
preferences.put(QUERY, ""); //$NON-NLS-1$ |
|
27 |
preferences.put(PROPERTY, "word"); //$NON-NLS-1$ |
|
28 |
preferences.put(PATTERN, "text_id"); //$NON-NLS-1$ |
|
29 |
} |
|
30 |
} |
|
0 | 31 |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/functions/Referencer.java (revision 626) | ||
---|---|---|
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 |
// This file is part of the TXM platform. |
|
24 |
// |
|
25 |
// The TXM platform is free software: you can redistribute it and/or modif y |
|
26 |
// it under the terms of the GNU General Public License as published by |
|
27 |
// the Free Software Foundation, either version 3 of the License, or |
|
28 |
// (at your option) any later version. |
|
29 |
// |
|
30 |
// The TXM platform is distributed in the hope that it will be useful, |
|
31 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
// GNU General Public License for more details. |
|
34 |
// |
|
35 |
// You should have received a copy of the GNU General Public License |
|
36 |
// along with the TXM platform. If not, see <http://www.gnu.org/licenses/>. |
|
37 |
// |
|
38 |
// |
|
39 |
// |
|
40 |
// $LastChangedDate: 2016-11-29 16:47:07 +0100 (Tue, 29 Nov 2016) $ |
|
41 |
// $LastChangedRevision: 3349 $ |
|
42 |
// $LastChangedBy: mdecorde $ |
|
43 |
// |
|
44 |
package org.txm.referencer.core.functions; |
|
45 |
|
|
46 |
import java.io.BufferedWriter; |
|
47 |
import java.io.File; |
|
48 |
import java.io.FileOutputStream; |
|
49 |
import java.io.IOException; |
|
50 |
import java.io.OutputStreamWriter; |
|
51 |
import java.io.Writer; |
|
52 |
import java.util.ArrayList; |
|
53 |
import java.util.Collections; |
|
54 |
import java.util.Comparator; |
|
55 |
import java.util.HashMap; |
|
56 |
import java.util.List; |
|
57 |
import java.util.Map; |
|
58 |
|
|
59 |
import org.txm.core.messages.TXMCoreMessages; |
|
60 |
import org.txm.core.results.Parameter; |
|
61 |
import org.txm.core.results.TXMParameters; |
|
62 |
import org.txm.core.results.TXMResult; |
|
63 |
import org.txm.referencer.core.preferences.ReferencerPreferences; |
|
64 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
65 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
66 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
67 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
|
68 |
import org.txm.searchengine.cqp.corpus.Property; |
|
69 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
|
70 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
71 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
72 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
73 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
|
74 |
import org.txm.statsengine.r.core.RWorkspace; |
|
75 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
|
76 |
import org.txm.utils.logger.Log; |
|
77 |
|
|
78 |
/** |
|
79 |
* The Class Referencer computes the references of a query |
|
80 |
*/ |
|
81 |
public class Referencer extends TXMResult { |
|
82 |
|
|
83 |
/** The noref. */ |
|
84 |
protected static int noref = 1; |
|
85 |
|
|
86 |
/** The prefix r. */ |
|
87 |
protected static String prefixR = "Referencer"; //$NON-NLS-1$ |
|
88 |
|
|
89 |
/** The indexes. */ |
|
90 |
int[] indexes; |
|
91 |
|
|
92 |
/** The lines. */ |
|
93 |
List<Line> lines; |
|
94 |
|
|
95 |
/** The cache. */ |
|
96 |
//private Map<Property, CqpDataProxy> cache; |
|
97 |
|
|
98 |
/** The matches. */ |
|
99 |
List<Match> matches; |
|
100 |
|
|
101 |
/** The positions. */ |
|
102 |
int[] positions; |
|
103 |
|
|
104 |
/** The nlines. */ |
|
105 |
int nlines; |
|
106 |
|
|
107 |
/** The processed idx. */ |
|
108 |
HashMap<Integer, Line> processedIdx; |
|
109 |
|
|
110 |
/** The result. */ |
|
111 |
QueryResult result; |
|
112 |
|
|
113 |
/** The symbol. */ |
|
114 |
private String symbol; |
|
115 |
|
|
116 |
/** The writer. */ |
|
117 |
private BufferedWriter writer; |
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
/** The hierarchic sort. */ |
|
124 |
@Parameter(key=ReferencerPreferences.SORT_BY_FREQ) |
|
125 |
private boolean pHierarchicSort; |
|
126 |
|
|
127 |
@Parameter |
|
128 |
List<StructuralUnitProperty> pPattern; |
|
129 |
|
|
130 |
/** The prop. */ |
|
131 |
@Parameter |
|
132 |
Property pProperty; |
|
133 |
|
|
134 |
/** The query. */ |
|
135 |
@Parameter |
|
136 |
Query pQuery; |
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
/** |
|
143 |
* Instantiates a new referencer. |
|
144 |
* |
|
145 |
* @param corpus the corpus |
|
146 |
* @param pQuery the query |
|
147 |
* @param pProperty the prop |
|
148 |
* @param pPattern the pattern |
|
149 |
* @param pHierarchicSort the hierarchic sort |
|
150 |
*/ |
|
151 |
public Referencer(Corpus corpus) { |
|
152 |
super(corpus); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* As r matrix. |
|
157 |
* |
|
158 |
* @return the string |
|
159 |
* @throws RWorkspaceException the r workspace exception |
|
160 |
*/ |
|
161 |
public String asRMatrix() throws RWorkspaceException { |
|
162 |
|
|
163 |
String keywords[] = new String[lines.size()]; |
|
164 |
for(int i = 0 ; i < lines.size() ; i++) |
|
165 |
keywords[i] = lines.get(i).getPropValue(); |
|
166 |
//System.out.println(Arrays.toString(keywords)); |
|
167 |
|
|
168 |
String symbol = prefixR+noref; |
|
169 |
|
|
170 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
|
171 |
rw.eval(symbol+" <- list()"); //$NON-NLS-1$ |
|
172 |
rw.addVectorToWorkspace("refkeywords", keywords); //$NON-NLS-1$ |
|
173 |
rw.eval(symbol+"$keywords <- refkeywords"); //$NON-NLS-1$ |
|
174 |
//rw.eval(symbol+"$query <- \""+this.query.getQueryString()+"\")"); |
|
175 |
rw.eval(symbol+"$refs <- list()"); //$NON-NLS-1$ |
|
176 |
int i = 1; |
|
177 |
for (Line line : this.lines) { |
|
178 |
String refs[] = line.getReferences().toArray(new String[line.getReferences().size()]); |
|
179 |
//System.out.println(line.getPropValue()+": "+Arrays.toString(refs)); |
|
180 |
rw.addVectorToWorkspace("reflinerefs", refs); //$NON-NLS-1$ |
|
181 |
rw.eval(symbol+"$refs[["+i+"]] <- reflinerefs"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
182 |
i++; |
|
183 |
} |
|
184 |
|
|
185 |
noref++; |
|
186 |
this.symbol = symbol; |
|
187 |
return symbol; |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void clean() { |
|
192 |
try { |
|
193 |
if (this.writer != null) { |
|
194 |
this.writer.flush(); |
|
195 |
this.writer.close(); |
|
196 |
} |
|
197 |
} catch (IOException e) { |
|
198 |
// TODO Auto-generated catch block |
|
199 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* Clear all lines. |
|
205 |
*/ |
|
206 |
public void clearAllLines() |
|
207 |
{ |
|
208 |
for(Line line : lines) { // we need to recompute lines' references |
|
209 |
line.clear(); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Call in order all stages to compute the referencer. |
|
215 |
* |
|
216 |
* @return true, if successful |
|
217 |
*/ |
|
218 |
protected boolean _compute() { |
|
219 |
try { |
|
220 |
if (!getQueryMatches()) |
|
221 |
return false; |
|
222 |
|
|
223 |
if (!getQueryindexes()) |
|
224 |
return false; |
|
225 |
|
|
226 |
if (!groupPositionsbyId()) |
|
227 |
return false; |
|
228 |
} |
|
229 |
catch(CqiClientException e) { |
|
230 |
e.printStackTrace(); |
|
231 |
return false; |
|
232 |
} |
|
233 |
|
|
234 |
return true; |
|
235 |
} |
|
236 |
|
|
237 |
/** |
|
238 |
* Gets the parent corpus. |
|
239 |
* |
|
240 |
* @return the corpus |
|
241 |
*/ |
|
242 |
public Corpus getCorpus() { |
|
243 |
return (Corpus) this.parent; |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public String getDetails() { |
|
248 |
return getCorpus().getName(); |
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* Gets the lines. |
|
253 |
* |
|
254 |
* @return the lines |
|
255 |
* @throws CqiClientException the cqi client exception |
|
256 |
* @throws IOException Signals that an I/O exception has occurred. |
|
257 |
* @throws CqiServerError the cqi server error |
|
258 |
*/ |
|
259 |
public List<Line> getLines() throws CqiClientException, IOException, CqiServerError |
|
260 |
{ |
|
261 |
return getLines(0,lines.size()); |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* Gets the lines. |
|
266 |
* |
|
267 |
* @param from the from |
|
268 |
* @param to the to |
|
269 |
* @return the lines |
|
270 |
* @throws CqiClientException the cqi client exception |
|
271 |
* @throws IOException Signals that an I/O exception has occurred. |
|
272 |
* @throws CqiServerError the cqi server error |
|
273 |
*/ |
|
274 |
public List<Line> getLines(int from, int to) throws CqiClientException, IOException, CqiServerError |
|
275 |
{ |
|
276 |
if (from < 0) |
|
277 |
from = 0; |
|
278 |
if (to > lines.size()) |
|
279 |
to = lines.size(); |
|
280 |
|
|
281 |
HashMap<Integer, Line> lineswithoutpropvalue = new HashMap<Integer, Line>(); |
|
282 |
|
|
283 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
|
284 |
//build Missing lines |
|
285 |
for(int i = from ; i < to ; i++)// for each position group |
|
286 |
{ |
|
287 |
Line l = lines.get(i); |
|
288 |
if (l.notcomputed) { |
|
289 |
lineswithoutpropvalue.put(l.id, l); |
|
290 |
|
|
291 |
// get all reference values of all position of the line |
|
292 |
Map<Property, List<List<String>>> refValues = new HashMap<Property, List<List<String>>>(); |
|
293 |
for (Property property : pPattern) { |
|
294 |
refValues.put(property, cqiClient.getData(property, |
|
295 |
l.positions, Collections.nCopies(l.positions.size(), 1))); |
|
296 |
} |
|
297 |
|
|
298 |
for (int j = 0 ; j < l.positions.size() ; j++)// build the Reference object |
|
299 |
{ |
|
300 |
String propvalue = ""; //$NON-NLS-1$ |
|
301 |
for (Property property : pPattern) { |
|
302 |
propvalue += refValues.get(property).get(j).get(0)+", "; //$NON-NLS-1$ |
|
303 |
} |
|
304 |
|
|
305 |
l.addReference(propvalue.substring(0, propvalue.length()-2)); |
|
306 |
} |
|
307 |
if (pHierarchicSort) |
|
308 |
l.sortRef(true); |
|
309 |
else |
|
310 |
l.sortAlpha(); |
|
311 |
l.notcomputed = false; |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
// get idx String value |
|
316 |
int[] idxwithoutvalues = new int[lineswithoutpropvalue.keySet().size()]; |
|
317 |
int count = 0; |
|
318 |
for(int i : lineswithoutpropvalue.keySet()) { |
|
319 |
idxwithoutvalues[count++] = i; |
|
320 |
} |
|
321 |
|
|
322 |
String[] values = CorpusManager.getCorpusManager().getCqiClient().id2Str(pProperty.getQualifiedName(), idxwithoutvalues); |
|
323 |
for(int i = 0 ; i < values.length ; i++) { |
|
324 |
int id = idxwithoutvalues[i]; |
|
325 |
lineswithoutpropvalue.get(id).linepropvalue = values[i]; |
|
326 |
} |
|
327 |
return lines.subList(from, to); |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* Gets the name. |
|
332 |
* |
|
333 |
* @return the name |
|
334 |
*/ |
|
335 |
public String getName() { |
|
336 |
return getCorpus().getName() + ": " + pQuery; //$NON-NLS-1$ |
|
337 |
} |
|
338 |
|
|
339 |
/** |
|
340 |
* Gets the n lines. |
|
341 |
* |
|
342 |
* @return the n lines |
|
343 |
*/ |
|
344 |
public int getNLines() { |
|
345 |
return nlines; |
|
346 |
} |
|
347 |
|
|
348 |
/** |
|
349 |
* Gets the pattern. |
|
350 |
* |
|
351 |
* @return the pattern |
|
352 |
*/ |
|
353 |
public List<StructuralUnitProperty> getPattern() { |
|
354 |
return pPattern; |
|
355 |
} |
|
356 |
|
|
357 |
/** |
|
358 |
* Gets the property. |
|
359 |
* |
|
360 |
* @return the property |
|
361 |
*/ |
|
362 |
public Property getProperty() { |
|
363 |
return pProperty; |
|
364 |
} |
|
365 |
|
|
366 |
/** |
|
367 |
* Gets the query. |
|
368 |
* |
|
369 |
* @return the query |
|
370 |
*/ |
|
371 |
public Query getQuery() { |
|
372 |
return pQuery; |
|
373 |
} |
|
374 |
|
|
375 |
/** |
|
376 |
* 2nd step. |
|
377 |
* |
|
378 |
* @return the queryindexes |
|
379 |
*/ |
|
380 |
public boolean getQueryindexes(){ |
|
381 |
try { |
|
382 |
positions = new int[matches.size()]; |
|
383 |
int i = 0; |
|
384 |
for (Match m : matches) { |
|
385 |
positions[i++] = m.getStart(); |
|
386 |
} |
|
387 |
|
|
388 |
indexes = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(pProperty.getQualifiedName(),positions); |
|
389 |
} catch (Exception e) { |
|
390 |
// TODO Auto-generated catch block |
|
391 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
392 |
return false; |
|
393 |
} |
|
394 |
return true; |
|
395 |
} |
|
396 |
|
|
397 |
/** |
|
398 |
* 1st step. |
|
399 |
* |
|
400 |
* @return the query matches |
|
401 |
* @throws CqiClientException |
|
402 |
*/ |
|
403 |
public boolean getQueryMatches() throws CqiClientException{ |
|
404 |
|
|
405 |
result = this.getCorpus().query(pQuery, TXMCoreMessages.Referencer_1, false); |
|
406 |
if (result.getNMatch() == 0) |
|
407 |
return false; |
|
408 |
matches = result.getMatches(); |
|
409 |
result.drop(); |
|
410 |
return true; |
|
411 |
} |
|
412 |
|
|
413 |
@Override |
|
414 |
public String getSimpleName() { |
|
415 |
if (pQuery != null) { |
|
416 |
return pQuery.toString(); |
|
417 |
} |
|
418 |
else { |
|
419 |
return getName(); |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
423 |
/** |
|
424 |
* Gets the symbol. |
|
425 |
* |
|
426 |
* @return the symbol |
|
427 |
*/ |
|
428 |
public String getSymbol() { |
|
429 |
return symbol; |
|
430 |
} |
|
431 |
|
|
432 |
public int getV() { |
|
433 |
if (matches == null) { |
|
434 |
return 0; |
|
435 |
} |
|
436 |
return matches.size(); |
|
437 |
} |
|
438 |
|
|
439 |
/** |
|
440 |
* 3rd stage. |
|
441 |
* |
|
442 |
* @return true, if successful |
|
443 |
*/ |
|
444 |
public boolean groupPositionsbyId() { |
|
445 |
processedIdx = new HashMap<Integer, Line>(); |
|
446 |
|
|
447 |
lines = new ArrayList<Line>(); |
|
448 |
//System.out.println("indexes "); |
|
449 |
for (int i = 0 ; i < indexes.length ; i++) { |
|
450 |
int id = indexes[i]; |
|
451 |
//System.out.print(" "+id); |
|
452 |
if (!processedIdx.containsKey(id)) { |
|
453 |
//System.out.println("add idx "+id); |
|
454 |
Line l = new Line(id); |
|
455 |
processedIdx.put(id, l); |
|
456 |
|
|
457 |
lines.add(l); |
|
458 |
} |
|
459 |
processedIdx.get(id).addPosition(positions[i]); |
|
460 |
} |
|
461 |
|
|
462 |
nlines = processedIdx.keySet().size(); |
|
463 |
return true; |
|
464 |
} |
|
465 |
|
|
466 |
public void setParameters(Query query, Property prop, List<StructuralUnitProperty> pattern, Boolean hierarchicSort) { |
|
467 |
if (query != null) this.pQuery = query; |
|
468 |
if (pattern != null) this.pPattern = pattern; |
|
469 |
if (prop != null) this.pProperty = prop; |
|
470 |
if (hierarchicSort != null) this.pHierarchicSort = hierarchicSort; |
|
471 |
dirty = true; |
|
472 |
} |
|
473 |
|
|
474 |
@Override |
|
475 |
public boolean setParameters(TXMParameters parameters) { |
|
476 |
return false; |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
480 |
* Write all the lines in a file. |
|
481 |
* |
|
482 |
* @param outfile the outfile |
|
483 |
* @param encoding the encoding |
|
484 |
* @return true, if successful |
|
485 |
*/ |
|
486 |
public boolean toTxt(File outfile, String encoding) { |
|
487 |
|
|
488 |
return toTxt(outfile, encoding, "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
489 |
} |
|
490 |
|
|
491 |
/** |
|
492 |
* Write all the lines in a file. |
|
493 |
* |
|
494 |
* @param outfile the outfile |
|
495 |
* @param encoding the encoding |
|
496 |
* @param colseparator the colseparator |
|
497 |
* @param txtseparator the txtseparator |
|
498 |
* @return true, if successful |
|
499 |
*/ |
|
500 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) { |
|
501 |
try { |
|
502 |
// NK: writer declared as class attribute to perform a clean if the operation is interrupted |
|
503 |
this.writer = new BufferedWriter(new OutputStreamWriter( |
|
504 |
new FileOutputStream(outfile), encoding)); |
|
505 |
// if ("UTF-8".equals(encoding)) writer.write('\ufeff'); // UTF-8 BOM |
|
506 |
toTxt(writer, 0, lines.size() - 1, colseparator, txtseparator); |
|
507 |
} catch (Exception e) { |
|
508 |
System.err.println(TXMCoreMessages.Referencer_2 + Log.toString(e)); |
|
509 |
return false; |
|
510 |
} |
|
511 |
return true; |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Write the lines between from and to in a writer. |
|
516 |
* |
|
517 |
* @param writer Where to write the lines |
|
518 |
* @param from The first line to be written |
|
519 |
* @param to The last line to be writen |
|
520 |
* @param colseparator the colseparator |
|
521 |
* @param txtseparator the txtseparator |
|
522 |
* @throws CqiClientException the cqi client exception |
|
523 |
* @throws IOException Signals that an I/O exception has occurred. |
|
524 |
*/ |
|
525 |
public void toTxt(Writer writer, int from, int to, String colseparator, String txtseparator) |
|
526 |
throws CqiClientException, IOException { |
|
527 |
try { |
|
528 |
getLines(0, 9999999); |
|
529 |
writer.write(pProperty.getName()+colseparator+this.pPattern+"\n"); //$NON-NLS-1$ |
|
530 |
for (Line line : lines) { |
|
531 |
writer.write(txtseparator+line.getPropValue().replace(txtseparator, txtseparator+txtseparator)+txtseparator+ colseparator + txtseparator+ line.getReferences().toString().replace(txtseparator, txtseparator+txtseparator)+txtseparator+"\n"); //$NON-NLS-1$ |
|
532 |
writer.flush(); |
|
533 |
} |
|
534 |
|
|
535 |
writer.close(); |
|
536 |
} catch (CqiServerError e) { |
|
537 |
// TODO Auto-generated catch block |
|
538 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
539 |
} |
|
540 |
} |
|
541 |
|
|
542 |
@Override |
|
543 |
public boolean canCompute() { |
|
544 |
|
|
545 |
if (pQuery == null |
|
546 |
|| pQuery.isEmpty()) { |
|
547 |
System.out.println("Empty query"); |
|
548 |
return false; |
|
549 |
} |
|
550 |
if (pPattern == null |
|
551 |
|| pPattern.size() == 0) { |
|
552 |
System.out.println("No reference pattern"); |
|
553 |
return false; |
|
554 |
} |
|
555 |
if (pProperty == null) { |
|
556 |
System.out.println("No property"); |
|
557 |
return false; |
|
558 |
} |
|
559 |
|
|
560 |
return true; |
|
561 |
} |
|
562 |
|
|
563 |
@Override |
|
564 |
public boolean loadParameters() throws CqiClientException { |
|
565 |
this.pQuery = new Query(this.getStringParameterValue(ReferencerPreferences.QUERY)); |
|
566 |
|
|
567 |
String s = this.getStringParameterValue(ReferencerPreferences.PATTERN); |
|
568 |
this.pPattern = StructuralUnitProperty.fromStringToList(getCorpus(), s); |
|
569 |
|
|
570 |
s = this.getStringParameterValue(ReferencerPreferences.PROPERTY); |
|
571 |
this.pProperty = getCorpus().getProperty(s); |
|
572 |
return true; |
|
573 |
} |
|
574 |
|
|
575 |
@Override |
|
576 |
public boolean saveParameters() { |
|
577 |
// TODO Auto-generated method stub |
|
578 |
System.err.println("Referencer.saveParameters(): not yet implemented."); |
|
579 |
return true; |
|
580 |
} |
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
/** |
|
586 |
* The Class Line. |
|
587 |
*/ |
|
588 |
public class Line { |
|
589 |
|
|
590 |
/** The id. */ |
|
591 |
int id; |
|
592 |
|
|
593 |
/** The propvalue. */ |
|
594 |
String linepropvalue; |
|
595 |
|
|
596 |
/** The notcomputed. */ |
|
597 |
boolean notcomputed=true; |
|
598 |
|
|
599 |
/** The positions. */ |
|
600 |
ArrayList<Integer> positions; |
|
601 |
|
|
602 |
/** The references. */ |
|
603 |
ArrayList<String> references; |
|
604 |
|
|
605 |
/** The references counts. */ |
|
606 |
HashMap<String, Integer> referencesCounts = new HashMap<String, Integer>(); |
|
607 |
|
|
608 |
/** |
|
609 |
* Instantiates a new line. |
|
610 |
* |
|
611 |
* @param i the i |
|
612 |
*/ |
|
613 |
public Line(int i) { |
|
614 |
id = i; |
|
615 |
positions = new ArrayList<Integer>(); |
|
616 |
references = new ArrayList<String>(); |
|
617 |
} |
|
618 |
|
|
619 |
/** |
|
620 |
* Adds the position. |
|
621 |
* |
|
622 |
* @param i the i |
|
623 |
*/ |
|
624 |
public void addPosition(int i) { |
|
625 |
positions.add(i); |
|
626 |
} |
|
627 |
|
|
628 |
/** |
|
629 |
* Adds the reference. |
|
630 |
* |
|
631 |
* @param string the string |
|
632 |
*/ |
|
633 |
public void addReference(String string) { |
|
634 |
if (!referencesCounts.containsKey(string)) { |
|
635 |
references.add(string); |
|
636 |
referencesCounts.put(string, 1); |
|
637 |
} else { |
|
638 |
referencesCounts.put(string, referencesCounts.get(string)+1); |
|
639 |
} |
|
640 |
} |
|
641 |
|
|
642 |
/** |
|
643 |
* Clear. |
|
644 |
*/ |
|
645 |
public void clear() { |
|
646 |
notcomputed = false; |
|
647 |
references = new ArrayList<String>(); |
|
648 |
} |
|
649 |
|
|
650 |
/** |
|
651 |
* Gets the count. |
|
652 |
* |
|
653 |
* @param ref the ref |
|
654 |
* @return the count |
|
655 |
*/ |
|
656 |
public int getCount(String ref) { |
|
657 |
return referencesCounts.get(ref); |
|
658 |
} |
|
659 |
|
|
660 |
public HashMap<String, Integer> getCounts() { |
|
661 |
return referencesCounts; |
|
662 |
} |
|
663 |
|
|
664 |
/** |
|
665 |
* Gets the prop value. |
|
666 |
* |
|
667 |
* @return the prop value |
|
668 |
*/ |
|
669 |
public String getPropValue() { |
|
670 |
return linepropvalue; |
|
671 |
} |
|
672 |
|
|
673 |
/** |
|
674 |
* Gets the references. |
|
675 |
* |
|
676 |
* @return the references |
|
677 |
*/ |
|
678 |
public List<String> getReferences() { |
|
679 |
return references; |
|
680 |
} |
|
681 |
|
|
682 |
/** |
|
683 |
* Sort alpha. |
|
684 |
*/ |
|
685 |
public void sortAlpha() { |
|
686 |
Collections.sort(references); |
|
687 |
} |
|
688 |
|
|
689 |
/** |
|
690 |
* Sort ref. |
|
691 |
* |
|
692 |
* @param reverse the reverse |
|
693 |
*/ |
|
694 |
public void sortRef(final boolean reverse) { |
|
695 |
Collections.sort(references, new Comparator<String>() { |
|
696 |
|
|
697 |
@Override |
|
698 |
public int compare(String arg0, String arg1) { |
|
699 |
if (reverse) |
|
700 |
return getCount(arg1) - getCount(arg0); |
|
701 |
else |
|
702 |
return getCount(arg0) - getCount(arg1); |
|
703 |
} |
|
704 |
}); |
|
705 |
} |
|
706 |
|
|
707 |
/* (non-Javadoc) |
|
708 |
* @see java.lang.Object#toString() |
|
709 |
*/ |
|
710 |
@Override |
|
711 |
public String toString() { |
|
712 |
return linepropvalue+" : <"+id+","+pProperty+"> : "+references.toString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
713 |
} |
|
714 |
} |
|
715 |
|
|
716 |
public void setQuery(Query query) { |
|
717 |
this.pQuery = query; |
|
718 |
} |
|
719 |
|
|
720 |
public void setProperty(Property property) { |
|
721 |
this.pProperty = property; |
|
722 |
} |
|
723 |
|
|
724 |
public void setPattern(List<StructuralUnitProperty> properties) { |
|
725 |
this.pPattern = properties; |
|
726 |
} |
|
727 |
} |
|
0 | 728 |
tmp/org.txm.referencer.core/src/org/txm/referencer/core/package.html (revision 626) | ||
---|---|---|
1 |
<html> |
|
2 |
<body> |
|
3 |
<p>Compute an index such as those in books</p> |
|
4 |
</body> |
|
5 |
</html> |
|
0 | 6 |
tmp/org.txm.groovy.core/src/groovy/org/txm/test/References.groovy (revision 626) | ||
---|---|---|
50 | 50 |
|
51 | 51 |
//we import the packages containing the functions we are going to use |
52 | 52 |
import org.txm.Toolbox |
53 |
import org.txm.referencer.core.functions.Referencer; |
|
53 | 54 |
import org.txm.searchengine.cqp.corpus.* |
54 | 55 |
import org.txm.searchengine.cqp.corpus.query.* |
55 | 56 |
import org.txm.functions.referencer.* |
tmp/org.txm.groovy.core/src/groovy/org/txm/test/CQPBenchmark.groovy (revision 626) | ||
---|---|---|
49 | 49 |
import org.txm.functions.diagnostic.*; |
50 | 50 |
import org.txm.functions.ca.*; |
51 | 51 |
import org.txm.functions.index.*; |
52 |
import org.txm.functions.referencer.Referencer; |
|
53 | 52 |
import org.txm.functions.specificities.*; |
54 | 53 |
import org.txm.functions.concordances.*; |
55 | 54 |
import org.txm.functions.concordances.comparators.*; |
55 |
import org.txm.referencer.core.functions.Referencer; |
|
56 | 56 |
import org.txm.searchengine.cqp.ReferencePattern |
57 | 57 |
import org.txm.searchengine.cqp.corpus.*; |
58 | 58 |
import org.txm.searchengine.cqp.corpus.query.*; |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 626) | ||
---|---|---|
141 | 141 |
|
142 | 142 |
// super.createPartControl(parent); |
143 | 143 |
|
144 |
lexicalTable = (LexicalTable) this.getResultData();
|
|
144 |
lexicalTable = (LexicalTable) this.getResult(); |
|
145 | 145 |
//iTable = lexicalTable.getData(); |
146 | 146 |
|
147 | 147 |
|
... | ... | |
408 | 408 |
|
409 | 409 |
this.updateEditorFromResult(false); |
410 | 410 |
|
411 |
this.createContextMenu(viewer); |
|
411 |
// Register the context menu |
|
412 |
TXMEditorPart.initContextMenu(this.viewer.getTable(), "LexicalTableEditorContextMenu", this.getSite(), this.viewer); // $NON-NLS-1$ |
|
413 |
|
|
412 | 414 |
|
413 | 415 |
//this.commandParametersGroup.pack(); |
414 | 416 |
} |
... | ... | |
462 | 464 |
this.viewer.getTable().setFocus(); |
463 | 465 |
} |
464 | 466 |
|
465 |
/** |
|
466 |
* Creates the context menu. |
|
467 |
* |
|
468 |
* @param tableViewer the table viewer |
|
469 |
*/ |
|
470 |
private void createContextMenu(TableViewer tableViewer) { |
|
471 |
|
|
472 |
MenuManager menuManager = new MenuManager(); |
|
473 |
Menu menu = menuManager.createContextMenu(tableViewer.getTable()); |
|
474 |
tableViewer.getTable().setMenu(menu); |
|
475 |
getSite().registerContextMenu(menuManager, tableViewer); |
|
476 |
getSite().setSelectionProvider(tableViewer); |
|
477 |
} |
|
478 |
|
|
479 | 467 |
|
480 | 468 |
/** |
481 | 469 |
* Sets the col comparator. |
tmp/org.txm.lexicaltable.rcp/plugin.xml (revision 626) | ||
---|---|---|
81 | 81 |
</command> |
82 | 82 |
</menuContribution> |
83 | 83 |
<menuContribution |
84 |
locationURI="popup:LexicalTableEditor"> |
|
84 |
locationURI="popup:LexicalTableEditorContextMenu">
|
|
85 | 85 |
<command |
86 | 86 |
commandId="org.txm.lexicaltable.rcp.handlers.DeleteLines" |
87 | 87 |
style="push"> |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/___LexicalTableFactory.java (revision 626) | ||
---|---|---|
1 |
package org.txm.lexicaltable.core.functions; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
|
9 |
import org.txm.lexicon.core.functions.Lexicon; |
|
10 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
11 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
12 |
import org.txm.searchengine.cqp.corpus.Partition; |
|
13 |
import org.txm.searchengine.cqp.corpus.Property; |
|
14 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
15 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
|
16 |
|
|
17 |
// FIXME: became useless? |
|
18 |
@Deprecated |
|
19 |
public class ___LexicalTableFactory { |
|
20 |
|
|
21 |
/** |
|
22 |
* Create a Complete Lexical Table according to a Partition and a Property. |
|
23 |
* |
|
24 |
* @param partition the partition |
|
25 |
* @param analysisProperty the analysis property |
|
26 |
* @param fMin the fmin |
|
27 |
* @param vmax |
|
28 |
* @return the lexical table |
|
29 |
* @throws CqiClientException the cqi client exception |
|
30 |
* @throws RWorkspaceException the r workspace exception |
|
31 |
*/ |
|
32 |
public static final LexicalTable getLexicalTable(Partition partition, Property analysisProperty, int fMin, int vMax) throws Exception { |
|
33 |
//long time = System.currentTimeMillis(); |
|
34 |
List<Lexicon> lexicons = new ArrayList<Lexicon>(); |
|
35 |
// Set<String> allLexiconEntry = new HashSet<String>(); |
|
36 |
for (int i = 0; i < partition.getNPart(); i++) { |
|
37 |
Lexicon l = new Lexicon(partition.getParts().get(i)); |
|
38 |
l.setProperty(analysisProperty); |
|
39 |
l.compute(null); |
|
40 |
lexicons.add(l); |
|
41 |
} |
|
42 |
//System.out.println("time lexicon build "+(System.currentTimeMillis()-time)); |
|
43 |
//time = System.currentTimeMillis(); |
|
44 |
// String[] entries = allLexiconEntry.toArray(new String[]{}); |
|
45 |
Corpus c = partition.getCorpus(); |
|
46 |
Lexicon ll = new Lexicon(c); |
|
47 |
ll.setProperty(analysisProperty); |
|
48 |
ll.compute(null); |
|
49 |
|
|
50 |
ArrayList<String> filteredForms = new ArrayList<String>(); |
|
51 |
//create a copy and filter line with Fmin; |
|
52 |
for (int i = 0 ; i < ll.getFreq().length ; i++) { |
|
53 |
if (ll.getFreq()[i] >= fMin) { |
|
54 |
filteredForms.add(ll.getForms()[i]); |
|
55 |
} |
|
56 |
} |
|
57 |
//System.out.println("remove freq too low "+(System.currentTimeMillis()-time)); |
|
58 |
//time = System.currentTimeMillis(); |
|
59 |
Map<String, Integer> entries2index = new HashMap<String, Integer>(); |
|
60 |
for (int i = 0; i < filteredForms.size(); i++) { |
|
61 |
entries2index.put(filteredForms.get(i), i); |
|
62 |
} |
|
63 |
|
|
64 |
//System.out.println("entries2index "+(System.currentTimeMillis()-time)); |
|
65 |
//time = System.currentTimeMillis(); |
|
66 |
int[][] mat = new int[filteredForms.size()][lexicons.size()];//DoubleFactory2D.sparse.make(filteredForms.size(), lexicons.size(), 0); |
|
67 |
|
|
68 |
|
|
69 |
Integer id= null; |
|
70 |
for (int i = 0; i < lexicons.size(); i++) { |
|
71 |
Lexicon l = lexicons.get(i); |
|
72 |
String[] ents = l.getForms(); |
|
73 |
int[] freqs = l.getFreq(); |
|
74 |
for (int j = 0; j < freqs.length; j++) { |
|
75 |
id = entries2index.get(ents[j]); |
|
76 |
// if (entriesFreqs[id] >= 2) |
|
77 |
if (id != null) { |
|
78 |
mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]); |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
//System.out.println("time build matrix "+(System.currentTimeMillis()-time)); |
|
83 |
//time = System.currentTimeMillis(); |
|
84 |
//System.out.println("Entries size " + filteredForms.size()); |
|
85 |
//System.out.println("mat size " + mat.rows()); |
|
86 |
//System.out.println("mat columns " + mat.columns()); |
|
87 |
|
|
88 |
LexicalTableImpl iTable = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames().toArray(new String[] {})); |
|
89 |
|
|
90 |
LexicalTable table = new LexicalTable(partition, analysisProperty, fMin, vMax, iTable); |
|
91 |
//System.out.println("time build table lexical "+(System.currentTimeMillis()-time)); |
|
92 |
return table; |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* |
|
97 |
* @param subcorpus |
|
98 |
* @param property |
|
99 |
* @return |
|
100 |
* @throws Exception |
|
101 |
*/ |
|
102 |
public static LexicalTable getLexicalTable(Subcorpus subcorpus, Property property) throws Exception { |
|
103 |
return new LexicalTable(subcorpus, property); |
|
104 |
} |
|
105 |
} |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 626) | ||
---|---|---|
149 | 149 |
this.statsData = iTable; |
150 | 150 |
} |
151 | 151 |
|
152 |
/** |
|
153 |
* Creates the lexical table. |
|
154 |
* |
|
155 |
* @param partindex the partindex |
|
156 |
* @return the lexical table |
|
157 |
* @throws RWorkspaceException the r workspace exception |
|
158 |
*/ |
|
159 |
// FIXME: not used? |
|
160 |
public LexicalTable(Index partIndex) throws RWorkspaceException { |
|
161 |
super(partIndex); |
|
162 |
this.pProperty = partIndex.getProperties().get(0); |
|
163 |
} |
|
164 |
|
|
165 | 152 |
|
166 | 153 |
@Override |
167 | 154 |
public boolean loadParameters() { |
tmp/org.txm.internalview.rcp/.settings/org.eclipse.core.resources.prefs (revision 626) | ||
---|---|---|
1 | 1 |
eclipse.preferences.version=1 |
2 |
encoding//src/org/txm/internalview/rcp/messages.properties=UTF-8 |
|
3 |
encoding//src/org/txm/internalview/rcp/messages_fr.properties=UTF-8 |
|
4 |
encoding//src/org/txm/internalview/rcp/messages_ru.properties=UTF-8 |
|
2 |
encoding//src/org/txm/internalview/rcp/messages/messages.properties=UTF-8 |
|
3 |
encoding//src/org/txm/internalview/rcp/messages/messages_fr.properties=UTF-8 |
|
4 |
encoding//src/org/txm/internalview/rcp/messages/messages_ru.properties=UTF-8 |
tmp/org.txm.internalview.rcp/META-INF/MANIFEST.MF (revision 626) | ||
---|---|---|
8 | 8 |
org.txm.rcp;bundle-version="0.8.0";visibility:=reexport, |
9 | 9 |
org.txm.concordance.core;bundle-version="1.0.0";visibility:=reexport, |
10 | 10 |
org.eclipse.osgi;visibility:=reexport |
11 |
Export-Package: org.txm.internal.rcp.editors, |
|
12 |
org.txm.internalview.rcp, |
|
13 |
org.txm.rcp.internal.rcp.handler |
|
11 |
Export-Package: org.txm.internalview.rcp.adapters, |
|
12 |
org.txm.internalview.rcp.editors, |
|
13 |
org.txm.internalview.rcp.handlers, |
|
14 |
org.txm.internalview.rcp.messages |
tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/messages_fr.properties (revision 626) | ||
---|---|---|
1 |
InternalViewEditor_1 = Calcul de la vue interne... |
|
2 |
InternalViewEditor_10 = InternalView: erreur d'initialisation : |
|
3 |
InternalViewEditor_11 = OK |
|
4 |
InternalViewEditor_16 = Erreur |
|
5 |
InternalViewEditor_2 = Récupération du prochain résultat... |
|
6 |
InternalViewEditor_25 = requête générée : |
|
7 |
InternalViewEditor_3 = Rechargement de l'interface |
|
8 |
InternalViewEditor_4 = Structure : |
|
9 |
InternalViewEditor_5 = Propriété de structure : |
tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/messages.properties (revision 626) | ||
---|---|---|
1 |
|
|
2 |
ComputeInternalView_0 = Selection is not structured |
|
3 |
ComputeInternalView_1 = Error: selection is not a Corpus |
|
4 |
|
|
5 |
InternalViewEditor_1 = Computing Internal view |
|
6 |
InternalViewEditor_10 = InternalView: failed to initialize form |
|
7 |
InternalViewEditor_11 = OK |
|
8 |
InternalViewEditor_16 = error |
|
9 |
InternalViewEditor_2 = Getting next result |
|
10 |
InternalViewEditor_25 = QUERY: |
|
11 |
InternalViewEditor_3 = Refreshing interface |
|
12 |
InternalViewEditor_4 = Structure: |
|
13 |
InternalViewEditor_5 = Structural properties: |
tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/Messages.java (revision 626) | ||
---|---|---|
1 |
package org.txm.internalview.rcp; |
|
2 |
|
|
3 |
import org.eclipse.osgi.util.NLS; |
|
4 |
import org.txm.utils.messages.Utf8NLS; |
|
5 |
|
|
6 |
public class Messages extends NLS { |
|
7 |
|
|
8 |
private static final String BUNDLE_NAME = Messages.class.getPackage().getName()+".messages"; //$NON-NLS-1$ |
|
9 |
|
|
10 |
public static String ComputeInternalView_0; |
|
11 |
public static String ComputeInternalView_1; |
|
12 |
|
|
13 |
public static String InternalViewEditor_1; |
|
14 |
public static String InternalViewEditor_10; |
|
15 |
public static String InternalViewEditor_11; |
|
16 |
public static String InternalViewEditor_16; |
|
17 |
public static String InternalViewEditor_2; |
|
18 |
public static String InternalViewEditor_25; |
|
19 |
public static String InternalViewEditor_3; |
|
20 |
public static String InternalViewEditor_4; |
|
21 |
public static String InternalViewEditor_5; |
|
22 |
|
|
23 |
static { |
|
24 |
// initialize resource bundle |
|
25 |
Utf8NLS.initializeMessages(BUNDLE_NAME, Messages.class); |
|
26 |
} |
|
27 |
} |
tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/AdapterFactory.java (revision 626) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
package org.txm.internalview.rcp; |
|
3 |
|
|
4 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
5 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
|
6 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
7 |
import org.txm.functions.internal.InternalView; |
|
8 |
import org.txm.internal.rcp.editors.InternalViewEditor; |
Formats disponibles : Unified diff