Révision 544
tmp/org.txm.specificities.core/src/org/txm/specificities/core/messages/SpecificitiesCoreMessages.java (revision 544) | ||
---|---|---|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
8 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author sjacquot |
|
11 |
* |
|
12 |
*/ |
|
9 | 13 |
public class SpecificitiesCoreMessages extends NLS { |
10 | 14 |
|
11 | 15 |
private static final String BUNDLE_NAME = "org.txm.specificities.core.messages.messages"; //$NON-NLS-1$ |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 544) | ||
---|---|---|
37 | 37 |
import java.util.Arrays; |
38 | 38 |
import java.util.List; |
39 | 39 |
|
40 |
import org.txm.chartsengine.core.results.ChartResult; |
|
41 |
import org.txm.core.results.TXMParameters; |
|
40 |
import org.txm.core.results.TXMResult; |
|
42 | 41 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
43 | 42 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
44 | 43 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
... | ... | |
51 | 50 |
import org.txm.statsengine.core.utils.ArrayIndex; |
52 | 51 |
import org.txm.statsengine.core.utils.CheckArray; |
53 | 52 |
import org.txm.statsengine.r.core.RWorkspace; |
53 |
import org.txm.utils.logger.Log; |
|
54 | 54 |
|
55 | 55 |
/** |
56 |
* Hold specificities computation result. |
|
56 |
* Holds specificities computation result.
|
|
57 | 57 |
* |
58 | 58 |
* @author mdecorde |
59 | 59 |
* @author sloiseau |
60 | 60 |
* |
61 | 61 |
*/ |
62 |
public class Specificities extends ChartResult {
|
|
62 |
public class Specificities extends TXMResult {
|
|
63 | 63 |
|
64 | 64 |
public static int MAXSPECIF = 1000; |
65 | 65 |
|
... | ... | |
109 | 109 |
@Deprecated |
110 | 110 |
private BufferedWriter writer; |
111 | 111 |
|
112 |
|
|
113 |
protected int pMaxScore; |
|
114 |
|
|
115 |
|
|
112 | 116 |
/** |
113 |
* The selected type names to focus on. |
|
117 |
* Specificities. |
|
118 |
* |
|
119 |
* @param table the table |
|
120 |
* @return the specificities result |
|
121 |
* @throws CqiClientException the cqi client exception |
|
122 |
* @throws StatException the stat exception |
|
114 | 123 |
*/ |
115 |
protected String[] selectedTypeNames; |
|
124 |
public Specificities(LexicalTable table, int maxScore) throws CqiClientException, StatException { |
|
125 |
super(table); |
|
126 |
this.table = table; |
|
127 |
this.pMaxScore = maxScore; |
|
128 |
} |
|
116 | 129 |
|
117 |
/** |
|
118 |
* The selected part names to focus on. |
|
119 |
*/ |
|
120 |
protected String[] selectedPartNames; |
|
121 | 130 |
|
122 |
/** |
|
123 |
* The selected specificities indices to focus on. |
|
124 |
*/ |
|
125 |
protected double[][] selectedSpecificitiesIndex; |
|
126 | 131 |
|
127 |
private int pMaxScore; |
|
128 | 132 |
|
133 |
@Override |
|
129 | 134 |
protected boolean _compute(boolean update) throws Exception { |
130 | 135 |
SpecificitiesR si = new SpecificitiesR(table.getData()); |
131 | 136 |
|
... | ... | |
138 | 143 |
// System.out.println("prop="+table.getProperty()); |
139 | 144 |
init(symbol, specIndex, table, Arrays |
140 | 145 |
.asList(table.getRowNames().asStringsArray()), Arrays.asList(table.getColNames().asStringsArray()), table.getProperty().getName(), this.pMaxScore); |
141 |
} else { |
|
146 |
} |
|
147 |
else { |
|
142 | 148 |
init(si.getSymbol(), specIndex, table, Arrays |
143 | 149 |
.asList(table.getRowNames().asStringsArray()), Arrays.asList(table.getColNames().asStringsArray()), |
144 | 150 |
"TLNONAME: " + table.getProperty().getName(), this.pMaxScore); //$NON-NLS-1$ |
... | ... | |
146 | 152 |
return true; |
147 | 153 |
} |
148 | 154 |
|
149 |
// /** |
|
150 |
// * Compute the specificity index for all the cells of a complete lexical |
|
151 |
// * table, as defined by a {@link Partition} and a {@link Property}. |
|
152 |
// * |
|
153 |
// * This may be used for extracting, for all part, the forms the most or the |
|
154 |
// * less specif ic. |
|
155 |
// * |
|
156 |
// * @param partition the partition |
|
157 |
// * @param analysisProperty the analysis property |
|
158 |
// * @param formFocus the form focus |
|
159 |
// * @param partsFocus the parts focus |
|
160 |
// * @param Fmin the fmin |
|
161 |
// * @return the specificites result |
|
162 |
// * @throws CqiClientException the cqi client exception |
|
163 |
// * @throws StatException the stat exception |
|
164 |
// */ |
|
165 |
// public Specificities(Partition partition, Property analysisProperty, int Fmin, int maxScore) throws Exception { |
|
166 |
// this(LexicalTableFactory.getLexicalTable(partition, analysisProperty, Fmin), maxScore); |
|
167 |
// |
|
168 |
// if (partition.getParts().size() < 2) { |
|
169 |
// throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS); |
|
170 |
// } |
|
171 |
// } |
|
172 |
|
|
173 | 155 |
/** |
174 |
* Specificites. |
|
175 |
* |
|
176 |
* @param table the table |
|
177 |
* @return the specificites result |
|
178 |
* @throws CqiClientException the cqi client exception |
|
179 |
* @throws StatException the stat exception |
|
180 |
*/ |
|
181 |
public Specificities(LexicalTable table, int maxScore) throws CqiClientException, StatException { |
|
182 |
super(table); |
|
183 |
if (table.getNColumns() < 2) { |
|
184 |
throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS); |
|
185 |
} |
|
186 |
this.table = table; |
|
187 |
this.pMaxScore = maxScore; // TODO: move this to setParamters(...) |
|
188 |
} |
|
189 |
|
|
190 |
// /** |
|
191 |
// * Specificites. |
|
192 |
// * |
|
193 |
// * @param corpus the corpus |
|
194 |
// * @param subcorpus the subcorpus |
|
195 |
// * @param property the property |
|
196 |
// * @return the specificites result |
|
197 |
// * @throws CqiClientException the cqi client exception |
|
198 |
// * @throws StatException the stat exception |
|
199 |
// * @throws REXPMismatchException |
|
200 |
// * @throws RserveException |
|
201 |
// */ |
|
202 |
// public Specificities(Corpus corpus, Subcorpus subcorpus, Property property, int maxScore) throws Exception { |
|
203 |
// super(corpus); |
|
204 |
// Lexicon totalFrequencies = Lexicon.getLexicon(corpus, property); |
|
205 |
// Lexicon subFrequencies = Lexicon.getLexicon(subcorpus, property); |
|
206 |
// |
|
207 |
// //System.out.println("Send corpus vector"); |
|
208 |
// Vector totalFSymbol; |
|
209 |
// Vector subFSymbol; |
|
210 |
// try { |
|
211 |
// totalFSymbol = totalFrequencies.asVector(); |
|
212 |
// subFSymbol = subFrequencies.asVector(); |
|
213 |
// } catch (StatException e) { |
|
214 |
// throw new RWorkspaceException(e); |
|
215 |
// } |
|
216 |
// |
|
217 |
// SpecificitiesR si = new SpecificitiesR(totalFSymbol, subFSymbol); |
|
218 |
// double[][] specIndex = si.getScores(); |
|
219 |
// |
|
220 |
// init(si.getSymbol(), specIndex, totalFrequencies, subFrequencies, corpus.getName()+"\\"+subcorpus.getName(), maxScore); |
|
221 |
// } |
|
222 |
// |
|
223 |
|
|
224 |
// /** |
|
225 |
// * Instantiates a new specificities result : for subcorpus specificities. |
|
226 |
// * |
|
227 |
// * @param symbol the symbol |
|
228 |
// * @param specIndex the spec index |
|
229 |
// * @param lexicon the lexicon |
|
230 |
// * @param subLexicon the sub lexicon |
|
231 |
// * @param name the name |
|
232 |
// */ |
|
233 |
// protected void init(String symbol, double[][] specIndex, Lexicon lexicon, Lexicon subLexicon, String name, int maxScore) { |
|
234 |
// |
|
235 |
// //super(subLexicon.getCorpus()); |
|
236 |
// this.corpus = subLexicon.getCorpus(); |
|
237 |
// this.symbol = symbol; |
|
238 |
// this.indices = specIndex; |
|
239 |
// |
|
240 |
// this.lexicon = lexicon; |
|
241 |
// this.subLexicon = subLexicon; |
|
242 |
// this.corpus = lexicon.getCorpus(); |
|
243 |
// this.subCorpus = subLexicon.getCorpus(); |
|
244 |
// this.name = name; |
|
245 |
// |
|
246 |
// int MAX = MAXSPECIF; |
|
247 |
// int MIN = -MAXSPECIF; |
|
248 |
// |
|
249 |
// if (maxScore > 0) { |
|
250 |
// MAX = maxScore; |
|
251 |
// MIN = -maxScore; |
|
252 |
// } |
|
253 |
// for (int i = 0 ; i < indices.length ; i++) { |
|
254 |
// for (int j = 0 ; j < indices[i].length ; j++) { |
|
255 |
// if (indices[i][j] > MAX) { |
|
256 |
// indices[i][j] = MAX; |
|
257 |
// } else if (indices[i][j] < MIN) { |
|
258 |
// indices[i][j] = MIN; |
|
259 |
// } |
|
260 |
// } |
|
261 |
// } |
|
262 |
// |
|
263 |
// this.table = null; |
|
264 |
// } |
|
265 |
|
|
266 |
/** |
|
267 | 156 |
* Instantiates a new specificities result. |
268 | 157 |
* |
269 | 158 |
* @param symbol the symbol |
... | ... | |
279 | 168 |
* @param maxScore if abs(score) > maxScore -> score = +/- maxScore |
280 | 169 |
* @throws StatException the stat exception |
281 | 170 |
*/ |
282 |
protected void init(String symbol, double[][] specIndex, LexicalTable table, |
|
283 |
List<String> typeFocus, List<String> partFocus, String name, int maxScore) |
|
284 |
throws StatException { |
|
171 |
protected void init(String symbol, double[][] specIndex, LexicalTable table, List<String> typeFocus, List<String> partFocus, String name, int maxScore) throws StatException { |
|
285 | 172 |
|
286 | 173 |
this.table = table; |
287 | 174 |
this.symbol = symbol; |
... | ... | |
329 | 216 |
SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ComputeError_FOUND_AND_WANTED_ROWS_MISMATCH, typeFocus.size(), specIndex.length)); |
330 | 217 |
} |
331 | 218 |
|
332 |
rowindex = ArrayIndex.getIndex( |
|
333 |
table.getRowNames().asStringsArray(), typeFocus |
|
334 |
.toArray(new String[] {})); |
|
219 |
rowindex = ArrayIndex.getIndex(table.getRowNames().asStringsArray(), typeFocus.toArray(new String[] {})); |
|
335 | 220 |
for (int i : rowindex) { |
336 | 221 |
if (i == -1) { |
337 |
throw new IllegalArgumentException( |
|
338 |
SpecificitiesCoreMessages.SpecificitesResult_6); |
|
222 |
throw new IllegalArgumentException(SpecificitiesCoreMessages.SpecificitesResult_6); |
|
339 | 223 |
} |
340 | 224 |
} |
341 | 225 |
} |
... | ... | |
415 | 299 |
*/ |
416 | 300 |
public String[] getTypeNames() throws StatException { |
417 | 301 |
if (table != null) { |
418 |
return (rownames != null && rownames.size() != 0) ? rownames |
|
419 |
.toArray(new String[] {}) : table.getRowNames() |
|
420 |
.asStringsArray(); |
|
302 |
return (rownames != null && rownames.size() != 0) ? rownames.toArray(new String[] {}) : table.getRowNames().asStringsArray(); |
|
421 | 303 |
} else { |
422 | 304 |
return lexicon.getForms(); |
423 | 305 |
} |
... | ... | |
432 | 314 |
public String[] getPartShortNames() throws StatException { |
433 | 315 |
// System.out.println("get col names: "+table); |
434 | 316 |
// System.out.println("colnames: "+colnames); |
435 |
if (colnames != null && colnames.size() > 0) |
|
317 |
if (colnames != null && colnames.size() > 0) {
|
|
436 | 318 |
return colnames.toArray(new String[]{}); |
319 |
} |
|
437 | 320 |
else if (table != null) { |
438 | 321 |
// return (colnames != null && colnames.size() != 0) ? |
439 | 322 |
// colnames.toArray(new String[]{}) : |
... | ... | |
445 | 328 |
* parts.get(i).getShortName(); } |
446 | 329 |
*/ |
447 | 330 |
return table.getColNames().asStringsArray(); |
448 |
} else { |
|
449 |
if (this.subCorpus != null) |
|
450 |
return new String[] { this.subCorpus.getName(), |
|
451 |
this.corpus.getName() + " \\ " + this.subCorpus.getName() }; //$NON-NLS-1$ |
|
331 |
} else if (this.subCorpus != null) { |
|
332 |
return new String[] { this.subCorpus.getName(),this.corpus.getName() + " \\ " + this.subCorpus.getName() }; //$NON-NLS-1$ |
|
452 | 333 |
} |
453 | 334 |
return new String[0]; |
454 | 335 |
} |
... | ... | |
550 | 431 |
} |
551 | 432 |
} |
552 | 433 |
|
553 |
/** |
|
554 |
* To txt. |
|
555 |
* |
|
556 |
* @param outfile the outfile |
|
557 |
* @param encoding the encoding |
|
558 |
* @param colseparator the colseparator |
|
559 |
* @param txtseparator the txtseparator |
|
560 |
* @return true, if successful |
|
561 |
* @throws StatException the stat exception |
|
562 |
*/ |
|
434 |
@Override |
|
563 | 435 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws StatException { |
564 | 436 |
|
565 | 437 |
// NK: Declared as class attribute to perform a clean if the operation is interrupted |
... | ... | |
613 | 485 |
return true; |
614 | 486 |
} |
615 | 487 |
|
616 |
|
|
617 |
|
|
618 |
|
|
619 | 488 |
/** |
620 |
* Gets the symbol. |
|
621 |
* |
|
622 |
* @return the symbol |
|
623 |
*/ |
|
624 |
public String getSymbol() { |
|
625 |
return symbol; |
|
626 |
} |
|
627 |
|
|
628 |
/** |
|
629 |
* Gets the sorted part indexes. |
|
630 |
* |
|
631 |
* @return the sorted part indexes |
|
632 |
*/ |
|
633 |
public int[] getSortedPartIndexes() { |
|
634 |
|
|
635 |
try { |
|
636 |
int[] indexes = new int[this.getNbrPart()]; |
|
637 |
String[] partsname = this.getPartShortNames().clone(); |
|
638 |
for (int i = 0; i < this.getNbrPart(); i++) { |
|
639 |
indexes[i] = i; |
|
640 |
} |
|
641 |
|
|
642 |
for (int i = 0; i < this.getNbrPart(); i++) { |
|
643 |
int imin = i; |
|
644 |
for (int j = i; j < this.getNbrPart(); j++) { |
|
645 |
if (partsname[imin].compareTo(partsname[j]) > 0) { |
|
646 |
imin = j; |
|
647 |
} |
|
648 |
} |
|
649 |
String tmp = partsname[i]; |
|
650 |
partsname[i] = partsname[imin]; |
|
651 |
partsname[imin] = tmp; |
|
652 |
|
|
653 |
int tmp2 = indexes[i]; |
|
654 |
indexes[i] = indexes[imin]; |
|
655 |
indexes[imin] = tmp2; |
|
656 |
} |
|
657 |
return indexes; |
|
658 |
} catch (StatException e) { |
|
659 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
660 |
} |
|
661 |
return new int[0]; |
|
662 |
} |
|
663 |
|
|
664 |
/** |
|
665 | 489 |
* Sets the corpus. |
666 | 490 |
* |
667 | 491 |
* @param subcorpus2 the new corpus |
... | ... | |
691 | 515 |
} |
692 | 516 |
} |
693 | 517 |
|
694 |
/** |
|
695 |
* @return the selectedTypeNames |
|
696 |
*/ |
|
697 |
public String[] getSelectedTypeNames() { |
|
698 |
return selectedTypeNames; |
|
699 |
} |
|
700 | 518 |
|
701 |
/** |
|
702 |
* @param selectedTypeNames the selectedTypeNames to set |
|
703 |
*/ |
|
704 |
public void setSelectedTypeNames(String[] selectedTypeNames) { |
|
705 |
this.selectedTypeNames = selectedTypeNames; |
|
706 |
} |
|
707 | 519 |
|
708 |
/** |
|
709 |
* @return the selectedPartNames |
|
710 |
*/ |
|
711 |
public String[] getSelectedPartNames() { |
|
712 |
return selectedPartNames; |
|
713 |
} |
|
714 | 520 |
|
715 |
/** |
|
716 |
* @param selectedPartNames the selectedPartNames to set |
|
717 |
*/ |
|
718 |
public void setSelectedPartNames(String[] selectedPartNames) { |
|
719 |
this.selectedPartNames = selectedPartNames; |
|
720 |
} |
|
521 |
// /** |
|
522 |
// * Gets the symbol. |
|
523 |
// * |
|
524 |
// * @return the symbol |
|
525 |
// */ |
|
526 |
// public String getSymbol() { |
|
527 |
// return symbol; |
|
528 |
// } |
|
721 | 529 |
|
722 |
/** |
|
723 |
* @return the selectedSpecificitiesIndex |
|
724 |
*/ |
|
725 |
public double[][] getSelectedSpecificitiesIndex() { |
|
726 |
return selectedSpecificitiesIndex; |
|
727 |
} |
|
728 |
|
|
729 |
/** |
|
730 |
* @param selectedSpecificitiesIndex the selectedSpecificitiesIndex to set |
|
731 |
*/ |
|
732 |
public void setSelectedSpecificitiesIndex(double[][] selectedSpecificitiesIndex) { |
|
733 |
this.selectedSpecificitiesIndex = selectedSpecificitiesIndex; |
|
734 |
} |
|
735 |
|
|
736 |
|
|
530 |
// /** |
|
531 |
// * Gets the sorted part indexes. |
|
532 |
// * |
|
533 |
// * @return the sorted part indexes |
|
534 |
// */ |
|
535 |
// public int[] getSortedPartIndexes() { |
|
536 |
// |
|
537 |
// try { |
|
538 |
// int[] indexes = new int[this.getNbrPart()]; |
|
539 |
// String[] partsname = this.getPartShortNames().clone(); |
|
540 |
// for (int i = 0; i < this.getNbrPart(); i++) { |
|
541 |
// indexes[i] = i; |
|
542 |
// } |
|
543 |
// |
|
544 |
// for (int i = 0; i < this.getNbrPart(); i++) { |
|
545 |
// int imin = i; |
|
546 |
// for (int j = i; j < this.getNbrPart(); j++) { |
|
547 |
// if (partsname[imin].compareTo(partsname[j]) > 0) { |
|
548 |
// imin = j; |
|
549 |
// } |
|
550 |
// } |
|
551 |
// String tmp = partsname[i]; |
|
552 |
// partsname[i] = partsname[imin]; |
|
553 |
// partsname[imin] = tmp; |
|
554 |
// |
|
555 |
// int tmp2 = indexes[i]; |
|
556 |
// indexes[i] = indexes[imin]; |
|
557 |
// indexes[imin] = tmp2; |
|
558 |
// } |
|
559 |
// return indexes; |
|
560 |
// } catch (StatException e) { |
|
561 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
562 |
// } |
|
563 |
// return new int[0]; |
|
564 |
// } |
|
565 |
|
|
737 | 566 |
@Override |
738 | 567 |
public String getName() { |
568 |
// FIXME: to define |
|
569 |
// if (this.specificitiesResult.getLexicalTable()!= null && this.specificitiesResult.getLexicalTable().getPartition() != null) { |
|
570 |
// setPartName(this.specificitiesResult.getLexicalTable().getPartition().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
571 |
// } else if (spinput.getSubcorpus() != null) { |
|
572 |
// setPartName(spinput.getSubcorpus().getName()+": "+specificitiesResult.getName()); //$NON-NLS-1$ |
|
573 |
// } else { |
|
574 |
// setPartName(specificitiesResult.getName()); |
|
575 |
// } |
|
739 | 576 |
return name; |
740 | 577 |
} |
741 | 578 |
|
... | ... | |
743 | 580 |
|
744 | 581 |
@Override |
745 | 582 |
public String getSimpleName() { |
583 |
// FIXME: to define |
|
746 | 584 |
return this.getName(); |
747 | 585 |
} |
748 | 586 |
|
749 | 587 |
@Override |
750 | 588 |
public String getDetails() { |
589 |
// FIXME: to define |
|
751 | 590 |
return this.getName(); |
752 | 591 |
} |
753 | 592 |
|
754 | 593 |
@Override |
755 | 594 |
public boolean canCompute() { |
756 |
return table != null; |
|
595 |
|
|
596 |
if(this.table == null) { |
|
597 |
return false; |
|
598 |
} |
|
599 |
|
|
600 |
if (table.getNColumns() < 2) { |
|
601 |
Log.severe(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS); |
|
602 |
return false; |
|
603 |
} |
|
604 |
|
|
605 |
return true; |
|
757 | 606 |
} |
758 | 607 |
|
759 |
@Override |
|
760 |
public boolean setParameters(TXMParameters parameters) { |
|
761 |
return false; |
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
/** |
|
612 |
* @param maxScore the pMaxScore to set |
|
613 |
*/ |
|
614 |
public void setMaxScore(int maxScore) { |
|
615 |
this.pMaxScore = maxScore; |
|
762 | 616 |
} |
617 |
|
|
763 | 618 |
} |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 544) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.specificities.core.functions; |
|
5 |
|
|
6 |
import java.io.File; |
|
7 |
|
|
8 |
import org.txm.chartsengine.core.results.ChartResult; |
|
9 |
|
|
10 |
/** |
|
11 |
* A selection from a Specificities result dedicated to export or chart creation. |
|
12 |
* @author sjacquot |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class SpecificitiesSelection extends ChartResult { |
|
16 |
|
|
17 |
|
|
18 |
/** |
|
19 |
* The selected type names to focus on. |
|
20 |
*/ |
|
21 |
protected String[] selectedTypeNames; |
|
22 |
|
|
23 |
/** |
|
24 |
* The selected part names to focus on. |
|
25 |
*/ |
|
26 |
protected String[] selectedPartNames; |
|
27 |
|
|
28 |
/** |
|
29 |
* The selected specificities indices to focus on. |
|
30 |
*/ |
|
31 |
protected double[][] selectedSpecificitiesIndex; |
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Creates an empty SpecificitiesSelection. |
|
38 |
* @param parent |
|
39 |
*/ |
|
40 |
public SpecificitiesSelection(Specificities parent) { |
|
41 |
super(parent); |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* @return the selectedTypeNames |
|
48 |
*/ |
|
49 |
public String[] getSelectedTypeNames() { |
|
50 |
return selectedTypeNames; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @param selectedTypeNames the selectedTypeNames to set |
|
55 |
*/ |
|
56 |
public void setSelectedTypeNames(String[] selectedTypeNames) { |
|
57 |
this.selectedTypeNames = selectedTypeNames; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @return the selectedPartNames |
|
62 |
*/ |
|
63 |
public String[] getSelectedPartNames() { |
|
64 |
return selectedPartNames; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* @param selectedPartNames the selectedPartNames to set |
|
69 |
*/ |
|
70 |
public void setSelectedPartNames(String[] selectedPartNames) { |
|
71 |
this.selectedPartNames = selectedPartNames; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @return the selectedSpecificitiesIndex |
|
76 |
*/ |
|
77 |
public double[][] getSelectedSpecificitiesIndex() { |
|
78 |
return selectedSpecificitiesIndex; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @param selectedSpecificitiesIndex the selectedSpecificitiesIndex to set |
|
83 |
*/ |
|
84 |
public void setSelectedSpecificitiesIndex(double[][] selectedSpecificitiesIndex) { |
|
85 |
this.selectedSpecificitiesIndex = selectedSpecificitiesIndex; |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
91 |
* @see org.txm.core.results.TXMResult#getName() |
|
92 |
*/ |
|
93 |
@Override |
|
94 |
public String getName() { |
|
95 |
String name = ""; |
|
96 |
for (int i = 0; i < selectedTypeNames.length; i++) { |
|
97 |
name += selectedTypeNames[i] + " "; |
|
98 |
} |
|
99 |
return name; |
|
100 |
} |
|
101 |
|
|
102 |
/* (non-Javadoc) |
|
103 |
* @see org.txm.core.results.TXMResult#getSimpleName() |
|
104 |
*/ |
|
105 |
@Override |
|
106 |
public String getSimpleName() { |
|
107 |
// TODO Auto-generated method stub |
|
108 |
return this.getName(); |
|
109 |
} |
|
110 |
|
|
111 |
/* (non-Javadoc) |
|
112 |
* @see org.txm.core.results.TXMResult#getDetails() |
|
113 |
*/ |
|
114 |
@Override |
|
115 |
public String getDetails() { |
|
116 |
// TODO Auto-generated method stub |
|
117 |
return this.getName(); |
|
118 |
} |
|
119 |
|
|
120 |
/* (non-Javadoc) |
|
121 |
* @see org.txm.core.results.TXMResult#clean() |
|
122 |
*/ |
|
123 |
@Override |
|
124 |
public void clean() { |
|
125 |
//does nothing |
|
126 |
} |
|
127 |
|
|
128 |
/* (non-Javadoc) |
|
129 |
* @see org.txm.core.results.TXMResult#canCompute() |
|
130 |
*/ |
|
131 |
@Override |
|
132 |
public boolean canCompute() throws Exception { |
|
133 |
return this.parent != null; |
|
134 |
} |
|
135 |
|
|
136 |
/* (non-Javadoc) |
|
137 |
* @see org.txm.core.results.TXMResult#_compute(boolean) |
|
138 |
*/ |
|
139 |
@Override |
|
140 |
protected boolean _compute(boolean update) throws Exception { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
return true; |
|
143 |
} |
|
144 |
|
|
145 |
/* (non-Javadoc) |
|
146 |
* @see org.txm.core.results.TXMResult#toTxt(java.io.File, java.lang.String, java.lang.String, java.lang.String) |
|
147 |
*/ |
|
148 |
@Override |
|
149 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception { |
|
150 |
// TODO Auto-generated method stub |
|
151 |
return false; |
|
152 |
} |
|
153 |
|
|
154 |
} |
|
0 | 155 |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/jfreechart/JFCSpecificitiesBarChartCreator.java (revision 544) | ||
---|---|---|
16 | 16 |
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection; |
17 | 17 |
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis; |
18 | 18 |
import org.txm.chartsengine.jfreechart.core.themes.base.SymbolAxisBetweenTicks; |
19 |
import org.txm.core.preferences.TXMPreferences; |
|
20 | 19 |
import org.txm.core.results.TXMResult; |
21 | 20 |
import org.txm.specificities.core.functions.Specificities; |
21 |
import org.txm.specificities.core.functions.SpecificitiesSelection; |
|
22 | 22 |
import org.txm.specificities.core.messages.SpecificitiesCoreMessages; |
23 | 23 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
24 | 24 |
|
25 | 25 |
/** |
26 |
* Creates a specificities chart from the specified <code>SpecificitesResult</code> result.
|
|
26 |
* Creates a bar chart from the specified <code>SpecificitiesSelection</code> result.
|
|
27 | 27 |
* @author sjacquot |
28 | 28 |
* |
29 | 29 |
*/ |
30 | 30 |
public class JFCSpecificitiesBarChartCreator extends JFCChartCreator { |
31 | 31 |
|
32 |
public JFCSpecificitiesBarChartCreator() { |
|
33 |
} |
|
34 |
|
|
35 | 32 |
@Override |
36 | 33 |
public JFreeChart createChart(TXMResult result) { |
37 | 34 |
|
38 |
Specificities specificitiesResult = (Specificities) result;
|
|
35 |
SpecificitiesSelection specificitiesSelection = (SpecificitiesSelection) result;
|
|
39 | 36 |
|
40 | 37 |
// parameters |
41 | 38 |
boolean drawBars = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_DRAW_BARS); |
... | ... | |
50 | 47 |
|
51 | 48 |
if(drawBars) { |
52 | 49 |
// Create the bar chart |
53 |
chart = this.getChartsEngine().createXYBarChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, SpecificitiesCoreMessages.Charts_Y_AXIS_LABEL, true, false);
|
|
50 |
chart = this.getChartsEngine().createXYBarChart(dataset, specificitiesSelection.getName(), SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, SpecificitiesCoreMessages.Charts_Y_AXIS_LABEL, true, false);
|
|
54 | 51 |
} |
55 | 52 |
else { |
56 | 53 |
// Create the line chart |
57 |
chart = this.getChartsEngine().createXYLineChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, SpecificitiesCoreMessages.Charts_Y_AXIS_LABEL,
|
|
54 |
chart = this.getChartsEngine().createXYLineChart(dataset, specificitiesSelection.getName(), SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, SpecificitiesCoreMessages.Charts_Y_AXIS_LABEL,
|
|
58 | 55 |
true, false, true, true, true, false, false); |
59 | 56 |
} |
60 | 57 |
|
... | ... | |
86 | 83 |
@Override |
87 | 84 |
public void updateChart(Object chart, TXMResult result) { |
88 | 85 |
|
89 |
Specificities specificitiesResult = (Specificities) result;
|
|
86 |
SpecificitiesSelection specificitiesSelection = (SpecificitiesSelection) result;
|
|
90 | 87 |
JFreeChart jfcChart = (JFreeChart) chart; |
91 | 88 |
|
92 | 89 |
// freeze rendering |
... | ... | |
100 | 97 |
|
101 | 98 |
// Transpose the data set |
102 | 99 |
if(result.getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE)) { |
103 |
xAxisSymbols = new String[specificitiesResult.getSelectedTypeNames().length];
|
|
100 |
xAxisSymbols = new String[specificitiesSelection.getSelectedTypeNames().length];
|
|
104 | 101 |
|
105 |
for(int i = 0; i < specificitiesResult.getSelectedPartNames().length; i++) {
|
|
106 |
XYSeries series = new XYSeries(specificitiesResult.getSelectedPartNames()[i]);
|
|
102 |
for(int i = 0; i < specificitiesSelection.getSelectedPartNames().length; i++) {
|
|
103 |
XYSeries series = new XYSeries(specificitiesSelection.getSelectedPartNames()[i]);
|
|
107 | 104 |
dataset.addSeries(series); |
108 | 105 |
|
109 |
for(int j = 0; j < specificitiesResult.getSelectedTypeNames().length; j++) {
|
|
110 |
series.add(j, specificitiesResult.getSelectedSpecificitiesIndex()[j][i]);
|
|
106 |
for(int j = 0; j < specificitiesSelection.getSelectedTypeNames().length; j++) {
|
|
107 |
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[j][i]);
|
|
111 | 108 |
// Add X axis symbol |
112 |
xAxisSymbols[j] = specificitiesResult.getSelectedTypeNames()[j];
|
|
109 |
xAxisSymbols[j] = specificitiesSelection.getSelectedTypeNames()[j];
|
|
113 | 110 |
} |
114 | 111 |
} |
115 | 112 |
|
116 | 113 |
} |
117 | 114 |
else { |
118 |
xAxisSymbols = new String[specificitiesResult.getSelectedPartNames().length];
|
|
115 |
xAxisSymbols = new String[specificitiesSelection.getSelectedPartNames().length];
|
|
119 | 116 |
|
120 |
for(int i = 0; i < specificitiesResult.getSelectedTypeNames().length; i++) {
|
|
117 |
for(int i = 0; i < specificitiesSelection.getSelectedTypeNames().length; i++) {
|
|
121 | 118 |
|
122 |
XYSeries series = new XYSeries(specificitiesResult.getSelectedTypeNames()[i]);
|
|
119 |
XYSeries series = new XYSeries(specificitiesSelection.getSelectedTypeNames()[i]);
|
|
123 | 120 |
dataset.addSeries(series); |
124 | 121 |
|
125 |
for(int j = 0; j < specificitiesResult.getSelectedPartNames().length; j++) {
|
|
126 |
series.add(j, specificitiesResult.getSelectedSpecificitiesIndex()[i][j]);
|
|
122 |
for(int j = 0; j < specificitiesSelection.getSelectedPartNames().length; j++) {
|
|
123 |
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[i][j]);
|
|
127 | 124 |
// Add X axis symbol |
128 |
xAxisSymbols[j] = specificitiesResult.getSelectedPartNames()[j];
|
|
125 |
xAxisSymbols[j] = specificitiesSelection.getSelectedPartNames()[j];
|
|
129 | 126 |
} |
130 | 127 |
} |
131 | 128 |
} |
... | ... | |
153 | 150 |
|
154 | 151 |
@Override |
155 | 152 |
public Class getResultDataClass() { |
156 |
return Specificities.class; |
|
153 |
return SpecificitiesSelection.class;
|
|
157 | 154 |
} |
158 | 155 |
|
159 | 156 |
|
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/r/RSpecificitiesBarChartCreator.java (revision 544) | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
6 | 6 |
import org.txm.chartsengine.r.core.RChartCreator; |
7 |
import org.txm.core.preferences.TXMPreferences; |
|
8 | 7 |
import org.txm.core.results.TXMResult; |
9 |
import org.txm.specificities.core.functions.Specificities; |
|
8 |
import org.txm.specificities.core.functions.SpecificitiesSelection;
|
|
10 | 9 |
import org.txm.specificities.core.messages.SpecificitiesCoreMessages; |
11 | 10 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
12 | 11 |
import org.txm.statsengine.core.data.Matrix; |
... | ... | |
17 | 16 |
import org.txm.utils.logger.Log; |
18 | 17 |
|
19 | 18 |
/** |
20 |
* Creates a partition dimensions bar chart from the specified <code>Partition</code> result.
|
|
19 |
* Creates a bar chart from the specified <code>SpecificitiesSelection</code> result.
|
|
21 | 20 |
* @author sjacquot |
22 | 21 |
* |
23 | 22 |
*/ |
... | ... | |
30 | 29 |
|
31 | 30 |
try { |
32 | 31 |
|
33 |
Specificities specificitiesResult = (Specificities) result;
|
|
32 |
SpecificitiesSelection specificitiesSelection = (SpecificitiesSelection) result;
|
|
34 | 33 |
|
35 | 34 |
// parameters |
36 | 35 |
boolean transpose = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE); |
... | ... | |
46 | 45 |
// TODO: should filter max and min here |
47 | 46 |
// specIndex |
48 | 47 |
|
49 |
Matrix spec = new DoubleMatrix(specificitiesResult.getSelectedSpecificitiesIndex());
|
|
50 |
Vector types = new VectorImpl(specificitiesResult.getSelectedTypeNames());
|
|
51 |
Vector parts = new VectorImpl(specificitiesResult.getSelectedPartNames());
|
|
48 |
Matrix spec = new DoubleMatrix(specificitiesSelection.getSelectedSpecificitiesIndex());
|
|
49 |
Vector types = new VectorImpl(specificitiesSelection.getSelectedTypeNames());
|
|
50 |
Vector parts = new VectorImpl(specificitiesSelection.getSelectedPartNames());
|
|
52 | 51 |
|
53 | 52 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
54 | 53 |
rw.eval("rownames(" + spec.getSymbol() + ") <- " + types.getSymbol() + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
... | ... | |
73 | 72 |
// Title |
74 | 73 |
String title = ""; |
75 | 74 |
if(result.getBooleanParameterValue(ChartsEnginePreferences.SHOW_TITLE)) { |
76 |
title = specificitiesResult.getName();
|
|
75 |
title = specificitiesSelection.getName();
|
|
77 | 76 |
} |
78 | 77 |
|
79 | 78 |
|
... | ... | |
81 | 80 |
int itemsCount = 0; |
82 | 81 |
// to put one color per part |
83 | 82 |
if (transpose) { |
84 |
itemsCount = specificitiesResult.getSelectedPartNames().length;
|
|
83 |
itemsCount = specificitiesSelection.getSelectedPartNames().length;
|
|
85 | 84 |
} |
86 | 85 |
// to put one color per word |
87 | 86 |
else { |
88 |
itemsCount = specificitiesResult.getSelectedTypeNames().length;
|
|
87 |
itemsCount = specificitiesSelection.getSelectedTypeNames().length;
|
|
89 | 88 |
} |
90 | 89 |
|
91 | 90 |
String[] colors = new String[itemsCount]; |
... | ... | |
175 | 174 |
|
176 | 175 |
@Override |
177 | 176 |
public Class getResultDataClass() { |
178 |
return Specificities.class; |
|
177 |
return SpecificitiesSelection.class;
|
|
179 | 178 |
} |
180 | 179 |
|
181 | 180 |
} |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Chi2.java (revision 544) | ||
---|---|---|
15 | 15 |
} |
16 | 16 |
|
17 | 17 |
@Override |
18 |
public boolean setParameters(TXMParameters parameters) { |
|
19 |
return false; |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 | 18 |
protected boolean _compute(boolean update) throws StatException { |
24 | 19 |
itable = table.getData(); |
25 | 20 |
colNames = itable.getColNames().asStringsArray(); |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Specificites2.java (revision 544) | ||
---|---|---|
54 | 54 |
return itable != null; |
55 | 55 |
} |
56 | 56 |
|
57 |
@Override |
|
58 |
public boolean setParameters(TXMParameters parameters) { |
|
59 |
return false; |
|
60 |
} |
|
61 | 57 |
} |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/RelativeFrequency.java (revision 544) | ||
---|---|---|
63 | 63 |
return itable != null; |
64 | 64 |
} |
65 | 65 |
|
66 |
@Override |
|
67 |
public boolean setParameters(TXMParameters parameters) { |
|
68 |
return false; |
|
69 |
} |
|
70 | 66 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 544) | ||
---|---|---|
180 | 180 |
|
181 | 181 |
monitor.worked(45); |
182 | 182 |
|
183 |
lexicalTableAble.getParent().addResult(table);
|
|
183 |
lexicalTableAble.getParent().addChild(table);
|
|
184 | 184 |
|
185 | 185 |
monitor.worked(5); |
186 | 186 |
|
... | ... | |
275 | 275 |
return Status.CANCEL_STATUS; |
276 | 276 |
} |
277 | 277 |
|
278 |
partition.addResult(table);
|
|
278 |
partition.addChild(table);
|
|
279 | 279 |
|
280 | 280 |
monitor.worked(5); |
281 | 281 |
|
... | ... | |
475 | 475 |
if (monitor.isCanceled() || table == null) |
476 | 476 |
return Status.CANCEL_STATUS; |
477 | 477 |
|
478 |
firstIndex.addResult(table);
|
|
478 |
firstIndex.addChild(table);
|
|
479 | 479 |
monitor.worked(5); |
480 | 480 |
|
481 | 481 |
monitor.subTask(RCPMessages.ComputeLexicalTable_10); |
tmp/org.txm.groovy.core/src/groovy/org/txm/test/CQPBenchmark.groovy (revision 544) | ||
---|---|---|
288 | 288 |
CA ca = new CA(discours_dates, word_property, 0 ,9999999) |
289 | 289 |
ca.stepLexicalTable(); |
290 | 290 |
ca.stepSortTableLexical(); |
291 |
ca.stepCompute()
|
|
291 |
ca.compute()
|
|
292 | 292 |
ca.toSVGFactorialMap(new File(exporttestdir,"cadates"), true, true) |
293 | 293 |
ca.toSVGSingularValues(new File(exporttestdir,"cadates_singularvalues")) |
294 | 294 |
if (firstExecution == 0) |
... | ... | |
300 | 300 |
print " AFC" |
301 | 301 |
time = System.currentTimeMillis(); |
302 | 302 |
CA ca2 = new CA(table); |
303 |
ca2.stepCompute()
|
|
303 |
ca2.compute()
|
|
304 | 304 |
ca2.toSVGFactorialMap(new File(exporttestdir,"cadates"), true, true) |
305 | 305 |
ca2.toSVGSingularValues(new File(exporttestdir,"cadates_singularvalues")) |
306 | 306 |
if (firstExecution == 0) |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/r/data/LexicalTableImpl.java (revision 544) | ||
---|---|---|
126 | 126 |
* @param symbol the symbol |
127 | 127 |
* @throws RWorkspaceException the r workspace exception |
128 | 128 |
*/ |
129 |
public LexicalTableImpl(LexicalTableImpl table, String symbol) |
|
130 |
throws RWorkspaceException { |
|
129 |
public LexicalTableImpl(LexicalTableImpl table, String symbol) throws RWorkspaceException { |
|
131 | 130 |
super(symbol); |
132 | 131 |
initSortedIndex(); |
133 | 132 |
} |
... | ... | |
140 | 139 |
* @param symbol the symbol |
141 | 140 |
* @throws RWorkspaceException the r workspace exception |
142 | 141 |
*/ |
143 |
public LexicalTableImpl(String symbol) |
|
144 |
throws RWorkspaceException { |
|
142 |
public LexicalTableImpl(String symbol) throws RWorkspaceException { |
|
145 | 143 |
super(symbol); |
146 | 144 |
} |
147 | 145 |
|
146 |
/** |
|
147 |
* |
|
148 |
* @param symbol |
|
149 |
* @param corpusLexicon |
|
150 |
* @param subcorpusLexicon |
|
151 |
* @throws StatException |
|
152 |
*/ |
|
148 | 153 |
public LexicalTableImpl(String symbol, Lexicon corpusLexicon, Lexicon subcorpusLexicon) throws StatException { |
149 | 154 |
super(symbol); |
150 | 155 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
... | ... | |
190 | 195 |
BufferedReader reader = new BufferedReader(new FileReader(f)); |
191 | 196 |
int i = 0; |
192 | 197 |
|
193 |
while(reader.readLine() != null) i++; |
|
198 |
while(reader.readLine() != null) { |
|
199 |
i++; |
|
200 |
} |
|
194 | 201 |
return i; |
195 | 202 |
} catch (Exception e) { return 0; } |
196 | 203 |
} |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTableFactory.java (revision 544) | ||
---|---|---|
5 | 5 |
import java.util.List; |
6 | 6 |
import java.util.Map; |
7 | 7 |
|
8 |
import org.txm.core.results.TXMResult; |
|
9 |
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable; |
|
10 | 8 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
11 | 9 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
12 | 10 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
... | ... | |
14 | 12 |
import org.txm.searchengine.cqp.corpus.Partition; |
15 | 13 |
import org.txm.searchengine.cqp.corpus.Property; |
16 | 14 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
17 |
import org.txm.statsengine.core.StatException; |
|
18 |
import org.txm.statsengine.core.data.Vector; |
|
19 | 15 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
20 | 16 |
|
21 | 17 |
public class LexicalTableFactory { |
... | ... | |
25 | 21 |
* |
26 | 22 |
* @param partition the partition |
27 | 23 |
* @param analysisProperty the analysis property |
28 |
* @param Fmin the fmin
|
|
24 |
* @param fMin the fmin
|
|
29 | 25 |
* @param vmax |
30 | 26 |
* @return the lexical table |
31 | 27 |
* @throws CqiClientException the cqi client exception |
32 | 28 |
* @throws RWorkspaceException the r workspace exception |
33 | 29 |
*/ |
34 |
public static final LexicalTable getLexicalTable(Partition partition, |
|
35 |
Property analysisProperty, int Fmin) throws Exception { |
|
30 |
public static final LexicalTable getLexicalTable(Partition partition, Property analysisProperty, int fMin) throws Exception { |
|
36 | 31 |
//long time = System.currentTimeMillis(); |
37 | 32 |
List<Lexicon> lexicons = new ArrayList<Lexicon>(); |
38 | 33 |
// Set<String> allLexiconEntry = new HashSet<String>(); |
... | ... | |
49 | 44 |
ArrayList<String> filteredForms = new ArrayList<String>(); |
50 | 45 |
//create a copy and filter line with Fmin; |
51 | 46 |
for (int i = 0 ; i < ll.getFreq().length ; i++) { |
52 |
if (ll.getFreq()[i] >= Fmin) {
|
|
47 |
if (ll.getFreq()[i] >= fMin) {
|
|
53 | 48 |
filteredForms.add(ll.getForms()[i]); |
54 | 49 |
} |
55 | 50 |
} |
... | ... | |
73 | 68 |
for (int j = 0; j < freqs.length; j++) { |
74 | 69 |
id = entries2index.get(ents[j]); |
75 | 70 |
// if (entriesFreqs[id] >= 2) |
76 |
if (id != null) |
|
71 |
if (id != null) {
|
|
77 | 72 |
mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]); |
73 |
} |
|
78 | 74 |
} |
79 | 75 |
} |
80 | 76 |
//System.out.println("time build matrix "+(System.currentTimeMillis()-time)); |
... | ... | |
83 | 79 |
//System.out.println("mat size " + mat.rows()); |
84 | 80 |
//System.out.println("mat columns " + mat.columns()); |
85 | 81 |
|
86 |
LexicalTableImpl itable = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames() |
|
87 |
.toArray(new String[] {})); |
|
82 |
LexicalTableImpl iTable = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames().toArray(new String[] {})); |
|
88 | 83 |
|
89 |
LexicalTable table = new LexicalTable(partition, |
|
90 |
analysisProperty, Fmin, itable); |
|
84 |
LexicalTable table = new LexicalTable(partition, analysisProperty, fMin, iTable); |
|
91 | 85 |
//System.out.println("time build table lexical "+(System.currentTimeMillis()-time)); |
92 | 86 |
return table; |
93 | 87 |
} |
94 | 88 |
|
89 |
/** |
|
90 |
* |
|
91 |
* @param subcorpus |
|
92 |
* @param property |
|
93 |
* @return |
|
94 |
* @throws Exception |
|
95 |
*/ |
|
95 | 96 |
public static LexicalTable getLexicalTable(Subcorpus subcorpus, Property property) throws Exception { |
96 |
LexicalTable table = new LexicalTable(subcorpus, property); |
|
97 |
return table; |
|
97 |
return new LexicalTable(subcorpus, property); |
|
98 | 98 |
} |
99 | 99 |
} |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 544) | ||
---|---|---|
8 | 8 |
import java.util.List; |
9 | 9 |
import java.util.Map; |
10 | 10 |
|
11 |
import org.txm.core.results.TXMParameters; |
|
12 | 11 |
import org.txm.core.results.TXMResult; |
13 | 12 |
import org.txm.index.core.functions.Index; |
14 | 13 |
import org.txm.index.core.functions.Line; |
15 | 14 |
import org.txm.lexicaltable.core.messages.LexicalTableCoreMessages; |
16 |
import org.txm.lexicaltable.core.preferences.LexicalTablePreferences; |
|
17 | 15 |
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable; |
18 | 16 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
19 | 17 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
... | ... | |
26 | 24 |
import org.txm.statsengine.core.data.Vector; |
27 | 25 |
import org.txm.statsengine.r.core.RWorkspace; |
28 | 26 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
29 |
import org.txm.utils.logger.Log; |
|
30 | 27 |
|
31 | 28 |
/** |
32 | 29 |
* ILexicalTable logic + TXMResult management methods |
... | ... | |
37 | 34 |
public class LexicalTable extends TXMResult { |
38 | 35 |
|
39 | 36 |
public static Integer LEXICALTABLE_COUNTER = new Integer(1); |
40 |
public static String SYMBOL_BASE = "LexicalTable_"; |
|
37 |
public static String SYMBOL_BASE = "LexicalTable_"; //$NON-NLS-1$
|
|
41 | 38 |
|
42 | 39 |
/** the statengine data object */ |
43 | 40 |
ILexicalTable data; |
... | ... | |
76 | 73 |
} |
77 | 74 |
|
78 | 75 |
/** |
76 |
* |
|
77 |
* @param partition |
|
78 |
* @param analysisProperty |
|
79 |
* @param fmin |
|
80 |
* @param itable |
|
81 |
*/ |
|
82 |
public LexicalTable(Partition partition, Property analysisProperty, int fmin, LexicalTableImpl itable) { |
|
83 |
super(partition); |
|
84 |
this.pProperty = analysisProperty; |
|
85 |
this.data = itable; |
|
86 |
} |
|
87 |
|
|
88 |
public LexicalTable(Subcorpus subcorpus) throws Exception { |
|
89 |
this(subcorpus, subcorpus.getProperty("word")); //$NON-NLS-1$ |
|
90 |
} |
|
91 |
|
|
92 |
public LexicalTable(Subcorpus subcorpus, Property property) throws Exception { |
|
93 |
super(subcorpus); |
|
94 |
this.pProperty = property; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
79 | 98 |
* Creates the lexical table. |
80 | 99 |
* |
81 | 100 |
* @param vocabularies the vocabularies |
... | ... | |
84 | 103 |
* @return the lexical table |
85 | 104 |
* @throws RWorkspaceException the r workspace exception |
86 | 105 |
*/ |
87 |
protected void _computeForIndex(List<Index> vocabularies) |
|
88 |
throws RWorkspaceException { |
|
106 |
protected void _computeForIndex(List<Index> vocabularies) throws RWorkspaceException { |
|
89 | 107 |
System.out.println(LexicalTableCoreMessages.LexicalTableImpl_1 + vocabularies); |
90 | 108 |
Index partindex = vocabularies.get(0);// FRIGO |
91 | 109 |
Partition partition = partindex.getPartition(); // the Index is computed on a partition |
92 | 110 |
|
93 |
if (!partindex.isComputedWithPartition()) |
|
111 |
if (!partindex.isComputedWithPartition()) {
|
|
94 | 112 |
throw new IllegalArgumentException("Vocabularies are not computed with a partition. Aborting."); |
113 |
} |
|
95 | 114 |
|
96 | 115 |
this.pProperty = partindex.getProperties().get(0); |
97 | 116 |
|
... | ... | |
103 | 122 |
Line ll = alllines.get(l.getSignature()); |
104 | 123 |
int[] c1 = ll.getFrequencies(); |
105 | 124 |
int[] c2 = l.getFrequencies(); |
106 |
for (int i = 0; i < c1.length; i++) |
|
125 |
for (int i = 0; i < c1.length; i++) {
|
|
107 | 126 |
c2[i] += c1[i]; |
127 |
} |
|
108 | 128 |
ll.setCounts(c2, 0.0f); |
109 |
} else |
|
129 |
} |
|
130 |
else { |
|
110 | 131 |
alllines.put(l.toString(), l); |
132 |
} |
|
111 | 133 |
} |
112 | 134 |
} |
113 | 135 |
|
... | ... | |
119 | 141 |
rownames.add(l.toString()); |
120 | 142 |
} |
121 | 143 |
int extra = 0; |
122 |
if (pUseAllOccurrences) |
|
144 |
if (pUseAllOccurrences) {
|
|
123 | 145 |
extra = 1; |
146 |
} |
|
124 | 147 |
|
125 | 148 |
String[] entries = new String[alllines.size() + extra]; |
126 | 149 |
|
... | ... | |
163 | 186 |
//System.out.println("mat size : ["+(rownames.size() + extra)+"]["+colnames.size()+"]"); |
164 | 187 |
//System.out.println("rownames size : "+rownames.size()); |
165 | 188 |
//System.out.println("colnames size : "+colnames.size()); |
166 |
this.data = new LexicalTableImpl(mat, rownames.toArray(new String[] {}), colnames |
|
167 |
.toArray(new String[] {})); |
|
189 |
this.data = new LexicalTableImpl(mat, rownames.toArray(new String[] {}), colnames.toArray(new String[] {})); |
|
168 | 190 |
} |
169 | 191 |
|
170 |
/** |
|
171 |
* |
|
172 |
* @param partition |
|
173 |
* @param analysisProperty |
|
174 |
* @param fmin |
|
175 |
* @param itable |
|
176 |
*/ |
|
177 |
public LexicalTable(Partition partition, Property analysisProperty, int fmin, LexicalTableImpl itable) { |
|
178 |
super(partition); |
|
179 |
this.pProperty = analysisProperty; |
|
180 |
this.data = itable; |
|
181 |
} |
|
182 | 192 |
|
183 |
public LexicalTable(Subcorpus subcorpus) throws Exception { |
|
184 |
this(subcorpus, subcorpus.getProperty("word")); |
|
185 |
} |
|
186 |
|
|
187 |
public LexicalTable(Subcorpus subcorpus, Property property) throws Exception { |
|
188 |
super(subcorpus); |
|
189 |
this.pProperty = property; |
|
190 |
} |
|
191 |
|
|
192 | 193 |
@Override |
193 | 194 |
protected boolean _compute(boolean update) throws Exception { |
194 | 195 |
|
... | ... | |
204 | 205 |
return false; |
205 | 206 |
} |
206 | 207 |
|
208 |
/** |
|
209 |
* |
|
210 |
* @param partition |
|
211 |
* @throws Exception |
|
212 |
*/ |
|
207 | 213 |
protected void _computeForPartition(Partition partition) throws Exception { |
208 | 214 |
//long time = System.currentTimeMillis(); |
209 | 215 |
List<Lexicon> lexicons = new ArrayList<Lexicon>(); |
... | ... | |
245 | 251 |
for (int j = 0; j < freqs.length; j++) { |
246 | 252 |
id = entries2index.get(ents[j]); |
247 | 253 |
// if (entriesFreqs[id] >= 2) |
248 |
if (id != null) |
|
254 |
if (id != null) {
|
|
249 | 255 |
mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]); |
256 |
} |
|
250 | 257 |
} |
251 | 258 |
} |
252 | 259 |
//System.out.println("time build matrix "+(System.currentTimeMillis()-time)); |
... | ... | |
255 | 262 |
//System.out.println("mat size " + mat.rows()); |
256 | 263 |
//System.out.println("mat columns " + mat.columns()); |
257 | 264 |
|
258 |
data = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames() |
|
259 |
.toArray(new String[] {})); |
|
265 |
data = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames().toArray(new String[] {})); |
|
260 | 266 |
|
261 | 267 |
} |
262 | 268 |
|
263 | 269 |
@Override |
264 | 270 |
public boolean canCompute() { |
265 |
return true; // can be computed on partition or corpus
|
|
271 |
return this.parent != null; // can be computed on partition or corpus
|
|
266 | 272 |
} |
267 | 273 |
|
268 | 274 |
@Override |
... | ... | |
293 | 299 |
if (parent instanceof Partition) return ((Partition)parent).getCorpus(); |
294 | 300 |
if (parent instanceof Index) return ((Index)parent).getCorpus(); |
295 | 301 |
else return null; |
302 |
// FIXME: prove this above method, it should work, but.... |
|
303 |
//return this.getFirstCorpusParent(); |
|
296 | 304 |
} |
297 | 305 |
|
298 | 306 |
public ILexicalTable getData() { |
... | ... | |
310 | 318 |
|
311 | 319 |
@Override |
312 | 320 |
public String getName() { |
313 |
return this.getPartition().getSimpleName() + ":" + this.getSimpleName(); //$NON-NLS-1$ |
|
321 |
try { |
|
322 |
return this.getPartition().getSimpleName() + ":" + this.getSimpleName(); //$NON-NLS-1$ |
|
323 |
} |
|
324 |
catch(Exception e) { |
|
325 |
} |
|
326 |
return ""; |
|
314 | 327 |
} |
315 | 328 |
|
316 | 329 |
public int getNColumns() { |
... | ... | |
374 | 387 |
/** |
375 | 388 |
* see LexicalTablePreferences.PROPERTY, LexicalTablePreferences.F_MIN, LexicalTablePreferences.V_MAX and LexicalTablePreferences.USEALLOCCURENCES |
376 | 389 |
*/ |
377 |
@Override |
|
378 |
public boolean setParameters(TXMParameters parameters) { |
|
379 |
try { |
|
380 |
if (parameters.get(LexicalTablePreferences.PROPERTY) != null) { |
|
381 |
Object o = parameters.get(LexicalTablePreferences.PROPERTY); |
|
382 |
if (o instanceof Property) this.pProperty = (Property) o; |
|
383 |
else if (o instanceof String) this.pProperty = this.getCorpus().getProperty(o.toString()); |
|
384 |
} |
|
385 |
if (parameters.get(LexicalTablePreferences.F_MIN) != null) { |
|
386 |
Object o = parameters.get(LexicalTablePreferences.F_MIN); |
|
387 |
if (o instanceof Integer) this.pFminFilter = (Integer)o; |
|
388 |
else if (o instanceof String) this.pFminFilter = Integer.parseInt(o.toString()); |
|
389 |
} |
|
390 |
if (parameters.get(LexicalTablePreferences.V_MAX) != null) { |
|
391 |
Object o = parameters.get(LexicalTablePreferences.V_MAX); |
|
392 |
if (o instanceof Integer) this.pVMaxFilter = (Integer)o; |
|
393 |
else if (o instanceof String) this.pVMaxFilter = Integer.parseInt(o.toString()); |
|
394 |
} |
|
395 |
if (parameters.get(LexicalTablePreferences.USEALLOCCURENCES) != null) { |
|
396 |
Object o = parameters.get(LexicalTablePreferences.USEALLOCCURENCES); |
|
397 |
if (o instanceof Boolean) this.pUseAllOccurrences = (Boolean)o; |
|
398 |
else if (o instanceof Integer) this.pUseAllOccurrences = (Integer)o > 0; |
|
399 |
else if (o instanceof String) this.pUseAllOccurrences = Boolean.parseBoolean(o.toString()); |
|
400 |
} |
|
390 |
// public boolean setParameters(TXMParameters parameters) { |
|
391 |
// try { |
|
392 |
// if (parameters.get(LexicalTablePreferences.PROPERTY) != null) { |
|
393 |
// Object o = parameters.get(LexicalTablePreferences.PROPERTY); |
|
394 |
// if (o instanceof Property) this.pProperty = (Property) o; |
|
395 |
// else if (o instanceof String) this.pProperty = this.getCorpus().getProperty(o.toString()); |
|
396 |
// } |
|
397 |
// if (parameters.get(LexicalTablePreferences.F_MIN) != null) { |
|
398 |
// Object o = parameters.get(LexicalTablePreferences.F_MIN); |
|
399 |
// if (o instanceof Integer) this.pFminFilter = (Integer)o; |
|
400 |
// else if (o instanceof String) this.pFminFilter = Integer.parseInt(o.toString()); |
|
401 |
// } |
|
402 |
// if (parameters.get(LexicalTablePreferences.V_MAX) != null) { |
|
403 |
// Object o = parameters.get(LexicalTablePreferences.V_MAX); |
|
404 |
// if (o instanceof Integer) this.pVMaxFilter = (Integer)o; |
|
405 |
// else if (o instanceof String) this.pVMaxFilter = Integer.parseInt(o.toString()); |
|
406 |
// } |
|
407 |
// if (parameters.get(LexicalTablePreferences.USEALLOCCURENCES) != null) { |
|
408 |
// Object o = parameters.get(LexicalTablePreferences.USEALLOCCURENCES); |
|
409 |
// if (o instanceof Boolean) this.pUseAllOccurrences = (Boolean)o; |
|
410 |
// else if (o instanceof Integer) this.pUseAllOccurrences = (Integer)o > 0; |
|
411 |
// else if (o instanceof String) this.pUseAllOccurrences = Boolean.parseBoolean(o.toString()); |
|
412 |
// } |
|
413 |
// |
|
414 |
// dirty = true; |
|
415 |
// } catch (Exception e) { |
|
416 |
// System.out.println("Error while setting LexicalTable parameters: "+e.getLocalizedMessage()); |
|
417 |
// Log.printStackTrace(e); |
|
418 |
// return false; |
|
419 |
// } |
|
420 |
// return true; |
|
421 |
// } |
|
401 | 422 |
|
402 |
dirty = true; |
|
403 |
} catch (Exception e) { |
|
404 |
System.out.println("Error while setting LexicalTable parameters: "+e.getLocalizedMessage()); |
|
405 |
Log.printStackTrace(e); |
|
406 |
return false; |
|
407 |
} |
|
408 |
return true; |
|
409 |
} |
|
410 |
|
|
411 | 423 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) { |
412 | 424 |
return data.toTxt(outfile, encoding, colseparator, txtseparator); |
413 | 425 |
} |
tmp/org.txm.cah.core/src/org/txm/cah/core/functions/AHC.java (revision 544) | ||
---|---|---|
133 | 133 |
dirty = true; |
134 | 134 |
} |
135 | 135 |
|
136 |
@Override |
|
137 |
public boolean setParameters(TXMParameters parameters) { |
|
138 |
try { |
|
139 |
Boolean columns = this.getBooleanParameterValue(AHCPreferences.COLUMNS_COMPUTING); |
|
140 |
String metric = this.getStringParameterValue(AHCPreferences.METRIC); |
|
141 |
Integer nCluster = this.getIntParameterValue(AHCPreferences.N_CLUSTERS); |
|
142 |
String method = this.getStringParameterValue(AHCPreferences.METHOD); |
|
143 |
this.setParameters(columns, metric, nCluster, method); |
|
144 |
} catch(Exception e) { |
|
145 |
System.out.println("Error while setting CAH parameters: "+e.getLocalizedMessage()); |
|
146 |
return false; |
|
147 |
} |
|
148 |
return true; |
|
136 |
|
|
137 |
public void loadParameters() { |
|
138 |
this.setParameters( |
|
139 |
this.getBooleanParameterValue(AHCPreferences.COLUMNS_COMPUTING), |
|
140 |
this.getStringParameterValue(AHCPreferences.METRIC), |
|
141 |
this.getIntParameterValue(AHCPreferences.N_CLUSTERS), |
|
142 |
this.getStringParameterValue(AHCPreferences.METHOD) |
|
143 |
); |
|
149 | 144 |
} |
150 | 145 |
|
151 |
// @Override |
|
152 |
// public void loadParameters() { |
|
153 |
// this.setParameters( |
|
154 |
// this.getBooleanParameterValue(AHCPreferences.COLUMNS_COMPUTING), |
|
155 |
// this.getStringParameterValue(AHCPreferences.METRIC), |
|
156 |
// this.getIntParameterValue(AHCPreferences.N_CLUSTERS), |
|
157 |
// this.getStringParameterValue(AHCPreferences.METHOD) |
|
158 |
// ); |
|
159 |
// } |
|
160 |
|
|
161 | 146 |
|
162 | 147 |
@Override |
163 | 148 |
public boolean canCompute() { |
... | ... | |
217 | 202 |
@Override |
218 | 203 |
protected boolean _compute(boolean update) { |
219 | 204 |
|
205 |
this.loadParameters(); |
|
206 |
|
|
220 | 207 |
Log.info("Computing CAH..."); |
221 | 208 |
try { |
222 | 209 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/forms/ProgressionParametersComposite.java (revision 544) | ||
---|---|---|
1 |
package org.txm.progression.rcp.forms; |
|
2 |
import org.eclipse.swt.SWT; |
|
3 |
import org.eclipse.swt.custom.SashForm; |
|
4 |
import org.eclipse.swt.custom.ScrolledComposite; |
|
5 |
import org.eclipse.swt.layout.FillLayout; |
|
6 |
import org.eclipse.swt.layout.GridData; |
|
7 |
import org.eclipse.swt.layout.GridLayout; |
|
8 |
import org.eclipse.swt.widgets.Button; |
|
9 |
import org.eclipse.swt.widgets.Combo; |
|
10 |
import org.eclipse.swt.widgets.Composite; |
|
11 |
import org.eclipse.swt.widgets.Label; |
|
12 |
import org.eclipse.swt.widgets.Table; |
|
13 |
import org.eclipse.swt.widgets.Text; |
|
14 |
import org.txm.rcp.RCPMessages; |
|
15 |
|
|
16 |
|
|
17 |
public class ProgressionParametersComposite extends Composite { |
|
18 |
SashForm sashForm; |
|
19 |
|
|
20 |
private Table table; |
|
21 |
private Text scaleTextEdit; |
|
22 |
private Text regTextEdit; |
|
23 |
|
|
24 |
Button btnSupprimer; |
|
25 |
Button cumulBtn; |
|
26 |
Button densiBtn; |
|
27 |
|
|
28 |
Combo structCombo; |
|
29 |
Combo propCombo; |
|
30 |
private Button styleRadio; |
|
31 |
private Button repeatRadio; |
|
32 |
private Button NBRadio; |
|
33 |
private Button btnNewButton; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Creates the composite. |
|
38 |
* @param parent |
|
39 |
* @param style |
|
40 |
*/ |
|
41 |
public ProgressionParametersComposite(Composite parent, int style) { |
|
42 |
super(parent, style); |
|
43 |
|
|
44 |
|
|
45 |
//parent.setLayout(new GridLayout(1, true)); |
|
46 |
|
|
47 |
// ExpandBar bar = new ExpandBar(parent, SWT.NONE); |
|
48 |
|
|
49 |
// sashForm = new SashForm(parent, SWT.VERTICAL); |
|
50 |
// sashForm.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
ScrolledComposite scrolledComposite_1 = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); |
|
55 |
scrolledComposite_1.setExpandHorizontal(true); |
|
56 |
scrolledComposite_1.setExpandVertical(true); |
|
57 |
|
|
58 |
// Composite scrolledComposite_1 = new Composite(this, SWT.BORDER); |
|
59 |
|
|
60 |
Composite composite_1 = new Composite(scrolledComposite_1, SWT.NONE); |
|
61 |
composite_1.setLayout(new FillLayout(SWT.VERTICAL)); |
|
62 |
|
|
63 |
Composite composite = new Composite(composite_1, SWT.NONE); |
|
64 |
composite.setLayout(new GridLayout(5, false)); |
|
65 |
|
|
66 |
Label label = new Label(composite, SWT.NONE); |
|
67 |
GridData gd_label = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); |
|
68 |
gd_label.widthHint = 29; |
|
69 |
label.setLayoutData(gd_label); |
|
70 |
label.setText(RCPMessages.ProgressionForm_0); |
|
71 |
|
|
72 |
cumulBtn = new Button(composite, SWT.RADIO); |
|
73 |
cumulBtn.setText(RCPMessages.ProgressionForm_1); |
|
74 |
cumulBtn.setSelection(true); |
Formats disponibles : Unified diff