Révision 2672
| tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 2672) | ||
|---|---|---|
| 147 | 147 |
protected Spinner fMinSpinner; |
| 148 | 148 |
|
| 149 | 149 |
/** |
| 150 |
* Minimum frequency filter spinner. |
|
| 151 |
*/ |
|
| 152 |
@Parameter(key = LexicalTablePreferences.F_MAX) |
|
| 153 |
protected Spinner fMaxSpinner; |
|
| 154 |
|
|
| 155 |
/** |
|
| 150 | 156 |
* Maximum numbers of lines spinner. |
| 151 | 157 |
*/ |
| 152 | 158 |
@Parameter(key = LexicalTablePreferences.V_MAX) |
| ... | ... | |
| 162 | 168 |
public void _createPartControl() {
|
| 163 | 169 |
|
| 164 | 170 |
try {
|
| 165 |
lexicalTable = (LexicalTable) this.getResult();
|
|
| 171 |
lexicalTable = this.getResult(); |
|
| 166 | 172 |
|
| 167 | 173 |
// Main parameters |
| 168 | 174 |
GLComposite mainParametersArea = this.getMainParametersComposite(); |
| ... | ... | |
| 223 | 229 |
|
| 224 | 230 |
|
| 225 | 231 |
// thresholds |
| 226 |
ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), SWT.NONE, this, true, false);
|
|
| 232 |
ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), SWT.NONE, this, true, true);
|
|
| 227 | 233 |
this.fMinSpinner = thresholdsGroup.getFMinSpinner(); |
| 234 |
this.fMaxSpinner = thresholdsGroup.getFMaxSpinner(); |
|
| 228 | 235 |
this.vMaxSpinner = thresholdsGroup.getVMaxSpinner(); |
| 229 | 236 |
this.vMaxSpinner.setMinimum(1); |
| 230 | 237 |
|
| ... | ... | |
| 236 | 243 |
@Override |
| 237 | 244 |
public void widgetSelected(SelectionEvent e) {
|
| 238 | 245 |
StatusLine.setMessage(LexicalTableUIMessages.mergingLines); |
| 239 |
ArrayList<Object> selection = new ArrayList<Object>();
|
|
| 240 |
MergeDeleteDialog d = new MergeDeleteDialog(e.display.getActiveShell(), new ArrayList<Object>(collist), selection, -1);
|
|
| 246 |
ArrayList<Object> selection = new ArrayList<>(); |
|
| 247 |
MergeDeleteDialog d = new MergeDeleteDialog(e.display.getActiveShell(), new ArrayList<>(collist), selection, -1); |
|
| 241 | 248 |
|
| 242 | 249 |
if (d.open() == Window.OK) {
|
| 243 |
List<Integer> colindices = new ArrayList<Integer>();
|
|
| 250 |
List<Integer> colindices = new ArrayList<>(); |
|
| 244 | 251 |
for (int i = 0; i < collist.size(); i++) {
|
| 245 | 252 |
if (selection.contains(collist.get(i))) {
|
| 246 | 253 |
colindices.add(i); |
| ... | ... | |
| 284 | 291 |
lexicalTable.getData().removeCols(coltodelete); |
| 285 | 292 |
lexicalTable.setAltered(); |
| 286 | 293 |
// refresh stuff |
| 287 |
collist = new ArrayList<Object>();// update col name
|
|
| 294 |
collist = new ArrayList<>();// update col name |
|
| 288 | 295 |
// list |
| 289 | 296 |
try {
|
| 290 | 297 |
for (String colname : lexicalTable.getColNames().asStringsArray()) {
|
| ... | ... | |
| 311 | 318 |
lexicalTable.getData().removeCols(colindices); |
| 312 | 319 |
lexicalTable.setAltered(); |
| 313 | 320 |
|
| 314 |
collist = new ArrayList<Object>();
|
|
| 321 |
collist = new ArrayList<>(); |
|
| 315 | 322 |
Vector colnames = lexicalTable.getColNames(); |
| 316 | 323 |
try {
|
| 317 | 324 |
for (String colname : colnames.asStringsArray()) {
|
| ... | ... | |
| 345 | 352 |
@Override |
| 346 | 353 |
public void widgetSelected(SelectionEvent e) {
|
| 347 | 354 |
|
| 348 |
ArrayList<Object> selection = new ArrayList<Object>();
|
|
| 355 |
ArrayList<Object> selection = new ArrayList<>(); |
|
| 349 | 356 |
MergeDeleteDialog d = new MergeDeleteDialog(e.display |
| 350 | 357 |
.getActiveShell(), new ArrayList<Object>(rows), |
| 351 | 358 |
selection, -1); |
| ... | ... | |
| 450 | 457 |
} |
| 451 | 458 |
} |
| 452 | 459 |
|
| 460 |
@Override |
|
| 453 | 461 |
public void setContentDescription(String desc) {
|
| 454 | 462 |
infoLine.setText(desc); |
| 455 | 463 |
infoLine.update(); |
| ... | ... | |
| 490 | 498 |
|
| 491 | 499 |
try {
|
| 492 | 500 |
|
| 493 |
collist = new ArrayList<Object>();
|
|
| 501 |
collist = new ArrayList<>(); |
|
| 494 | 502 |
|
| 495 | 503 |
if (this.lexicalTable.getProperty() != null) {
|
| 496 | 504 |
unitColumn.getColumn().setText(this.lexicalTable.getProperty().getName()); |
| tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 2672) | ||
|---|---|---|
| 85 | 85 |
// In not, clean and simplify the code |
| 86 | 86 |
List<PartitionIndex> partitionIndexes = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList(); |
| 87 | 87 |
|
| 88 |
ArrayList<String> choices = new ArrayList<String>();
|
|
| 88 |
ArrayList<String> choices = new ArrayList<>(); |
|
| 89 | 89 |
choices.add(LexicalTableUIMessages.useAllOccurrences); |
| 90 | 90 |
choices.add(LexicalTableUIMessages.userIndexOccurrences); |
| 91 | 91 |
ListDialog dialog = new ListDialog(window.getShell()); |
| ... | ... | |
| 146 | 146 |
lexicalTable.setUnitProperty(property); |
| 147 | 147 |
// transmit index fmin/fmax parameters |
| 148 | 148 |
lexicalTable.setFMinFilter(firstIndex.getFilterFmin()); |
| 149 |
lexicalTable.setVMaxFilter(firstIndex.getFilterVmax()); |
|
| 149 |
if (useAllOccurrences) {
|
|
| 150 |
lexicalTable.setVMaxFilter(firstIndex.getFilterVmax() + 1); // the #REST line is added, we need to add a line to vmax |
|
| 151 |
} |
|
| 152 |
else {
|
|
| 153 |
lexicalTable.setVMaxFilter(firstIndex.getFilterVmax()); |
|
| 154 |
} |
|
| 150 | 155 |
|
| 151 | 156 |
|
| 152 | 157 |
|
| tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 2672) | ||
|---|---|---|
| 41 | 41 |
* @author sjacquot |
| 42 | 42 |
* |
| 43 | 43 |
*/ |
| 44 |
// TODO: SJ: add a fMax filter |
|
| 45 | 44 |
public class LexicalTable extends TXMResult implements RResult {
|
| 46 | 45 |
|
| 47 | 46 |
public static Integer LEXICALTABLE_COUNTER = new Integer(1); |
| 48 | 47 |
|
| 49 | 48 |
public static String SYMBOL_BASE = "LexicalTable_"; //$NON-NLS-1$ |
| 50 | 49 |
|
| 51 |
/** stores the data computed */
|
|
| 50 |
/** stores the computed data */
|
|
| 52 | 51 |
protected ILexicalTable statsData; |
| 53 | 52 |
|
| 54 | 53 |
/** |
| 55 |
* The property. |
|
| 54 |
* The word property.
|
|
| 56 | 55 |
*/ |
| 57 | 56 |
@Parameter(key = TXMPreferences.UNIT_PROPERTY) |
| 58 | 57 |
private WordProperty property; |
| ... | ... | |
| 64 | 63 |
private int fMinFilter; |
| 65 | 64 |
|
| 66 | 65 |
/** |
| 67 |
* Maximum number of lines.
|
|
| 66 |
* Maximum frequency.
|
|
| 68 | 67 |
*/ |
| 68 |
@Parameter(key = TXMPreferences.F_MAX) |
|
| 69 |
private int fMaxFilter; |
|
| 70 |
|
|
| 71 |
/** |
|
| 72 |
* Maximum number of lines spinner. |
|
| 73 |
*/ |
|
| 69 | 74 |
@Parameter(key = TXMPreferences.V_MAX) |
| 70 | 75 |
private int vMaxFilter; |
| 71 | 76 |
|
| ... | ... | |
| 119 | 124 |
this.statsData = new LexicalTableImpl(matrix, rowNames, colNames); |
| 120 | 125 |
} |
| 121 | 126 |
catch (Exception e) {
|
| 122 |
e.printStackTrace();
|
|
| 127 |
Log.printStackTrace(e);
|
|
| 123 | 128 |
} |
| 124 | 129 |
} |
| 125 | 130 |
|
| ... | ... | |
| 138 | 143 |
this.statsData = new LexicalTableImpl(matrix, rowNames, colNames); |
| 139 | 144 |
} |
| 140 | 145 |
catch (Exception e) {
|
| 141 |
e.printStackTrace();
|
|
| 146 |
Log.printStackTrace(e);
|
|
| 142 | 147 |
} |
| 143 | 148 |
} |
| 144 | 149 |
|
| ... | ... | |
| 156 | 161 |
this.statsData = new LexicalTableImpl(matrix, rowNames, colNames); |
| 157 | 162 |
} |
| 158 | 163 |
catch (Exception e) {
|
| 159 |
e.printStackTrace();
|
|
| 164 |
Log.printStackTrace(e);
|
|
| 160 | 165 |
} |
| 161 | 166 |
} |
| 162 | 167 |
|
| ... | ... | |
| 166 | 171 |
this.property = this.getCorpus().getProperty(this.getStringParameterValue(TBXPreferences.UNIT_PROPERTY)); |
| 167 | 172 |
} |
| 168 | 173 |
catch (CqiClientException e) {
|
| 169 |
// TODO Auto-generated catch block |
|
| 170 |
e.printStackTrace(); |
|
| 174 |
Log.printStackTrace(e); |
|
| 171 | 175 |
return false; |
| 172 | 176 |
} |
| 173 | 177 |
return true; |
| ... | ... | |
| 198 | 202 |
ArrayList<String> filteredForms = new ArrayList<>(); |
| 199 | 203 |
// create a copy and filter line with Fmin; |
| 200 | 204 |
for (int i = 0; i < corpusLexicon.getFreq().length; i++) {
|
| 201 |
if (corpusLexicon.getFreq()[i] >= this.fMinFilter) {
|
|
| 205 |
int f = corpusLexicon.getFreq()[i]; |
|
| 206 |
if (this.fMinFilter <= f && f <= this.fMaxFilter) {
|
|
| 202 | 207 |
filteredForms.add(corpusLexicon.getForms()[i]); |
| 203 | 208 |
} |
| 204 | 209 |
} |
| ... | ... | |
| 324 | 329 |
// System.out.println("reste : "+Arrays.toString(reste));
|
| 325 | 330 |
} |
| 326 | 331 |
catch (CqiClientException e) {
|
| 327 |
// TODO Auto-generated catch block |
|
| 328 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
| 332 |
Log.printStackTrace(e); |
|
| 329 | 333 |
return null; |
| 330 | 334 |
} |
| 331 | 335 |
} |
| ... | ... | |
| 335 | 339 |
return new LexicalTableImpl(mat, rownames.toArray(new String[] {}), colnames.toArray(new String[] {}));
|
| 336 | 340 |
} |
| 337 | 341 |
|
| 338 |
|
|
| 339 | 342 |
@Override |
| 340 | 343 |
protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
|
| 341 | 344 |
|
| 342 | 345 |
if (this.pExternData) {
|
| 343 | 346 |
return this.statsData != null; |
| 344 | 347 |
} |
| 345 |
// FIXME: SJ: became useless? |
|
| 346 |
// this.statsData = null; // reset frequencies |
|
| 347 | 348 |
|
| 348 |
|
|
| 349 |
int vMaxFilter = this.vMaxFilter; |
|
| 350 |
|
|
| 351 | 349 |
if (this.parent instanceof Subcorpus) {
|
| 352 | 350 |
|
| 353 | 351 |
Subcorpus subcorpus = (Subcorpus) this.parent; |
| ... | ... | |
| 363 | 361 |
} |
| 364 | 362 |
else if (this.parent instanceof PartitionIndex) {
|
| 365 | 363 |
|
| 366 |
// FIXME: SJ: add 1 to vmax filter to manage the #RESTE# line when computed with corpora margins |
|
| 367 |
// need to validate |
|
| 368 |
if (this.useAllOccurrences) {
|
|
| 369 |
vMaxFilter++; |
|
| 370 |
} |
|
| 371 |
|
|
| 372 | 364 |
this.statsData = this._computeFromIndexes(Arrays.asList((PartitionIndex) this.parent)); |
| 373 | 365 |
} |
| 374 | 366 |
|
| ... | ... | |
| 377 | 369 |
} |
| 378 | 370 |
|
| 379 | 371 |
// apply filtering |
| 380 |
this.statsData.filter(vMaxFilter, this.fMinFilter);
|
|
| 372 |
this.statsData.filter(this.vMaxFilter, this.fMinFilter, this.fMaxFilter);
|
|
| 381 | 373 |
|
| 382 | 374 |
return true; |
| 383 | 375 |
} |
| ... | ... | |
| 401 | 393 |
if (parameters.containsKey(LexicalTablePreferences.F_MIN)) {
|
| 402 | 394 |
this.fMinFilter = parameters.getInteger(LexicalTablePreferences.F_MIN); |
| 403 | 395 |
} |
| 396 |
if (parameters.containsKey(LexicalTablePreferences.F_MAX)) {
|
|
| 397 |
this.fMaxFilter = parameters.getInteger(LexicalTablePreferences.F_MAX); |
|
| 398 |
} |
|
| 404 | 399 |
if (parameters.containsKey(LexicalTablePreferences.UNIT_PROPERTY)) {
|
| 405 | 400 |
String s = parameters.get(LexicalTablePreferences.UNIT_PROPERTY).toString(); |
| 406 | 401 |
this.property = getCorpus().getProperty(s); |
| ... | ... | |
| 433 | 428 |
} |
| 434 | 429 |
} |
| 435 | 430 |
catch (RWorkspaceException e) {
|
| 436 |
// TODO Auto-generated catch block |
|
| 437 |
e.printStackTrace(); |
|
| 431 |
Log.printStackTrace(e); |
|
| 438 | 432 |
} |
| 439 | 433 |
} |
| 440 | 434 |
|
| ... | ... | |
| 464 | 458 |
return statsData.getColNames(); |
| 465 | 459 |
} |
| 466 | 460 |
catch (Exception e) {
|
| 461 |
Log.printStackTrace(e); |
|
| 467 | 462 |
return null; |
| 468 | 463 |
} |
| 469 | 464 |
} |
| 470 | 465 |
|
| 471 |
|
|
| 472 | 466 |
public ILexicalTable getData() {
|
| 473 | 467 |
return statsData; |
| 474 | 468 |
} |
| ... | ... | |
| 489 | 483 |
} |
| 490 | 484 |
|
| 491 | 485 |
/** |
| 492 |
* Gets the maximum frequency filter.
|
|
| 486 |
* Gets the minimum frequency filter.
|
|
| 493 | 487 |
* |
| 494 |
* @return |
|
| 488 |
* @return the minimum frequency filter
|
|
| 495 | 489 |
*/ |
| 496 | 490 |
public int getFMinFilter() {
|
| 497 | 491 |
return this.fMinFilter; |
| 498 | 492 |
} |
| 499 | 493 |
|
| 494 |
/** |
|
| 495 |
* Gets the maximum frequency filter. |
|
| 496 |
* |
|
| 497 |
* @return the maximum frequency filter |
|
| 498 |
*/ |
|
| 499 |
public int getFMaxFilter() {
|
|
| 500 |
return this.fMaxFilter; |
|
| 501 |
} |
|
| 502 |
|
|
| 500 | 503 |
@Override |
| 501 | 504 |
public String getSimpleName() {
|
| 502 | 505 |
// if (statsData != null) {
|
| ... | ... | |
| 505 | 508 |
strb.append(property.getName() + " "); |
| 506 | 509 |
try {
|
| 507 | 510 |
// strb.append(this.getFMin() + " / " + this.getNRows()); |
| 508 |
strb.append(this.fMinFilter + " / " + this.vMaxFilter); |
|
| 511 |
strb.append(this.fMinFilter + "-" + this.fMaxFilter + " / " + this.vMaxFilter);
|
|
| 509 | 512 |
} |
| 510 | 513 |
catch (Exception e) {
|
| 511 |
// TODO Auto-generated catch block |
|
| 512 |
e.printStackTrace(); |
|
| 514 |
Log.printStackTrace(e); |
|
| 513 | 515 |
return this.getEmptyName(); |
| 514 | 516 |
} |
| 515 | 517 |
return strb.toString(); |
| ... | ... | |
| 521 | 523 |
} |
| 522 | 524 |
} |
| 523 | 525 |
|
| 524 |
|
|
| 525 | 526 |
@Override |
| 526 | 527 |
public String getName() {
|
| 527 | 528 |
try {
|
| 528 | 529 |
return this.getParent().getSimpleName() + ":" + this.getSimpleName(); //$NON-NLS-1$ |
| 529 | 530 |
} |
| 530 | 531 |
catch (Exception e) {
|
| 532 |
Log.printStackTrace(e); |
|
| 531 | 533 |
} |
| 532 | 534 |
return ""; |
| 533 | 535 |
} |
| 534 | 536 |
|
| 535 |
|
|
| 536 | 537 |
@Override |
| 537 | 538 |
public String getComputingStartMessage() {
|
| 538 | 539 |
// from partition index |
| ... | ... | |
| 592 | 593 |
return CQPCorpus.getFirstParentCorpus(this); |
| 593 | 594 |
} |
| 594 | 595 |
|
| 595 |
|
|
| 596 | 596 |
/** |
| 597 | 597 |
* Gets the parent partition of this lexical table. |
| 598 | 598 |
* |
| ... | ... | |
| 628 | 628 |
} |
| 629 | 629 |
} |
| 630 | 630 |
|
| 631 |
|
|
| 632 | 631 |
/** |
| 633 | 632 |
* Gets the maximum number of lines filter. |
| 634 | 633 |
* |
| ... | ... | |
| 658 | 657 |
} |
| 659 | 658 |
|
| 660 | 659 |
/** |
| 660 |
* Sets the maximum frequency filter. |
|
| 661 |
* |
|
| 662 |
* @param fMax |
|
| 663 |
*/ |
|
| 664 |
public void setFMaxFilter(int fMin) {
|
|
| 665 |
this.fMaxFilter = fMin; |
|
| 666 |
} |
|
| 667 |
|
|
| 668 |
/** |
|
| 661 | 669 |
* see LexicalTablePreferences.PROPERTY, LexicalTablePreferences.F_MIN, LexicalTablePreferences.V_MAX and LexicalTablePreferences.USEALLOCCURENCES |
| 662 | 670 |
*/ |
| 663 | 671 |
// public boolean setParameters(TXMParameters parameters) {
|
| ... | ... | |
| 709 | 717 |
} |
| 710 | 718 |
|
| 711 | 719 |
|
| 712 |
public void setParameters(WordProperty prop, Integer fmin, Integer vmax, Boolean useAllOccurrences) {
|
|
| 720 |
public void setParameters(WordProperty prop, Integer fmin, Integer fmax, Integer vmax, Boolean useAllOccurrences) {
|
|
| 713 | 721 |
if (prop != null) {
|
| 714 | 722 |
this.property = prop; |
| 715 | 723 |
} |
| 716 | 724 |
if (fmin != null) {
|
| 717 | 725 |
this.fMinFilter = fmin; |
| 718 | 726 |
} |
| 727 |
if (fmax != null) {
|
|
| 728 |
this.fMaxFilter = fmax; |
|
| 729 |
} |
|
| 719 | 730 |
if (vmax != null) {
|
| 720 | 731 |
this.vMaxFilter = vmax; |
| 721 | 732 |
} |
| ... | ... | |
| 725 | 736 |
this.dirty = true; |
| 726 | 737 |
} |
| 727 | 738 |
|
| 728 |
|
|
| 729 | 739 |
/** |
| 730 | 740 |
* @param useAllOccurrences the useAllOccurrences to set |
| 731 | 741 |
*/ |
| tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/preferences/LexicalTablePreferences.java (revision 2672) | ||
|---|---|---|
| 42 | 42 |
super.initializeDefaultPreferences(); |
| 43 | 43 |
Preferences preferences = this.getDefaultPreferencesNode(); |
| 44 | 44 |
preferences.putInt(F_MIN, 2); |
| 45 |
preferences.putInt(F_MAX, Integer.MAX_VALUE); |
|
| 45 | 46 |
preferences.putInt(V_MAX, 200); |
| 46 | 47 |
preferences.putBoolean(USE_ALL_OCCURRENCES, true); |
| 47 | 48 |
preferences.putBoolean(EXTERN_DATA, false); |
| tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/ILexicalTable.java (revision 2672) | ||
|---|---|---|
| 163 | 163 |
* |
| 164 | 164 |
* @param nlines the number of lines to keep |
| 165 | 165 |
*/ |
| 166 |
public abstract void cut(int nlines);
|
|
| 166 |
public abstract void cut(int before, int after);
|
|
| 167 | 167 |
|
| 168 | 168 |
/** |
| 169 | 169 |
* Filter. |
| ... | ... | |
| 172 | 172 |
* @param nlines the nlines |
| 173 | 173 |
* @param fmin the fmin |
| 174 | 174 |
*/ |
| 175 |
public abstract void filter(int nlines, int fmin) throws Exception; |
|
| 175 |
public abstract void filter(int nlines, int fmin, int fmax) throws Exception;
|
|
| 176 | 176 |
|
| 177 | 177 |
/** |
| 178 | 178 |
* Sets the order. |
Formats disponibles : Unified diff