Révision 430
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java (revision 430) | ||
---|---|---|
11 | 11 |
import java.util.List; |
12 | 12 |
|
13 | 13 |
import org.txm.Toolbox; |
14 |
import org.txm.core.results.ITXMResult; |
|
15 |
import org.txm.functions.Function; |
|
14 |
import org.txm.core.preferences.TXMPreferences; |
|
15 |
import org.txm.core.results.TXMResult; |
|
16 |
import org.txm.core.results.TXMParameters; |
|
17 |
import org.txm.functions.TXMCommand; |
|
18 |
import org.txm.functions.ProgressWatcher; |
|
16 | 19 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
17 | 20 |
import org.txm.searchengine.cqp.CQPEngine; |
18 | 21 |
import org.txm.searchengine.cqp.NetCqiClient; |
... | ... | |
23 | 26 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
24 | 27 |
import org.txm.searchengine.cqp.corpus.query.Match; |
25 | 28 |
import org.txm.searchengine.cqp.corpus.query.Query; |
29 |
import org.txm.textsbalance.core.preferences.TextsBalancePreferences; |
|
26 | 30 |
import org.txm.utils.logger.Log; |
27 | 31 |
|
28 | 32 |
/** |
... | ... | |
32 | 36 |
* @author sjacquot |
33 | 37 |
* |
34 | 38 |
*/ |
35 |
public class TextsBalance extends Function implements ITXMResult {
|
|
39 |
public class TextsBalance extends TXMCommand {
|
|
36 | 40 |
|
37 | 41 |
|
38 | 42 |
|
... | ... | |
56 | 60 |
} |
57 | 61 |
|
58 | 62 |
|
63 |
|
|
64 |
|
|
65 |
@Override |
|
66 |
public boolean compute(ProgressWatcher watcher, TXMParameters parameters) { |
|
67 |
try { |
|
68 |
StructuralUnit su = this.getCorpus().getStructuralUnit((String) parameters.get(TextsBalancePreferences.STRUCTURAL_UNIT)); |
|
69 |
return this.compute( |
|
70 |
(Integer)parameters.get(TextsBalancePreferences.METHOD), |
|
71 |
su, |
|
72 |
su.getProperties().get((Integer) parameters.get(TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX)).getName(), |
|
73 |
(Boolean)parameters.get(TextsBalancePreferences.GROUP_BY_WORDS)); |
|
74 |
} |
|
75 |
catch(Exception e) { |
|
76 |
// TODO Auto-generated catch block |
|
77 |
e.printStackTrace(); |
|
78 |
} |
|
79 |
return false; |
|
80 |
} |
|
81 |
|
|
82 |
|
|
59 | 83 |
/** |
60 | 84 |
* @param method 1: use CQL to solve matches, 2 uses corpus struct indexes, 2 is faster ! |
61 | 85 |
* @param method |
... | ... | |
64 | 88 |
* @param groupByTexts |
65 | 89 |
* @throws CqiClientException |
66 | 90 |
*/ |
67 |
public void compute(int method, StructuralUnit su, String suPropertyName, boolean groupByTexts) throws CqiClientException {
|
|
91 |
public boolean compute(int method, StructuralUnit su, String suPropertyName, boolean groupByTexts) {
|
|
68 | 92 |
|
69 | 93 |
this.name = su.getName() + "@" + suPropertyName + " (group by texts = " + groupByTexts + ")"; |
70 | 94 |
|
71 | 95 |
Log.warning("Compute balance with metadata propertyName = " + suPropertyName + ", structural unit = " + su.getName() + " and count_texts = " + groupByTexts); |
72 | 96 |
try { |
73 |
if (suPropertyName == null || suPropertyName.length() == 0) return; |
|
97 |
if (suPropertyName == null || suPropertyName.length() == 0) return false;
|
|
74 | 98 |
|
75 | 99 |
|
76 | 100 |
this.dataset = new HashMap<Integer, Comparable[]>(); |
... | ... | |
106 | 130 |
AbstractCqiClient CQI = CQPEngine.getCqiClient(); |
107 | 131 |
if (CQI instanceof NetCqiClient) { |
108 | 132 |
System.out.println("Error: CQP eval method only available with CQP memory mode"); |
109 |
return; |
|
133 |
return false;
|
|
110 | 134 |
} |
111 | 135 |
|
112 | 136 |
String supqn = p.getQualifiedName(); |
... | ... | |
161 | 185 |
catch(Exception e) { |
162 | 186 |
System.out.println("Error while computing text informations: "+e); |
163 | 187 |
e.printStackTrace(); |
188 |
return false; |
|
164 | 189 |
} |
190 |
return true; |
|
165 | 191 |
} |
166 | 192 |
|
167 | 193 |
|
... | ... | |
276 | 302 |
// TODO Auto-generated method stub |
277 | 303 |
return null; |
278 | 304 |
} |
279 |
|
|
280 |
|
|
305 |
|
|
306 |
|
|
281 | 307 |
} |
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/jfreechart/JFCBalanceSpiderChartCreator.java (revision 430) | ||
---|---|---|
9 | 9 |
import org.jfree.chart.plot.SpiderWebPlot; |
10 | 10 |
import org.jfree.data.category.CategoryDataset; |
11 | 11 |
import org.jfree.data.category.DefaultCategoryDataset; |
12 |
import org.txm.core.results.ITXMResult;
|
|
12 |
import org.txm.core.results.TXMResult; |
|
13 | 13 |
import org.txm.chartsengine.jfreechart.core.JFCChartCreator; |
14 | 14 |
import org.txm.textsbalance.core.functions.TextsBalance; |
15 | 15 |
|
... | ... | |
20 | 20 |
} |
21 | 21 |
|
22 | 22 |
@Override |
23 |
public JFreeChart createChart(ITXMResult result, String preferencesNode) {
|
|
23 |
public JFreeChart createChart(TXMResult result) {
|
|
24 | 24 |
|
25 | 25 |
final TextsBalance balance = (TextsBalance) result; |
26 | 26 |
|
... | ... | |
62 | 62 |
|
63 | 63 |
// FIXME: tests |
64 | 64 |
//this.getChartsEngine().getTheme().apply(chart); |
65 |
this.getChartsEngine().getJFCTheme().applyThemeToChart(chart, result, preferencesNode);
|
|
65 |
this.getChartsEngine().getJFCTheme().applyThemeToChart(chart, result); |
|
66 | 66 |
//this.getChartsEngine().getJFCTheme().apply(chart); |
67 | 67 |
// this.getChartsEngine().getJFCTheme().apply(chart); |
68 | 68 |
|
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/r/RBalanceSpiderChartCreator.java (revision 430) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
|
5 |
import org.txm.core.results.ITXMResult;
|
|
5 |
import org.txm.core.results.TXMResult; |
|
6 | 6 |
import org.txm.chartsengine.r.core.RChartCreator; |
7 | 7 |
import org.txm.chartsengine.r.core.RChartsEngine; |
8 | 8 |
import org.txm.textsbalance.core.functions.TextsBalance; |
... | ... | |
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
@Override |
17 |
public Object createChart(ITXMResult result, String preferencesNode) {
|
|
17 |
public Object createChart(TXMResult result) {
|
|
18 | 18 |
// TODO Auto-generated method stub |
19 | 19 |
return null; |
20 | 20 |
} |
21 | 21 |
|
22 | 22 |
@Override |
23 |
public File createChartFile(ITXMResult result, File file, String preferencesNode) {
|
|
23 |
public File createChartFile(TXMResult result, File file) {
|
|
24 | 24 |
|
25 | 25 |
// try { |
26 | 26 |
|
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java (revision 430) | ||
---|---|---|
20 | 20 |
|
21 | 21 |
public static final String PREFERENCES_PREFIX = "texts_balance_"; //$NON-NLS-1$ |
22 | 22 |
|
23 |
public static final String GROUP_BY_WORDS = PREFERENCES_PREFIX + "count_by_words"; //$NON-NLS-1$
|
|
23 |
public static final String GROUP_BY_WORDS = PREFERENCES_PREFIX + "group_by_words"; //$NON-NLS-1$
|
|
24 | 24 |
public static final String METHOD = PREFERENCES_PREFIX + "method"; //$NON-NLS-1$ |
25 | 25 |
|
26 | 26 |
// local result preferences |
Formats disponibles : Unified diff