Révision 842
| tmp/org.txm.cooccurrence.rcp/META-INF/MANIFEST.MF (revision 842) | ||
|---|---|---|
| 2 | 2 |
Export-Package: org.txm.cooccurrence.rcp.adapters,org.txm.cooccurrence |
| 3 | 3 |
.rcp.editors,org.txm.cooccurrence.rcp.handlers,org.txm.cooccurrence.r |
| 4 | 4 |
cp.messages,org.txm.cooccurrence.rcp.preferences |
| 5 |
Require-Bundle: org.txm.utils;visibility:=reexport,org.eclipse.osgi;bu |
|
| 6 |
ndle-version="3.10.2";visibility:=reexport,org.eclipse.core.runtime;b |
|
| 7 |
undle-version="3.10.0";visibility:=reexport,org.txm.searchengine.cqp. |
|
| 8 |
core;bundle-version="1.1.0";visibility:=reexport,org.txm.cooccurrence |
|
| 9 |
.core;bundle-version="1.0.0";visibility:=reexport,org.txm.concordance |
|
| 10 |
.core;bundle-version="1.0.0";visibility:=reexport,org.txm.statsengine |
|
| 11 |
.r.rcp;bundle-version="1.0.0";visibility:=reexport,org.eclipse.ui;bun |
|
| 12 |
dle-version="3.106.1";visibility:=reexport,org.txm.core;visibility:=r |
|
| 13 |
eexport,org.txm.rcp;visibility:=reexport,org.eclipse.core.expressions |
|
| 14 |
;bundle-version="3.4.600";visibility:=reexport,org.txm.searchengine.c |
|
| 15 |
ore;bundle-version="1.0.0";visibility:=reexport |
|
| 5 |
Require-Bundle: org.txm.utils;visibility:=reexport, |
|
| 6 |
org.eclipse.osgi;bundle-version="3.10.2";visibility:=reexport, |
|
| 7 |
org.eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport, |
|
| 8 |
org.txm.searchengine.cqp.core;bundle-version="1.1.0";visibility:=reexport, |
|
| 9 |
org.txm.cooccurrence.core;bundle-version="1.0.0";visibility:=reexport, |
|
| 10 |
org.txm.concordance.core;bundle-version="1.0.0";visibility:=reexport, |
|
| 11 |
org.txm.statsengine.r.rcp;bundle-version="1.0.0";visibility:=reexport, |
|
| 12 |
org.eclipse.ui;bundle-version="3.106.1";visibility:=reexport, |
|
| 13 |
org.txm.core;visibility:=reexport, |
|
| 14 |
org.txm.rcp;visibility:=reexport, |
|
| 15 |
org.eclipse.core.expressions;bundle-version="3.4.600";visibility:=reexport, |
|
| 16 |
org.txm.searchengine.core;bundle-version="1.0.0";visibility:=reexport |
|
| 16 | 17 |
Bundle-Vendor: Textometrie.org |
| 17 | 18 |
Bundle-Version: 1.0.0.qualifier |
| 18 | 19 |
Bundle-Name: Cooccurence RCP |
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 842) | ||
|---|---|---|
| 383 | 383 |
viewer.getTable().setFont(font); |
| 384 | 384 |
} |
| 385 | 385 |
|
| 386 |
// TODO replace this with a command+menucontribution |
|
| 387 |
// viewer.getTable().addMouseListener(new MouseAdapter() {
|
|
| 388 |
// @Override |
|
| 389 |
// public void mouseDoubleClick(MouseEvent e) {
|
|
| 390 |
// Point mouseposition = new Point(e.x |
|
| 391 |
// + viewer.getTable().getHorizontalBar() |
|
| 392 |
// .getSelection(), e.y); |
|
| 393 |
// int col = getPointedColumn(mouseposition); |
|
| 394 |
// //System.out.println("col "+col);
|
|
| 395 |
// switch(col) |
|
| 396 |
// {
|
|
| 397 |
// default: |
|
| 398 |
// IStructuredSelection selection = (IStructuredSelection) |
|
| 399 |
// viewer.getSelection(); |
|
| 400 |
// CooccurrencesToConcordances.link(CooccurrencesEditor.this, |
|
| 401 |
// selection); |
|
| 402 |
// } |
|
| 403 |
// } |
|
| 404 |
// }); |
|
| 405 |
|
|
| 406 | 386 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 407 | 387 |
|
| 408 | 388 |
viewer.setLabelProvider(new LineLabelProvider()); |
| ... | ... | |
| 496 | 476 |
setColComparator(new ScoreComparator(), scoreColumn); |
| 497 | 477 |
sort(); |
| 498 | 478 |
|
| 479 |
|
|
| 480 |
// Add double click, "Send to" command |
|
| 481 |
TXMEditor.addDoubleClickCommandListener(viewer.getTable(), "org.txm.links.rcp.commands.SendToConcordance"); //$NON-NLS-1$ |
|
| 482 |
|
|
| 483 |
// TODO replace this with a command+menucontribution |
|
| 484 |
// viewer.getTable().addMouseListener(new MouseAdapter() {
|
|
| 485 |
// @Override |
|
| 486 |
// public void mouseDoubleClick(MouseEvent e) {
|
|
| 487 |
// Point mouseposition = new Point(e.x |
|
| 488 |
// + viewer.getTable().getHorizontalBar() |
|
| 489 |
// .getSelection(), e.y); |
|
| 490 |
// int col = getPointedColumn(mouseposition); |
|
| 491 |
// //System.out.println("col "+col);
|
|
| 492 |
// switch(col) |
|
| 493 |
// {
|
|
| 494 |
// default: |
|
| 495 |
// IStructuredSelection selection = (IStructuredSelection) |
|
| 496 |
// viewer.getSelection(); |
|
| 497 |
// CooccurrencesToConcordances.link(CooccurrencesEditor.this, |
|
| 498 |
// selection); |
|
| 499 |
// } |
|
| 500 |
// } |
|
| 501 |
// }); |
|
| 502 |
|
|
| 499 | 503 |
// Register the context menu |
| 500 | 504 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
| 501 |
|
|
| 502 | 505 |
|
| 506 |
|
|
| 507 |
|
|
| 503 | 508 |
initializeFields(); |
| 504 | 509 |
|
| 505 | 510 |
for (TableColumn col : viewer.getTable().getColumns()) {
|
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/___CooccurrencesToConcordances.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.cooccurrence.rcp.handlers; |
|
| 29 |
|
|
| 30 |
import java.util.List; |
|
| 31 |
|
|
| 32 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 34 |
import org.eclipse.core.commands.ExecutionException; |
|
| 35 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 36 |
import org.eclipse.ui.IEditorPart; |
|
| 37 |
import org.eclipse.ui.IWorkbenchPage; |
|
| 38 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 39 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 40 |
import org.txm.concordance.core.functions.Concordance; |
|
| 41 |
import org.txm.cooccurrence.core.functions.Cooccurrence; |
|
| 42 |
import org.txm.cooccurrence.core.functions.Cooccurrence.CLine; |
|
| 43 |
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor; |
|
| 44 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 45 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 46 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
|
| 47 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
| 48 |
|
|
| 49 |
// TODO: Auto-generated Javadoc |
|
| 50 |
/** |
|
| 51 |
* use the lines of a cooc result to build a concordance @ author mdecorde. |
|
| 52 |
*/ |
|
| 53 |
public class ___CooccurrencesToConcordances extends AbstractHandler {
|
|
| 54 |
|
|
| 55 |
/** The selection. */ |
|
| 56 |
private IStructuredSelection selection; |
|
| 57 |
|
|
| 58 |
/** The editor input. */ |
|
| 59 |
private static TXMResultEditorInput editorInput; |
|
| 60 |
|
|
| 61 |
/* (non-Javadoc) |
|
| 62 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 63 |
*/ |
|
| 64 |
@Override |
|
| 65 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 66 |
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 67 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 68 |
|
|
| 69 |
CooccurrencesEditor ceditor = null; |
|
| 70 |
IEditorPart editor = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor(); |
|
| 71 |
ceditor = (CooccurrencesEditor) editor; |
|
| 72 |
|
|
| 73 |
link(ceditor, selection); |
|
| 74 |
return null; |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Link. |
|
| 79 |
* |
|
| 80 |
* @param editor the editor |
|
| 81 |
* @param selection the selection |
|
| 82 |
*/ |
|
| 83 |
public static void link(CooccurrencesEditor editor, IStructuredSelection selection) |
|
| 84 |
{
|
|
| 85 |
|
|
| 86 |
assert (selection.getFirstElement() instanceof CLine); |
|
| 87 |
|
|
| 88 |
Cooccurrence cooc = ((CLine) selection.getFirstElement()).getCooc(); |
|
| 89 |
|
|
| 90 |
int nbProps = cooc.getProperties().size(); |
|
| 91 |
List<WordProperty> props = cooc.getProperties(); |
|
| 92 |
List<CLine> list = selection.toList(); |
|
| 93 |
//System.out.println("Cooc lines "+list);
|
|
| 94 |
|
|
| 95 |
String query = "["; //$NON-NLS-1$ |
|
| 96 |
for (int p = 0; p < nbProps; p++) {
|
|
| 97 |
query += props.get(p) + "=\""; //$NON-NLS-1$ |
|
| 98 |
for (int l = 0; l < list.size(); l++) {
|
|
| 99 |
CLine line = list.get(l); |
|
| 100 |
String s = line.props.get(p); |
|
| 101 |
s = Query.addBackSlash(s); |
|
| 102 |
query += s + "|"; //$NON-NLS-1$ |
|
| 103 |
} |
|
| 104 |
query = query.substring(0, query.length() - 1); |
|
| 105 |
query += "\" & "; //$NON-NLS-1$ |
|
| 106 |
} |
|
| 107 |
query = query.substring(0, query.length() - 3); |
|
| 108 |
query += "] "; //$NON-NLS-1$ |
|
| 109 |
|
|
| 110 |
int maxempan = Math.max(cooc.getMaxLeft(), cooc.getMaxRight()); |
|
| 111 |
if (cooc.getIncludeXPivot() && maxempan == 0) maxempan = 1; |
|
| 112 |
|
|
| 113 |
String maxempanstr = "within " + maxempan + " "; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 114 |
if (cooc.getStructure() != null) maxempanstr += cooc.getStructure().getName(); |
|
| 115 |
|
|
| 116 |
query = "("+cooc.getQuery()+" []* "+query+") | ("+query+" []* "+cooc.getQuery()+") "+maxempanstr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
| 117 |
|
|
| 118 |
Corpus corpus = cooc.getCorpus(); |
|
| 119 |
Concordance concordance = new Concordance(corpus); |
|
| 120 |
concordance.setParameters(new Query(query), null, null, null, null, null, null, null, null, null, null); |
|
| 121 |
editorInput = new TXMResultEditorInput(concordance); |
|
| 122 |
|
|
| 123 |
IWorkbenchPage page = editor.getEditorSite().getWorkbenchWindow().getActivePage(); |
|
| 124 |
|
|
| 125 |
// try {
|
|
| 126 |
// ConcordanceEditor conceditor = (ConcordanceEditor) page |
|
| 127 |
// .openEditor(editorInput, ConcordanceEditor.ID); //$NON-NLS-1$ |
|
| 128 |
// } catch (PartInitException e) {
|
|
| 129 |
// System.err.println("Error: "+e.getLocalizedMessage());
|
|
| 130 |
// } |
|
| 131 |
} |
|
| 132 |
} |
|
| 0 | 133 | |
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 842) | ||
|---|---|---|
| 37 | 37 |
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences; |
| 38 | 38 |
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor; |
| 39 | 39 |
import org.txm.core.preferences.TXMPreferences; |
| 40 |
import org.txm.progression.core.functions.Progression; |
|
| 40 | 41 |
import org.txm.rcp.StatusLine; |
| 41 | 42 |
import org.txm.rcp.editors.TXMEditor; |
| 42 | 43 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| ... | ... | |
| 49 | 50 |
import org.txm.utils.logger.Log; |
| 50 | 51 |
|
| 51 | 52 |
/** |
| 52 |
* If the selection is a corpus, opens an empty Cooc editor, |
|
| 53 |
* if the selection is a concordance, opens a Cooc editor already computed.
|
|
| 53 |
* If the selection is a corpus, opens an empty Cooc editor, if the selection is
|
|
| 54 |
* a concordance, opens a Cooc editor already computed. |
|
| 54 | 55 |
* |
| 55 | 56 |
* @author mdecorde |
| 56 | 57 |
* |
| 57 | 58 |
*/ |
| 58 | 59 |
public class ComputeCooccurrences extends BaseAbstractHandler {
|
| 59 |
|
|
| 60 |
|
|
| 60 |
|
|
| 61 | 61 |
@Override |
| 62 | 62 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 63 |
|
|
| 63 |
|
|
| 64 | 64 |
if (!this.checkStatsEngine()) {
|
| 65 | 65 |
return null; |
| 66 | 66 |
} |
| ... | ... | |
| 68 | 68 |
if (!this.checkCorpusEngine()) {
|
| 69 | 69 |
return null; |
| 70 | 70 |
} |
| 71 |
|
|
| 72 |
Object selection = this.getSelection(event); |
|
| 71 |
|
|
| 73 | 72 |
Cooccurrence cooc = null; |
| 74 |
|
|
| 75 |
if (selection instanceof Concordance) {
|
|
| 76 | 73 |
|
| 77 |
int minleft = 1; |
|
| 78 |
int maxleft = 50; |
|
| 79 |
int minright = 1; |
|
| 80 |
int maxright = 50; |
|
| 74 |
// From link: creating from UUID and preferences nodes |
|
| 75 |
String uuid = event.getParameter(TXMPreferences.RESULT_UUID); |
|
| 76 |
if (uuid != null && !uuid.isEmpty()) {
|
|
| 77 |
cooc = new Cooccurrence(uuid); |
|
| 78 |
} |
|
| 79 |
// From view result node |
|
| 80 |
else {
|
|
| 81 | 81 |
|
| 82 |
int minf = TXMPreferences.getInt(CooccurrencePreferences.MIN_FREQ, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 83 |
int mincof = TXMPreferences.getInt(CooccurrencePreferences.MIN_COUNT, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 84 |
int minscore = (int) TXMPreferences.getDouble(CooccurrencePreferences.MIN_SCORE, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 85 |
boolean buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 86 |
|
|
| 87 |
StructuralUnit limit = null; |
|
| 88 |
Query query = null; |
|
| 89 |
List<WordProperty> properties = null; |
|
| 82 |
Object selection = this.getSelection(event); |
|
| 90 | 83 |
|
| 91 |
Concordance conc = (Concordance) selection; |
|
| 92 |
Corpus corpus = conc.getCorpus(); |
|
| 93 |
maxleft = conc.getLeftContextSize(); |
|
| 94 |
maxright = conc.getRightContextSize(); |
|
| 95 |
properties = new ArrayList<WordProperty>(); |
|
| 96 |
properties.addAll(conc.getAnalysisProperty()); |
|
| 97 |
query = conc.getQuery(); |
|
| 98 |
|
|
| 99 |
try {
|
|
| 100 |
cooc = new Cooccurrence(corpus); |
|
| 101 |
cooc.setParameters(query, properties, limit, |
|
| 102 |
maxleft, minleft, minright, maxright, minf, mincof, |
|
| 103 |
minscore, false, buildLexicalTableWithCooccurrents); |
|
| 104 |
} catch (Exception e) {
|
|
| 105 |
Log.printStackTrace(e); |
|
| 106 |
return null; |
|
| 84 |
// Creating from Concordance |
|
| 85 |
if (selection instanceof Concordance) {
|
|
| 86 |
|
|
| 87 |
int minleft = 1; |
|
| 88 |
int maxleft = 50; |
|
| 89 |
int minright = 1; |
|
| 90 |
int maxright = 50; |
|
| 91 |
|
|
| 92 |
int minf = TXMPreferences.getInt(CooccurrencePreferences.MIN_FREQ, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 93 |
int mincof = TXMPreferences.getInt(CooccurrencePreferences.MIN_COUNT, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 94 |
int minscore = (int) TXMPreferences.getDouble(CooccurrencePreferences.MIN_SCORE, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 95 |
boolean buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrencePreferences.PREFERENCES_NODE); |
|
| 96 |
|
|
| 97 |
StructuralUnit limit = null; |
|
| 98 |
Query query = null; |
|
| 99 |
List<WordProperty> properties = null; |
|
| 100 |
|
|
| 101 |
Concordance conc = (Concordance) selection; |
|
| 102 |
Corpus corpus = conc.getCorpus(); |
|
| 103 |
maxleft = conc.getLeftContextSize(); |
|
| 104 |
maxright = conc.getRightContextSize(); |
|
| 105 |
properties = new ArrayList<WordProperty>(); |
|
| 106 |
properties.addAll(conc.getAnalysisProperty()); |
|
| 107 |
query = conc.getQuery(); |
|
| 108 |
|
|
| 109 |
try {
|
|
| 110 |
cooc = new Cooccurrence(corpus); |
|
| 111 |
cooc.setParameters(query, properties, limit, maxleft, minleft, minright, maxright, minf, mincof, minscore, false, buildLexicalTableWithCooccurrents); |
|
| 112 |
} |
|
| 113 |
catch (Exception e) {
|
|
| 114 |
Log.printStackTrace(e); |
|
| 115 |
return null; |
|
| 116 |
} |
|
| 117 |
|
|
| 107 | 118 |
} |
| 108 |
|
|
| 109 |
} else if (selection instanceof Corpus) { // new editor from corpus
|
|
| 110 |
cooc = new Cooccurrence((Corpus)selection); |
|
| 111 |
} else if (selection instanceof Cooccurrence) { // reopening an existing result
|
|
| 112 |
cooc = (Cooccurrence)selection; |
|
| 113 |
} else {
|
|
| 114 |
System.out.println(TXMUIMessages.ComputeCooccurrences_1 + selection); |
|
| 115 |
return null; |
|
| 119 |
// Creating from Corpus |
|
| 120 |
else if (selection instanceof Corpus) {
|
|
| 121 |
cooc = new Cooccurrence((Corpus) selection); |
|
| 122 |
} |
|
| 123 |
// Reopening an existing result |
|
| 124 |
else if (selection instanceof Cooccurrence) {
|
|
| 125 |
cooc = (Cooccurrence) selection; |
|
| 126 |
} |
|
| 127 |
// Error |
|
| 128 |
else {
|
|
| 129 |
return this.logCanNotCompute(selection); |
|
| 130 |
} |
|
| 116 | 131 |
} |
| 117 |
|
|
| 118 |
try {
|
|
| 119 |
StatusLine.setMessage(TXMUIMessages.ComputeCooccurrences_0); |
|
| 120 | 132 |
|
| 121 |
//System.out.println("DEBUG: opening cooc: "+cooc+" corpus="+cooc.getCorpus());
|
|
| 122 |
TXMEditor.openEditor(cooc, CooccurrencesEditor.ID); |
|
| 123 |
|
|
| 124 |
return true; |
|
| 125 |
} catch (Exception e) {
|
|
| 126 |
Log.printStackTrace(e); |
|
| 127 |
return false; |
|
| 128 |
} |
|
| 133 |
StatusLine.setMessage(TXMUIMessages.ComputeCooccurrences_0); |
|
| 134 |
|
|
| 135 |
TXMEditor.openEditor(cooc, CooccurrencesEditor.ID); |
|
| 136 |
|
|
| 137 |
return null; |
|
| 129 | 138 |
} |
| 130 | 139 |
} |
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/SendToConcordance.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.cooccurrence.rcp.handlers; |
|
| 29 |
|
|
| 30 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 31 |
import org.eclipse.core.commands.ExecutionException; |
|
| 32 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 33 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 34 |
import org.txm.cooccurrence.core.functions.Cooccurrence; |
|
| 35 |
import org.txm.cooccurrence.core.functions.Cooccurrence.CLine; |
|
| 36 |
import org.txm.core.preferences.TXMPreferences; |
|
| 37 |
import org.txm.core.results.TXMResult; |
|
| 38 |
import org.txm.rcp.editors.TXMEditor; |
|
| 39 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
| 40 |
|
|
| 41 |
/** |
|
| 42 |
* Sends the selected lines of a cooccurrence to compute a concordance. |
|
| 43 |
* |
|
| 44 |
* @author mdecorde |
|
| 45 |
* @author sjacquot |
|
| 46 |
* |
|
| 47 |
*/ |
|
| 48 |
public class SendToConcordance extends BaseAbstractHandler {
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
@Override |
|
| 52 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 53 |
|
|
| 54 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 55 |
|
|
| 56 |
System.err.println("SendToConcordance.execute() class of line = " + selection.getFirstElement().getClass());
|
|
| 57 |
|
|
| 58 |
if (selection != null && selection.getFirstElement() instanceof CLine) {
|
|
| 59 |
|
|
| 60 |
String query = Cooccurrence.createQuery(selection.toList()); |
|
| 61 |
|
|
| 62 |
TXMEditor editor = (TXMEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart(); |
|
| 63 |
|
|
| 64 |
// create local result node, store it some parameters and call the linked command |
|
| 65 |
String uuid = TXMResult.createUUID(); |
|
| 66 |
TXMPreferences.put(uuid, TXMPreferences.PARENT_UUID, editor.getResult().getParent().getUUID()); |
|
| 67 |
TXMPreferences.put(uuid, TXMPreferences.QUERY, query); |
|
| 68 |
BaseAbstractHandler.executeCommand("org.txm.concordance.rcp.handlers.ComputeConcordance", uuid); //$NON-NLS-1$
|
|
| 69 |
} |
|
| 70 |
else {
|
|
| 71 |
this.logCanNotCompute(selection); |
|
| 72 |
} |
|
| 73 |
return null; |
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
} |
|
| 0 | 77 | |
| tmp/org.txm.cooccurrence.rcp/plugin.xml (revision 842) | ||
|---|---|---|
| 95 | 95 |
<menuContribution |
| 96 | 96 |
locationURI="popup:org.txm.cooccurrence.rcp.editors.CooccurrencesEditor"> |
| 97 | 97 |
<command |
| 98 |
commandId="org.txm.rcp.commands.link.CooccurrencesToConcordances" |
|
| 99 |
label="%command.label.102" |
|
| 98 |
commandId="org.txm.links.rcp.commands.SendToConcordance" |
|
| 100 | 99 |
style="push"> |
| 101 | 100 |
</command> |
| 102 | 101 |
</menuContribution> |
| ... | ... | |
| 126 | 125 |
</iterate> |
| 127 | 126 |
</with> |
| 128 | 127 |
</definition> |
| 128 |
<definition |
|
| 129 |
id="CooccurrenceEditorActive"> |
|
| 130 |
<with |
|
| 131 |
variable="activePart"> |
|
| 132 |
<instanceof |
|
| 133 |
value="org.txm.cooccurrence.rcp.editors.CooccurrencesEditor"> |
|
| 134 |
</instanceof> |
|
| 135 |
</with> |
|
| 136 |
</definition> |
|
| 129 | 137 |
</extension> |
| 138 |
<extension |
|
| 139 |
point="org.eclipse.ui.handlers"> |
|
| 140 |
<handler |
|
| 141 |
class="org.txm.cooccurrence.rcp.handlers.SendToConcordance" |
|
| 142 |
commandId="org.txm.links.rcp.commands.SendToConcordance"> |
|
| 143 |
<activeWhen> |
|
| 144 |
<reference |
|
| 145 |
definitionId="CooccurrenceEditorActive"> |
|
| 146 |
</reference></activeWhen> |
|
| 147 |
</handler> |
|
| 148 |
</extension> |
|
| 130 | 149 |
|
| 131 | 150 |
</plugin> |
| tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/preferences/CooccurrencePreferences.java (revision 842) | ||
|---|---|---|
| 64 | 64 |
preferences.putDouble(MIN_SCORE, 2.0); |
| 65 | 65 |
|
| 66 | 66 |
preferences.putInt(MAX_LEFT, 10); |
| 67 |
preferences.putInt(MIN_LEFT, 0);
|
|
| 68 |
preferences.putInt(MIN_RIGHT, 0);
|
|
| 67 |
preferences.putInt(MIN_LEFT, 1);
|
|
| 68 |
preferences.putInt(MIN_RIGHT, 1);
|
|
| 69 | 69 |
preferences.putInt(MAX_RIGHT, 10); |
| 70 | 70 |
|
| 71 | 71 |
preferences.put(PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY); |
| tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 842) | ||
|---|---|---|
| 60 | 60 |
import org.txm.searchengine.cqp.corpus.Property; |
| 61 | 61 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
| 62 | 62 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 63 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
| 63 | 64 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
| 64 | 65 |
import org.txm.searchengine.cqp.corpus.query.Match; |
| 65 | 66 |
import org.txm.searchengine.cqp.corpus.query.Query; |
| ... | ... | |
| 226 | 227 |
|
| 227 | 228 |
|
| 228 | 229 |
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 230 |
public Cooccurrence(Corpus corpus) {
|
|
| 231 |
this(null, corpus); |
|
| 232 |
} |
|
| 233 |
|
|
| 234 |
public Cooccurrence(String uuid) {
|
|
| 235 |
this(uuid, null); |
|
| 236 |
} |
|
| 237 |
|
|
| 232 | 238 |
/** |
| 233 | 239 |
* Creates an empty <link>Cooccurrence</link> object, child of the specified <link>Corpus</link>. |
| 234 | 240 |
* @param corpus |
| 235 | 241 |
*/ |
| 236 |
public Cooccurrence(Corpus corpus) {
|
|
| 237 |
super(corpus); |
|
| 242 |
public Cooccurrence(String uuid, Corpus corpus) {
|
|
| 243 |
super(uuid, corpus);
|
|
| 238 | 244 |
} |
| 239 | 245 |
|
| 246 |
|
|
| 240 | 247 |
/** |
| 241 | 248 |
* |
| 242 | 249 |
* @param watcher |
| ... | ... | |
| 263 | 270 |
//System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+limit+" "+maxLeft+" "+minLeft+" "+minRight+" "+maxRight+" "+minFreq+" "+minCof+" "+minScore+" "+includeXpivot);
|
| 264 | 271 |
|
| 265 | 272 |
this.subTask(CooccurrenceCoreMessages.info_buildingQueries); |
| 266 |
if (lines != null) this.lines.clear(); |
|
| 267 |
if (allsignaturesstr != null) this.allsignaturesstr.clear(); |
|
| 268 |
if (conclines != null) this.conclines.clear(); |
|
| 269 |
if (count != null) this.count.clear(); |
|
| 270 |
if (counted != null) this.counted.clear(); |
|
| 271 |
if (counts != null) this.counts.clear(); |
|
| 272 |
if (dist != null) this.dist.clear(); |
|
| 273 |
if (distances != null) this.distances.clear(); |
|
| 274 |
if (distancescounts != null) this.distancescounts.clear(); |
|
| 275 |
if (indexfreqs != null) this.indexfreqs.clear(); |
|
| 276 |
if (keysToString != null) this.keysToString.clear(); |
|
| 277 |
if (occproperties != null) this.occproperties.clear(); |
|
| 273 |
|
|
| 274 |
// clear data |
|
| 275 |
try {
|
|
| 276 |
this.lines.clear(); |
|
| 277 |
this.allsignaturesstr.clear(); |
|
| 278 |
this.conclines.clear(); |
|
| 279 |
this.count.clear(); |
|
| 280 |
this.counted.clear(); |
|
| 281 |
this.counts.clear(); |
|
| 282 |
this.dist.clear(); |
|
| 283 |
this.distances.clear(); |
|
| 284 |
this.distancescounts.clear(); |
|
| 285 |
this.indexfreqs.clear(); |
|
| 286 |
this.keysToString.clear(); |
|
| 287 |
this.occproperties.clear(); |
|
| 288 |
} |
|
| 289 |
catch (Exception e) {
|
|
| 290 |
} |
|
| 278 | 291 |
|
| 279 |
if (!this.stepQueryLimits()) {
|
|
| 280 |
return false;
|
|
| 281 |
}
|
|
| 292 |
if (!this.stepQueryLimits()) {
|
|
| 293 |
return false; |
|
| 294 |
} |
|
| 282 | 295 |
|
| 283 |
this.subTask(CooccurrenceCoreMessages.info_retreivingMatches);
|
|
| 284 |
if (!this.stepGetMatches()) {
|
|
| 285 |
return false;
|
|
| 286 |
}
|
|
| 287 |
this.worked(10);
|
|
| 296 |
this.subTask(CooccurrenceCoreMessages.info_retreivingMatches); |
|
| 297 |
if (!this.stepGetMatches()) {
|
|
| 298 |
return false; |
|
| 299 |
} |
|
| 300 |
this.worked(10); |
|
| 288 | 301 |
|
| 289 |
this.subTask(CooccurrenceCoreMessages.info_buildingLineSignatures); |
|
| 290 |
if (!this.stepBuildSignatures()) |
|
| 291 |
return false; |
|
| 292 |
this.worked(10); |
|
| 302 |
this.subTask(CooccurrenceCoreMessages.info_buildingLineSignatures); |
|
| 303 |
if (!this.stepBuildSignatures()) {
|
|
| 304 |
return false; |
|
| 305 |
} |
|
| 306 |
this.worked(10); |
|
| 293 | 307 |
|
| 294 |
this.subTask(CooccurrenceCoreMessages.info_counting);
|
|
| 295 |
if (!this.stepCount()) {
|
|
| 296 |
return false;
|
|
| 297 |
}
|
|
| 298 |
this.worked(10);
|
|
| 308 |
this.subTask(CooccurrenceCoreMessages.info_counting); |
|
| 309 |
if (!this.stepCount()) {
|
|
| 310 |
return false; |
|
| 311 |
} |
|
| 312 |
this.worked(10); |
|
| 299 | 313 |
|
| 300 |
this.subTask(CooccurrenceCoreMessages.info_buildingLexicalTable);
|
|
| 301 |
if (!this.stepBuildLexicalTable()) {
|
|
| 302 |
return false;
|
|
| 303 |
}
|
|
| 304 |
this.worked(10);
|
|
| 314 |
this.subTask(CooccurrenceCoreMessages.info_buildingLexicalTable); |
|
| 315 |
if (!this.stepBuildLexicalTable()) {
|
|
| 316 |
return false; |
|
| 317 |
} |
|
| 318 |
this.worked(10); |
|
| 305 | 319 |
|
| 306 |
this.subTask(CooccurrenceCoreMessages.info_computingSpecificitiesScores); |
|
| 307 |
if (!this.stepGetScores()) {
|
|
| 308 |
return false; |
|
| 309 |
} |
|
| 320 |
this.subTask(CooccurrenceCoreMessages.info_computingSpecificitiesScores); |
|
| 321 |
if (!this.stepGetScores()) {
|
|
| 322 |
return false; |
|
| 323 |
} |
|
| 324 |
|
|
| 325 |
this.clearMemory(); |
|
| 326 |
this.worked(10); |
|
| 310 | 327 |
|
| 311 |
this.clearMemory(); |
|
| 312 |
this.worked(10); |
|
| 313 |
|
|
| 314 | 328 |
|
| 315 | 329 |
return true; |
| 316 | 330 |
} |
| ... | ... | |
| 909 | 923 |
index = new Index(corpus); |
| 910 | 924 |
index.setParameters(new Query(pCooccurentQueryFilter), pProperties, null, null, null, null); |
| 911 | 925 |
if (!index.compute(monitor)) {
|
| 912 |
System.out.println("Cooccurrence internal Index compute failed. Aborting.");
|
|
| 926 |
Log.severe("Cooccurrence internal Index compute failed. Aborting.");
|
|
| 913 | 927 |
return false; |
| 914 | 928 |
} |
| 915 | 929 |
} catch (Exception e){
|
| ... | ... | |
| 1436 | 1450 |
this.pQuery = query; |
| 1437 | 1451 |
} |
| 1438 | 1452 |
|
| 1453 |
/** |
|
| 1454 |
* Creates a CQL query string from the specified lines. |
|
| 1455 |
* |
|
| 1456 |
* @param lines |
|
| 1457 |
* @return the query |
|
| 1458 |
*/ |
|
| 1459 |
public static String createQuery(List<CLine> lines) {
|
|
| 1460 |
|
|
| 1461 |
Cooccurrence cooc = lines.get(0).getCooc(); |
|
| 1462 |
int nbProps = cooc.getProperties().size(); |
|
| 1463 |
List<WordProperty> props = cooc.getProperties(); |
|
| 1464 |
|
|
| 1465 |
String query = "["; //$NON-NLS-1$ |
|
| 1466 |
for (int p = 0; p < nbProps; p++) {
|
|
| 1467 |
query += props.get(p) + "=\""; //$NON-NLS-1$ |
|
| 1468 |
for (int l = 0; l < lines.size(); l++) {
|
|
| 1469 |
CLine line = lines.get(l); |
|
| 1470 |
String s = line.props.get(p); |
|
| 1471 |
s = Query.addBackSlash(s); |
|
| 1472 |
query += s + "|"; //$NON-NLS-1$ |
|
| 1473 |
} |
|
| 1474 |
query = query.substring(0, query.length() - 1); |
|
| 1475 |
query += "\" & "; //$NON-NLS-1$ |
|
| 1476 |
} |
|
| 1477 |
query = query.substring(0, query.length() - 3); |
|
| 1478 |
query += "] "; //$NON-NLS-1$ |
|
| 1479 |
|
|
| 1480 |
int maxempan = Math.max(cooc.getMaxLeft(), cooc.getMaxRight()); |
|
| 1481 |
if (cooc.getIncludeXPivot() && maxempan == 0) maxempan = 1; |
|
| 1482 |
|
|
| 1483 |
String maxempanstr = "within " + maxempan + " "; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 1484 |
if (cooc.getStructure() != null) maxempanstr += cooc.getStructure().getName(); |
|
| 1485 |
|
|
| 1486 |
query = "("+cooc.getQuery()+" []* "+query+") | ("+query+" []* "+cooc.getQuery()+") "+maxempanstr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
| 1487 |
|
|
| 1488 |
return query; |
|
| 1489 |
} |
|
| 1439 | 1490 |
|
| 1440 | 1491 |
|
| 1441 | 1492 |
/** |
| tmp/org.txm.links.rcp/plugin.xml (revision 842) | ||
|---|---|---|
| 18 | 18 |
</command> |
| 19 | 19 |
<command |
| 20 | 20 |
id="org.txm.links.rcp.commands.SendToCooccurrence" |
| 21 |
name="Send to cooccurrence">
|
|
| 21 |
name="%command.name.4">
|
|
| 22 | 22 |
</command> |
| 23 | 23 |
<command |
| 24 | 24 |
categoryId="org.txm.synopticedition.rcp.category.txm" |
| tmp/org.txm.links.rcp/META-INF/MANIFEST.MF (revision 842) | ||
|---|---|---|
| 26 | 26 |
sibility:=reexport,org.txm.lexicaltable.rcp;visibility:=reexport,org. |
| 27 | 27 |
txm.libs.batik;visibility:=reexport,org.txm.edition.rcp;bundle |
| 28 | 28 |
-version="1.0.0";visibility:=reexport |
| 29 |
Export-Package: org.txm.links.rcp,org.txm.rcp.commands.link |
|
| 29 |
Export-Package: org.txm.links.rcp, |
|
| 30 |
org.txm.rcp.commands.link |
|
| 30 | 31 |
Bundle-Vendor: Textometrie.org |
| 31 | 32 |
Bundle-Version: 1.0.0.qualifier |
| 32 | 33 |
Bundle-Name: Links RCP |
| tmp/org.txm.links.rcp/src/org/txm/links/rcp/___LinkCommands.java (revision 842) | ||
|---|---|---|
| 1 |
package org.txm.links.rcp; |
|
| 2 |
|
|
| 3 |
/** |
|
| 4 |
* Associations between link command types and RCP command ids. |
|
| 5 |
* @author sjacquot |
|
| 6 |
* |
|
| 7 |
*/ |
|
| 8 |
public enum ___LinkCommands {
|
|
| 9 |
|
|
| 10 |
SEND_TO_CONCORDANCE("org.txm.links.rcp.commands.SendToConcordance"),
|
|
| 11 |
SEND_TO_INDEX("org.txm.links.rcp.commands.SendToIndex"),
|
|
| 12 |
SEND_TO_COOCCURRENCE("org.txm.links.rcp.commands.SendToProgression"),
|
|
| 13 |
SEND_TO_PROGRESSIONE("org.txm.links.rcp.commands.SendToCooccurrence");
|
|
| 14 |
|
|
| 15 |
/** |
|
| 16 |
* Command id. |
|
| 17 |
*/ |
|
| 18 |
final private String id; |
|
| 19 |
|
|
| 20 |
/** |
|
| 21 |
* |
|
| 22 |
* @param commandId |
|
| 23 |
*/ |
|
| 24 |
private ___LinkCommands(String id) {
|
|
| 25 |
this.id = id; |
|
| 26 |
} |
|
| 27 |
|
|
| 28 |
@Override |
|
| 29 |
public String toString(){
|
|
| 30 |
return this.id; |
|
| 31 |
} |
|
| 32 |
} |
|
| 0 | 33 | |
| tmp/org.txm.links.rcp/src/org/txm/rcp/commands/link/CooccurrencesToConcordances.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.commands.link; |
|
| 29 |
|
|
| 30 |
import java.util.List; |
|
| 31 |
|
|
| 32 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 34 |
import org.eclipse.core.commands.ExecutionException; |
|
| 35 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 36 |
import org.eclipse.osgi.util.NLS; |
|
| 37 |
import org.eclipse.ui.IEditorPart; |
|
| 38 |
import org.eclipse.ui.IWorkbenchPage; |
|
| 39 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 40 |
import org.eclipse.ui.PartInitException; |
|
| 41 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 42 |
import org.txm.concordance.core.functions.Concordance; |
|
| 43 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
| 44 |
import org.txm.cooccurrence.core.functions.Cooccurrence; |
|
| 45 |
import org.txm.cooccurrence.core.functions.Cooccurrence.CLine; |
|
| 46 |
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor; |
|
| 47 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 48 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 49 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 50 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 51 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
|
| 52 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
| 53 |
|
|
| 54 |
// TODO: Auto-generated Javadoc |
|
| 55 |
/** |
|
| 56 |
* use the lines of a cooc result to build a concordance @ author mdecorde. |
|
| 57 |
*/ |
|
| 58 |
public class CooccurrencesToConcordances extends AbstractHandler {
|
|
| 59 |
|
|
| 60 |
/** The selection. */ |
|
| 61 |
private IStructuredSelection selection; |
|
| 62 |
|
|
| 63 |
/** The editor input. */ |
|
| 64 |
private static TXMResultEditorInput editorInput; |
|
| 65 |
|
|
| 66 |
/* (non-Javadoc) |
|
| 67 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 68 |
*/ |
|
| 69 |
@Override |
|
| 70 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 71 |
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 72 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 73 |
|
|
| 74 |
CooccurrencesEditor ceditor = null; |
|
| 75 |
IEditorPart editor = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor(); |
|
| 76 |
ceditor = (CooccurrencesEditor) editor; |
|
| 77 |
|
|
| 78 |
link(ceditor, selection); |
|
| 79 |
return null; |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
/** |
|
| 83 |
* Link. |
|
| 84 |
* |
|
| 85 |
* @param editor the editor |
|
| 86 |
* @param selection the selection |
|
| 87 |
*/ |
|
| 88 |
public static void link(CooccurrencesEditor editor, IStructuredSelection selection) |
|
| 89 |
{
|
|
| 90 |
|
|
| 91 |
assert (selection.getFirstElement() instanceof CLine); |
|
| 92 |
|
|
| 93 |
Cooccurrence cooc = ((CLine) selection.getFirstElement()).getCooc(); |
|
| 94 |
|
|
| 95 |
int nbProps = cooc.getProperties().size(); |
|
| 96 |
List<WordProperty> props = cooc.getProperties(); |
|
| 97 |
List<CLine> list = selection.toList(); |
|
| 98 |
//System.out.println("Cooc lines "+list);
|
|
| 99 |
|
|
| 100 |
String query = "["; //$NON-NLS-1$ |
|
| 101 |
for (int p = 0; p < nbProps; p++) {
|
|
| 102 |
query += props.get(p) + "=\""; //$NON-NLS-1$ |
|
| 103 |
for (int l = 0; l < list.size(); l++) {
|
|
| 104 |
CLine line = list.get(l); |
|
| 105 |
String s = line.props.get(p); |
|
| 106 |
s = Query.addBackSlash(s); |
|
| 107 |
query += s + "|"; //$NON-NLS-1$ |
|
| 108 |
} |
|
| 109 |
query = query.substring(0, query.length() - 1); |
|
| 110 |
query += "\" & "; //$NON-NLS-1$ |
|
| 111 |
} |
|
| 112 |
query = query.substring(0, query.length() - 3); |
|
| 113 |
query += "] "; //$NON-NLS-1$ |
|
| 114 |
|
|
| 115 |
int maxempan = Math.max(cooc.getMaxLeft(), cooc.getMaxRight()); |
|
| 116 |
if (cooc.getIncludeXPivot() && maxempan == 0) maxempan = 1; |
|
| 117 |
|
|
| 118 |
String maxempanstr = "within " + maxempan + " "; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 119 |
if (cooc.getStructure() != null) maxempanstr += cooc.getStructure().getName(); |
|
| 120 |
|
|
| 121 |
query = "("+cooc.getQuery()+" []* "+query+") | ("+query+" []* "+cooc.getQuery()+") "+maxempanstr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
| 122 |
|
|
| 123 |
Corpus corpus = cooc.getCorpus(); |
|
| 124 |
Concordance concordance = new Concordance(corpus); |
|
| 125 |
concordance.setParameters(new Query(query), null, null, null, null, null, null, null, null, null, null); |
|
| 126 |
editorInput = new TXMResultEditorInput(concordance); |
|
| 127 |
|
|
| 128 |
IWorkbenchPage page = editor.getEditorSite().getWorkbenchWindow().getActivePage(); |
|
| 129 |
|
|
| 130 |
try {
|
|
| 131 |
ConcordanceEditor conceditor = (ConcordanceEditor) page |
|
| 132 |
.openEditor(editorInput, ConcordanceEditor.ID); //$NON-NLS-1$ |
|
| 133 |
} catch (PartInitException e) {
|
|
| 134 |
System.err.println("Error: "+e.getLocalizedMessage());
|
|
| 135 |
} |
|
| 136 |
} |
|
| 137 |
} |
|
| tmp/org.txm.links.rcp/src/org/txm/rcp/commands/link/___IndexToProgression.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.commands.link; |
|
| 29 |
|
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 33 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 34 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 35 |
import org.eclipse.core.commands.ExecutionException; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 37 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 38 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 39 |
import org.txm.index.core.functions.Line; |
|
| 40 |
import org.txm.index.rcp.editors.IndexEditor; |
|
| 41 |
import org.txm.progression.core.functions.Progression; |
|
| 42 |
import org.txm.progression.rcp.editors.ProgressionEditor; |
|
| 43 |
import org.txm.rcp.editors.TXMEditor; |
|
| 44 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 45 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 46 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 47 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
| 48 |
|
|
| 49 |
// TODO: Auto-generated Javadoc |
|
| 50 |
/** |
|
| 51 |
* use the lines of a index to compute a Progression |
|
| 52 |
* @author mdecorde |
|
| 53 |
*/ |
|
| 54 |
// FIXME: old version |
|
| 55 |
public class ___IndexToProgression extends AbstractHandler {
|
|
| 56 |
|
|
| 57 |
/** The window. */ |
|
| 58 |
private IWorkbenchWindow window; |
|
| 59 |
|
|
| 60 |
/** The selection. */ |
|
| 61 |
private IStructuredSelection selection; |
|
| 62 |
|
|
| 63 |
/** The editor input. */ |
|
| 64 |
private TXMResultEditorInput editorInput; |
|
| 65 |
|
|
| 66 |
/* (non-Javadoc) |
|
| 67 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 68 |
*/ |
|
| 69 |
@Override |
|
| 70 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 71 |
window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 72 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 73 |
|
|
| 74 |
assert (selection.getFirstElement() instanceof Line); |
|
| 75 |
|
|
| 76 |
List<Query> queries = getQueries(selection); |
|
| 77 |
|
|
| 78 |
IndexEditor voceditor = (IndexEditor) HandlerUtil |
|
| 79 |
.getActiveWorkbenchWindow(event).getActivePage() |
|
| 80 |
.getActivePart(); |
|
| 81 |
Corpus corpus = voceditor.getCorpus(); |
|
| 82 |
|
|
| 83 |
Progression progression = new Progression(corpus); |
|
| 84 |
progression.setQueries(queries); |
|
| 85 |
|
|
| 86 |
TXMEditor.openEditor(progression, ProgressionEditor.class.getName()); |
|
| 87 |
return null; |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Link. |
|
| 92 |
* |
|
| 93 |
* @param voceditor the voceditor |
|
| 94 |
* @param selection the selection |
|
| 95 |
* @return the object |
|
| 96 |
*/ |
|
| 97 |
public static Object link(IndexEditor voceditor, |
|
| 98 |
IStructuredSelection selection) {
|
|
| 99 |
// window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 100 |
// selection = (IStructuredSelection) |
|
| 101 |
// HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); |
|
| 102 |
|
|
| 103 |
assert (selection.getFirstElement() instanceof Line); |
|
| 104 |
|
|
| 105 |
List<Query> queries = getQueries(selection); |
|
| 106 |
if (queries.size() == 0) return null; |
|
| 107 |
|
|
| 108 |
Corpus corpus = voceditor.getCorpus(); |
|
| 109 |
|
|
| 110 |
Progression progression = new Progression(corpus); |
|
| 111 |
progression.setQueries(queries); |
|
| 112 |
|
|
| 113 |
TXMEditor.openEditor(progression, ProgressionEditor.class.getName()); |
|
| 114 |
return null; |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
/** |
|
| 118 |
* Gets the queries. |
|
| 119 |
* |
|
| 120 |
* @param selection the selection |
|
| 121 |
* @return the queries |
|
| 122 |
*/ |
|
| 123 |
public static List<Query> getQueries(IStructuredSelection selection) {
|
|
| 124 |
List<Line> lines = selection.toList(); |
|
| 125 |
List<Query> queries = new ArrayList<Query>(); |
|
| 126 |
for (Line line : lines) {
|
|
| 127 |
String query = ""; //$NON-NLS-1$ |
|
| 128 |
int nbToken = line.getUnitsProperties().get(0).size(); |
|
| 129 |
int nbProps = line.getProperties().size(); |
|
| 130 |
List<List<String>> values = line.getUnitsProperties(); |
|
| 131 |
List<Property> props = line.getProperties(); |
|
| 132 |
for (int t = 0; t < nbToken; t++) {
|
|
| 133 |
query += "["; //$NON-NLS-1$ |
|
| 134 |
for (int p = 0; p < nbProps; p++) {
|
|
| 135 |
query += props.get(p) + "=\""; //$NON-NLS-1$ |
|
| 136 |
String s = values.get(p).get(t); |
|
| 137 |
s = Query.addBackSlash(s); |
|
| 138 |
query += s; |
|
| 139 |
query += "\" & "; //$NON-NLS-1$ |
|
| 140 |
} |
|
| 141 |
query = query.substring(0, query.length() - 3); |
|
| 142 |
query += "] "; //$NON-NLS-1$ |
|
| 143 |
} |
|
| 144 |
queries.add(new Query(query)); |
|
| 145 |
} |
|
| 146 |
return queries; |
|
| 147 |
} |
|
| 148 |
} |
|
| tmp/org.txm.links.rcp/src/org/txm/rcp/commands/link/IndexToLexicalTable.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.commands.link; |
|
| 29 |
|
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
|
|
| 32 |
import org.apache.batik.util.gui.CSSMediaPanel.Dialog; |
|
| 33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 34 |
import org.eclipse.core.commands.ExecutionException; |
|
| 35 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 37 |
import org.eclipse.jface.viewers.LabelProvider; |
|
| 38 |
import org.eclipse.swt.widgets.Shell; |
|
| 39 |
import org.eclipse.ui.IWorkbenchPage; |
|
| 40 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 41 |
import org.eclipse.ui.PartInitException; |
|
| 42 |
import org.eclipse.ui.PlatformUI; |
|
| 43 |
import org.eclipse.ui.dialogs.ListSelectionDialog; |
|
| 44 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 45 |
import org.txm.index.core.functions.Index; |
|
| 46 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
|
| 47 |
import org.txm.lexicaltable.rcp.editors.___LexicalTableEditorInput; |
|
| 48 |
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages; |
|
| 49 |
import org.txm.rcp.StatusLine; |
|
| 50 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
| 51 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 52 |
// TODO: Auto-generated Javadoc |
|
| 53 |
/** |
|
| 54 |
* The Class IndexToLexicalTable. |
|
| 55 |
*/ |
|
| 56 |
public class IndexToLexicalTable extends BaseAbstractHandler {
|
|
| 57 |
|
|
| 58 |
/** The window. */ |
|
| 59 |
private IWorkbenchWindow window; |
|
| 60 |
|
|
| 61 |
/** The selection. */ |
|
| 62 |
private IStructuredSelection selection; |
|
| 63 |
private static Shell shell; |
|
| 64 |
/* (non-Javadoc) |
|
| 65 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 66 |
*/ |
|
| 67 |
@Override |
|
| 68 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 69 |
|
|
| 70 |
if(!this.checkStatsEngine()) {
|
|
| 71 |
return null; |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
|
|
| 75 |
// TODO Auto-generated method stub |
|
| 76 |
window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 77 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 78 |
shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
| 79 |
return null; |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
/** |
|
| 83 |
* Builds the lexical table. |
|
| 84 |
* |
|
| 85 |
* @param voc the voc |
|
| 86 |
* @param from the from |
|
| 87 |
* @param to the to |
|
| 88 |
* @return true, if successful |
|
| 89 |
*/ |
|
| 90 |
public boolean buildLexicalTable(Index voc, int from, int to) {
|
|
| 91 |
LexicalTable table; |
|
| 92 |
|
|
| 93 |
if (!voc.isComputedWithPartition()) {
|
|
| 94 |
|
|
| 95 |
System.out.println(TXMUIMessages.IndexToLexicalTable_0); |
|
| 96 |
StatusLine.setMessage(TXMUIMessages.IndexToLexicalTable_0); |
|
| 97 |
return false; |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
System.out.println(LexicalTableUIMessages.ComputeLexicalTable_3); |
|
| 101 |
ArrayList<String> choices = new ArrayList<String>(); |
|
| 102 |
choices.add(LexicalTableUIMessages.ComputeLexicalTable_16); |
|
| 103 |
choices.add(LexicalTableUIMessages.ComputeLexicalTable_12); |
|
| 104 |
ListSelectionDialog dialog = new ListSelectionDialog(shell, |
|
| 105 |
choices, new ArrayContentProvider(), new LabelProvider(), |
|
| 106 |
LexicalTableUIMessages.ComputeLexicalTable_13); |
|
| 107 |
|
|
| 108 |
int ret = dialog.open(); |
|
| 109 |
//System.out.println("ret= "+ret);
|
|
| 110 |
if (ret == Dialog.OK_OPTION) {
|
|
| 111 |
|
|
| 112 |
} else {
|
|
| 113 |
return false; |
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
try {
|
|
| 117 |
table = new LexicalTable(voc); |
|
| 118 |
} catch (Exception e) {
|
|
| 119 |
// TODO Auto-generated catch block |
|
| 120 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 121 |
return false; |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
try {
|
|
| 125 |
IWorkbenchWindow window = PlatformUI.getWorkbench() |
|
| 126 |
.getActiveWorkbenchWindow(); |
|
| 127 |
IWorkbenchPage page = window.getActivePage(); |
|
| 128 |
___LexicalTableEditorInput editorInput = new ___LexicalTableEditorInput(table); |
|
| 129 |
StatusLine.setMessage(LexicalTableUIMessages.ComputeLexicalTable_10); |
|
| 130 |
page.openEditor(editorInput, "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
| 131 |
} catch (PartInitException e) {
|
|
| 132 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 133 |
} |
|
| 134 |
|
|
| 135 |
return true; |
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
} |
|
| tmp/org.txm.links.rcp/src/org/txm/rcp/commands/link/IndexToCooccurrence.java (revision 842) | ||
|---|---|---|
| 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 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.rcp.commands.link; |
|
| 29 |
|
|
| 30 |
import java.util.List; |
|
| 31 |
|
|
| 32 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 34 |
import org.eclipse.core.commands.ExecutionException; |
|
| 35 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 36 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 37 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 38 |
import org.txm.index.core.functions.Line; |
|
| 39 |
import org.txm.index.rcp.editors.IndexEditor; |
|
| 40 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 41 |
import org.txm.searchengine.cqp.corpus.Property; |
|
| 42 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
| 43 |
|
|
| 44 |
// TODO: Auto-generated Javadoc |
|
| 45 |
/** |
|
| 46 |
* use the lines of a index to compute a concordance |
|
| 47 |
* @author mdecorde. |
|
| 48 |
*/ |
|
| 49 |
// FIXME: should call the ComputeCooccurrence command with some parameters |
|
| 50 |
public class IndexToCooccurrence extends AbstractHandler {
|
|
| 51 |
|
|
| 52 |
/* (non-Javadoc) |
|
| 53 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 54 |
*/ |
|
| 55 |
@Override |
|
| 56 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 57 |
IWorkbenchWindow window; |
|
| 58 |
IStructuredSelection selection; |
|
| 59 |
window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
| 60 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 61 |
|
|
| 62 |
assert (selection.getFirstElement() instanceof Line); |
|
| 63 |
|
|
| 64 |
String query = getQuery(selection); |
|
| 65 |
|
|
| 66 |
// System.out.println(query); |
|
| 67 |
|
|
| 68 |
IndexEditor voceditor = (IndexEditor) HandlerUtil |
|
| 69 |
.getActiveWorkbenchWindow(event).getActivePage() |
|
| 70 |
.getActivePart(); |
|
| 71 |
|
|
| 72 |
Corpus corpus = voceditor.getCorpus(); |
|
| 73 |
|
|
| 74 |
System.out.println("IMPLEMENTATION NOT FINISHED");
|
|
| 75 |
|
|
| 76 |
// try {
|
|
| 77 |
// CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditor.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$ |
|
| 78 |
// conceditor.setFocus(query); |
|
| 79 |
// conceditor.computeResult(false); |
|
| 80 |
// } catch (Exception e) {
|
|
| 81 |
// System.out.println(Messages.IndexToCooccurrence_0); |
|
| 82 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 83 |
// } |
|
| 84 |
|
|
| 85 |
return null; |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/** |
|
| 89 |
* Link. |
|
| 90 |
* |
|
| 91 |
* @param voceditor the voceditor |
|
| 92 |
* @param selection the selection |
|
| 93 |
* @return the object |
|
| 94 |
*/ |
|
| 95 |
public static Object link(IndexEditor voceditor, |
|
| 96 |
IStructuredSelection selection) {
|
|
| 97 |
assert (selection.getFirstElement() instanceof Line); |
|
| 98 |
String query = getQuery(selection); |
|
| 99 |
if (query.length() == 0) |
|
| 100 |
return null; |
|
| 101 |
|
|
| 102 |
System.out.println("IMPLEMENTATION NOT FINISHED");
|
|
| 103 |
|
|
| 104 |
// Corpus corpus = voceditor.getCorpus(); |
|
| 105 |
// try {
|
|
| 106 |
// CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditor.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$ |
|
| 107 |
// conceditor.setFocus(query); |
|
| 108 |
// conceditor.computeResult(false); |
|
| 109 |
// return conceditor; |
|
| 110 |
// } catch (Exception e) {
|
|
| 111 |
// System.out.println(Messages.IndexToCooccurrence_0); |
|
| 112 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 113 |
// } |
|
| 114 |
|
|
| 115 |
return null; |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
/** |
|
| 119 |
* Gets the query. |
|
| 120 |
* |
|
| 121 |
* @param selection the selection |
|
| 122 |
* @return the query |
|
| 123 |
*/ |
|
| 124 |
private static String getQuery(IStructuredSelection selection) {
|
|
| 125 |
String query = ""; //$NON-NLS-1$ |
|
| 126 |
|
|
| 127 |
Line line = (Line) selection.getFirstElement(); |
|
| 128 |
int nbToken = line.getUnitsProperties().get(0).size(); |
|
| 129 |
int nbProps = line.getProperties().size(); |
|
| 130 |
int nbLines = selection.size(); |
|
| 131 |
List<Line> lines = selection.toList(); |
|
| 132 |
List<Property> props = line.getProperties(); |
|
| 133 |
for (int t = 0; t < nbToken; t++) {
|
|
| 134 |
query += "["; //$NON-NLS-1$ |
|
| 135 |
for (int p = 0; p < nbProps; p++) {
|
|
| 136 |
query += props.get(p) + "=\""; //$NON-NLS-1$ |
|
| 137 |
for (int l = 0; l < nbLines; l++) {
|
|
| 138 |
line = lines.get(l); |
|
| 139 |
List<List<String>> values = line.getUnitsProperties(); |
|
| 140 |
String s = values.get(p).get(t); |
|
| 141 |
s = Query.addBackSlash(s); |
|
| 142 |
query += s + "|"; //$NON-NLS-1$ |
|
| 143 |
} |
|
| 144 |
query = query.substring(0, query.length() - 1); |
|
| 145 |
query += "\" & "; //$NON-NLS-1$ |
|
| 146 |
} |
|
| 147 |
query = query.substring(0, query.length() - 3); |
|
| 148 |
query += "] "; //$NON-NLS-1$ |
|
| 149 |
} |
|
| 150 |
query = query.substring(0, query.length() - 1); |
|
| 151 |
return query; |
|
| 152 |
} |
|
| 153 |
} |
|
| tmp/org.txm.links.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 842) | ||
|---|---|---|
| 1 | 1 |
|
| 2 | 2 |
command.name.1 = Envoyer vers la concordance |
| 3 | 3 |
|
| 4 |
command.name.2 = Envoyer vers l'Index
|
|
| 4 |
command.name.2 = Envoyer vers l'index
|
|
| 5 | 5 |
|
| 6 | 6 |
command.name.3 = Envoyer vers la progression |
| 7 |
|
|
| 8 |
command.name.4 = Envoyer vers la cooccurrence |
|
| tmp/org.txm.links.rcp/OSGI-INF/l10n/bundle.properties (revision 842) | ||
|---|---|---|
| 5 | 5 |
|
| 6 | 6 |
command.name.3 = Send to progression |
| 7 | 7 |
|
| 8 |
command.name.65 = IndexToCooccurrence |
|
| 8 |
command.name.4 = Send to cooccurrence |
|
| tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 842) | ||
|---|---|---|
| 98 | 98 |
*/ |
| 99 | 99 |
public static final String PROPERTIES = "properties"; //$NON-NLS-1$ |
| 100 | 100 |
|
| 101 |
|
|
| 101 | 102 |
/** |
| 103 |
* Minimum frequency filter value. |
|
| 104 |
*/ |
|
| 105 |
public static final String F_MIN = "f_min"; //$NON-NLS-1$ |
|
| 106 |
|
|
| 107 |
/** |
|
| 108 |
* Maximum frequency filter value. |
|
| 109 |
*/ |
|
| 110 |
public static final String F_MAX = "f_max"; //$NON-NLS-1$ |
|
| 111 |
|
|
| 112 |
/** |
|
| 113 |
* V max filter (max number of lines). |
|
| 114 |
*/ |
|
| 115 |
public static final String V_MAX = "v_max"; //$NON-NLS-1$ |
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
/** |
|
| 102 | 120 |
* Separator used when converting list from and to string. |
| 103 | 121 |
*/ |
| 104 | 122 |
public static final String LIST_SEPARATOR = "\t"; //$NON-NLS-1$ |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 842) | ||
|---|---|---|
| 114 | 114 |
public final void _createPartControl() {
|
| 115 | 115 |
|
| 116 | 116 |
// Toolbar |
| 117 |
this.chartToolBar = new ChartEditorToolBar(this, this.getFirstLineComposite(), this.getParametersGroupsComposite(), SWT.FLAT | SWT.RIGHT);
|
|
| 117 |
this.chartToolBar = new ChartEditorToolBar(this, this.getFirstLineComposite(), null, SWT.FLAT | SWT.RIGHT);
|
|
| 118 | 118 |
this.getFirstLineComposite().getLayout().numColumns += 1; |
| 119 | 119 |
//this.chartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED)); |
| 120 | 120 |
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/TXMResultContentProvider.java (revision 842) | ||
|---|---|---|
| 30 | 30 |
import java.util.ArrayList; |
| 31 | 31 |
import java.util.Collections; |
| 32 | 32 |
import java.util.Comparator; |
| 33 |
import java.util.HashMap; |
|
| 34 | 33 |
|
| 35 | 34 |
import org.eclipse.core.runtime.IAdaptable; |
| 36 | 35 |
import org.eclipse.core.runtime.Platform; |
| ... | ... | |
| 43 | 42 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 44 | 43 |
|
| 45 | 44 |
/** |
| 46 |
* Content provider of the Corpus view |
|
| 45 |
* Content provider of the Corpus view.
|
|
| 47 | 46 |
* |
| 48 | 47 |
* @author mdecorde |
| 49 | 48 |
*/ |
| ... | ... | |
| 77 | 76 |
*/ |
| 78 | 77 |
@Override |
Formats disponibles : Unified diff