Révision 1969
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1969) | ||
|---|---|---|
| 21 | 21 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 22 | 22 |
import org.eclipse.jface.viewers.TableViewer; |
| 23 | 23 |
import org.eclipse.jface.viewers.TableViewerColumn; |
| 24 |
import org.eclipse.jface.viewers.ViewerCell; |
|
| 25 | 24 |
import org.eclipse.osgi.util.NLS; |
| 26 | 25 |
import org.eclipse.swt.SWT; |
| 27 | 26 |
import org.eclipse.swt.events.KeyEvent; |
| ... | ... | |
| 31 | 30 |
import org.eclipse.swt.events.TypedEvent; |
| 32 | 31 |
import org.eclipse.swt.graphics.Font; |
| 33 | 32 |
import org.eclipse.swt.graphics.FontData; |
| 34 |
import org.eclipse.swt.graphics.Image; |
|
| 35 | 33 |
import org.eclipse.swt.layout.GridData; |
| 36 | 34 |
import org.eclipse.swt.widgets.Button; |
| 37 | 35 |
import org.eclipse.swt.widgets.Composite; |
| ... | ... | |
| 53 | 51 |
import org.txm.annotation.kr.rcp.commands.InitializeKnowledgeRepository; |
| 54 | 52 |
import org.txm.annotation.kr.rcp.commands.SaveAnnotations; |
| 55 | 53 |
import org.txm.annotation.kr.rcp.messages.KRAnnotationUIMessages; |
| 56 |
import org.txm.annotation.kr.rcp.views.knowledgerepositories.KRView; |
|
| 57 | 54 |
import org.txm.annotation.rcp.editor.AnnotationArea; |
| 58 | 55 |
import org.txm.annotation.rcp.editor.AnnotationExtension; |
| 59 | 56 |
import org.txm.concordance.core.functions.Concordance; |
| 60 | 57 |
import org.txm.concordance.core.functions.Line; |
| 61 | 58 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
| 62 | 59 |
import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener; |
| 63 |
import org.txm.concordance.rcp.messages.ConcordanceUIMessages; |
|
| 64 | 60 |
import org.txm.core.messages.TXMCoreMessages; |
| 65 | 61 |
import org.txm.core.results.TXMResult; |
| 62 |
import org.txm.objects.Match; |
|
| 66 | 63 |
import org.txm.rcp.IImageKeys; |
| 67 | 64 |
import org.txm.rcp.editors.TXMEditor; |
| 68 | 65 |
import org.txm.rcp.swt.GLComposite; |
| ... | ... | |
| 72 | 69 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 73 | 70 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 74 | 71 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
| 75 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 76 | 72 |
import org.txm.utils.AsciiUtils; |
| 77 | 73 |
import org.txm.utils.logger.Log; |
| 78 | 74 |
|
| ... | ... | |
| 168 | 164 |
affectMatchesToSelection(matches); |
| 169 | 165 |
} |
| 170 | 166 |
|
| 171 |
protected void affectAnnotationValues(final List<Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 167 |
protected void affectAnnotationValues(final List<? extends Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 172 | 168 |
value_to_add = null; // reset |
| 173 | 169 |
if (matches == null || matches.size() == 0) {
|
| 174 | 170 |
System.out.println("No line selected. Aborting."); //$NON-NLS-1$
|
| ... | ... | |
| 344 | 340 |
}); |
| 345 | 341 |
} |
| 346 | 342 |
|
| 347 |
protected void affectMatchesToSelection(final List<Match> matches) {
|
|
| 343 |
protected void affectMatchesToSelection(final List<? extends Match> matches) {
|
|
| 348 | 344 |
final AnnotationType type = getSelectedAnnotationType(); |
| 349 | 345 |
final String svalue = annotationValuesText.getText(); |
| 350 | 346 |
|
| ... | ... | |
| 607 | 603 |
public void widgetSelected(SelectionEvent e) {
|
| 608 | 604 |
|
| 609 | 605 |
try {
|
| 610 |
List<Match> matches = concordance.getMatches(); |
|
| 606 |
List<? extends Match> matches = concordance.getMatches();
|
|
| 611 | 607 |
affectMatchesToSelection(matches); |
| 612 |
} catch (CqiClientException e1) {
|
|
| 608 |
} catch (Exception e1) {
|
|
| 613 | 609 |
Log.severe(NLS.bind(KRAnnotationUIMessages.errorWhileAnnotatingConcordanceColonP0, e1.getLocalizedMessage())); |
| 614 | 610 |
Log.printStackTrace(e1); |
| 615 | 611 |
return; |
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/ConcordanceAnnotations.java (revision 1969) | ||
|---|---|---|
| 13 | 13 |
import org.txm.annotation.kr.core.repository.TypedValue; |
| 14 | 14 |
import org.txm.concordance.core.functions.Concordance; |
| 15 | 15 |
import org.txm.concordance.core.functions.Line; |
| 16 |
import org.txm.searchengine.cqp.corpus.query.Match;
|
|
| 16 |
import org.txm.objects.Match;
|
|
| 17 | 17 |
import org.txm.utils.logger.Log; |
| 18 | 18 |
|
| 19 | 19 |
/** |
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 1969) | ||
|---|---|---|
| 55 | 55 |
import org.txm.concordance.rcp.messages.ConcordanceUIMessages; |
| 56 | 56 |
import org.txm.core.messages.TXMCoreMessages; |
| 57 | 57 |
import org.txm.core.results.TXMResult; |
| 58 |
import org.txm.objects.Match; |
|
| 58 | 59 |
import org.txm.rcp.IImageKeys; |
| 59 | 60 |
import org.txm.rcp.editors.TXMEditor; |
| 60 | 61 |
import org.txm.rcp.swt.GLComposite; |
| ... | ... | |
| 63 | 64 |
import org.txm.rcp.utils.JobHandler; |
| 64 | 65 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 65 | 66 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 66 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 67 | 67 |
import org.txm.utils.logger.Log; |
| 68 | 68 |
|
| 69 | 69 |
public class SimpleKRAnnotation extends AnnotationArea {
|
| ... | ... | |
| 329 | 329 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection()); |
| 330 | 330 |
} else { // all
|
| 331 | 331 |
try {
|
| 332 |
List<Match> matches = concordance.getMatches(); |
|
| 332 |
List<? extends Match> matches = concordance.getMatches();
|
|
| 333 | 333 |
affectMatchesToSelection(matches); |
| 334 |
} catch (CqiClientException e1) {
|
|
| 334 |
} catch (Exception e1) {
|
|
| 335 | 335 |
Log.severe(NLS.bind(KRAnnotationUIMessages.errorWhileAnnotatingConcordanceColonP0, e1.getLocalizedMessage())); |
| 336 | 336 |
Log.printStackTrace(e1); |
| 337 | 337 |
return; |
| ... | ... | |
| 389 | 389 |
} |
| 390 | 390 |
} |
| 391 | 391 |
|
| 392 |
protected void affectMatchesToSelection(final List<Match> matches) {
|
|
| 392 |
protected void affectMatchesToSelection(final List<? extends Match> matches) {
|
|
| 393 | 393 |
final AnnotationType type = getSelectedAnnotationType(); |
| 394 | 394 |
final String svalue = annotationValuesText.getText(); |
| 395 | 395 |
final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default |
| ... | ... | |
| 458 | 458 |
}); |
| 459 | 459 |
} |
| 460 | 460 |
|
| 461 |
protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
|
|
| 461 |
protected void deleteAnnotationValues(List<? extends Match> matches, AnnotationType type, JobHandler job) {
|
|
| 462 | 462 |
|
| 463 | 463 |
if (matches.size() == 0) {
|
| 464 | 464 |
System.out.println("No lines selected. Aborting."); //$NON-NLS-1$
|
| ... | ... | |
| 495 | 495 |
}); |
| 496 | 496 |
} |
| 497 | 497 |
|
| 498 |
protected void affectAnnotationValues(final List<Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 498 |
protected void affectAnnotationValues(final List<? extends Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 499 | 499 |
value_to_add = null; // reset |
| 500 | 500 |
if (matches == null || matches.size() == 0) {
|
| 501 | 501 |
System.out.println("No line selected. Aborting."); //$NON-NLS-1$
|
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1969) | ||
|---|---|---|
| 63 | 63 |
import org.txm.concordance.rcp.messages.ConcordanceUIMessages; |
| 64 | 64 |
import org.txm.core.messages.TXMCoreMessages; |
| 65 | 65 |
import org.txm.core.results.TXMResult; |
| 66 |
import org.txm.objects.Match; |
|
| 66 | 67 |
import org.txm.rcp.IImageKeys; |
| 67 | 68 |
import org.txm.rcp.commands.OpenBrowser; |
| 68 | 69 |
import org.txm.rcp.editors.TXMEditor; |
| ... | ... | |
| 73 | 74 |
import org.txm.rcp.views.corpora.CorporaView; |
| 74 | 75 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 75 | 76 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 76 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 77 | 77 |
import org.txm.utils.AsciiUtils; |
| 78 | 78 |
import org.txm.utils.logger.Log; |
| 79 | 79 |
|
| ... | ... | |
| 518 | 518 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection()); |
| 519 | 519 |
} else { // all
|
| 520 | 520 |
try {
|
| 521 |
List<Match> matches = concordance.getMatches(); |
|
| 521 |
List<? extends Match> matches = concordance.getMatches();
|
|
| 522 | 522 |
affectMatchesToSelection(matches); |
| 523 |
} catch (CqiClientException e1) {
|
|
| 523 |
} catch (Exception e1) {
|
|
| 524 | 524 |
Log.severe(NLS.bind(KRAnnotationUIMessages.errorWhileAnnotatingConcordanceColonP0, e1.getLocalizedMessage())); |
| 525 | 525 |
Log.printStackTrace(e1); |
| 526 | 526 |
return; |
| ... | ... | |
| 619 | 619 |
return (AnnotationType) isel.getFirstElement(); |
| 620 | 620 |
} |
| 621 | 621 |
|
| 622 |
protected void affectMatchesToSelection(final List<Match> matches) {
|
|
| 622 |
protected void affectMatchesToSelection(final List<? extends Match> matches) {
|
|
| 623 | 623 |
final AnnotationType type = getSelectedAnnotationType(); |
| 624 | 624 |
final String svalue = annotationValuesText.getText(); |
| 625 | 625 |
final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default |
| ... | ... | |
| 690 | 690 |
} |
| 691 | 691 |
} |
| 692 | 692 |
|
| 693 |
protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
|
|
| 693 |
protected void deleteAnnotationValues(List<? extends Match> matches, AnnotationType type, JobHandler job) {
|
|
| 694 | 694 |
if (concordance == null) {
|
| 695 | 695 |
return; |
| 696 | 696 |
} |
| ... | ... | |
| 728 | 728 |
} |
| 729 | 729 |
} |
| 730 | 730 |
|
| 731 |
protected void affectAnnotationValues(final List<Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 731 |
protected void affectAnnotationValues(final List<? extends Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 732 | 732 |
value_to_add = null; // reset |
| 733 | 733 |
if (concordance == null) {
|
| 734 | 734 |
System.out.println("No concordance done. Aborting."); //$NON-NLS-1$
|
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/storage/temporary/TemporaryAnnotationManager.java (revision 1969) | ||
|---|---|---|
| 9 | 9 |
import javax.persistence.EntityManager; |
| 10 | 10 |
import javax.persistence.EntityManagerFactory; |
| 11 | 11 |
import javax.persistence.TypedQuery; |
| 12 |
import javax.persistence.spi.PersistenceUnitTransactionType; |
|
| 13 | 12 |
|
| 14 | 13 |
import org.eclipse.persistence.config.PersistenceUnitProperties; |
| 15 |
import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo; |
|
| 16 | 14 |
import org.eclipse.persistence.jpa.PersistenceProvider; |
| 17 |
//import org.eclipse.persistence.jpa.PersistenceProvider; |
|
| 18 |
import org.txm.Toolbox; |
|
| 19 | 15 |
import org.txm.annotation.kr.core.Annotation; |
| 20 | 16 |
import org.txm.annotation.kr.core.AnnotationPK; |
| 21 | 17 |
import org.txm.annotation.kr.core.DatabasePersistenceManager; |
| 22 | 18 |
import org.txm.annotation.kr.core.repository.AnnotationEffect; |
| 23 | 19 |
import org.txm.annotation.kr.core.repository.AnnotationType; |
| 24 | 20 |
import org.txm.annotation.kr.core.repository.TypedValue; |
| 25 |
import org.txm.annotation.kr.core.temporary.CreateAnnotation; |
|
| 21 |
import org.txm.objects.Match; |
|
| 22 |
import org.txm.objects.Match2P; |
|
| 26 | 23 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 27 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 28 | 24 |
import org.txm.utils.logger.Log; |
| 29 | 25 |
|
| 30 | 26 |
public class TemporaryAnnotationManager {
|
| ... | ... | |
| 127 | 123 |
//check if it does not already exist, with either one of the positions (overlaps) |
| 128 | 124 |
//isOverlapAnnots = isOverlapAnnotationCritical(refType, refVal, startPos, endPos); |
| 129 | 125 |
ArrayList<Match> matches = new ArrayList<Match>(); |
| 130 |
matches.add(new Match(startPos, endPos)); |
|
| 126 |
matches.add(new Match2P(startPos, endPos));
|
|
| 131 | 127 |
overlapingAnnotations = getAnnotations(null, matches, null, false, true); // getAll annotation ovelapping with startPos-endPos |
| 132 | 128 |
for (int i = 0 ; i < overlapingAnnotations.size() ; i++) { // parse overlapping annotations to remove wrapping annotation with different type and annotation with same type and same position
|
| 133 | 129 |
annot = overlapingAnnotations.get(i); |
| ... | ... | |
| 304 | 300 |
* @return |
| 305 | 301 |
* @throws Exception |
| 306 | 302 |
*/ |
| 307 |
public List<Annotation> getAnnotations(AnnotationType type, List<Match> matches, String value, boolean ordered, boolean overlap) throws Exception {
|
|
| 303 |
public List<Annotation> getAnnotations(AnnotationType type, List<? extends Match> matches, String value, boolean ordered, boolean overlap) throws Exception {
|
|
| 308 | 304 |
String query = "SELECT annot FROM Annotation AS annot"; |
| 309 | 305 |
boolean where = false; // TODO: fucking shit, need to replace this |
| 310 | 306 |
|
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java (revision 1969) | ||
|---|---|---|
| 13 | 13 |
import org.txm.annotation.kr.core.repository.AnnotationType; |
| 14 | 14 |
import org.txm.annotation.kr.core.repository.TypedValue; |
| 15 | 15 |
import org.txm.annotation.kr.core.storage.temporary.TemporaryAnnotationManager; |
| 16 |
import org.txm.core.engines.Engine; |
|
| 17 |
import org.txm.core.results.TXMResult; |
|
| 18 |
import org.txm.objects.Project; |
|
| 16 |
import org.txm.objects.Match; |
|
| 17 |
import org.txm.objects.Match2P; |
|
| 19 | 18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 20 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 21 | 19 |
import org.txm.utils.logger.Log; |
| 22 | 20 |
|
| 23 | 21 |
/** |
| ... | ... | |
| 125 | 123 |
return true; |
| 126 | 124 |
} |
| 127 | 125 |
|
| 128 |
public boolean deleteAnnotations(AnnotationType type, List<Match> matches, IProgressMonitor job) throws Exception {
|
|
| 126 |
public boolean deleteAnnotations(AnnotationType type, List<? extends Match> matches, IProgressMonitor job) throws Exception {
|
|
| 129 | 127 |
try {
|
| 130 | 128 |
tempManager.getEntityManager().getTransaction().begin(); |
| 131 | 129 |
for (Match match : matches) {
|
| ... | ... | |
| 233 | 231 |
* @return |
| 234 | 232 |
*/ |
| 235 | 233 |
public HashMap<Match,List<Annotation>> createAnnotations(AnnotationType annotSelectedType, |
| 236 |
TypedValue annotSelectedTypedValue, List<Match> matches, IProgressMonitor job) {
|
|
| 234 |
TypedValue annotSelectedTypedValue, List<? extends Match> matches, IProgressMonitor job) {
|
|
| 237 | 235 |
|
| 238 | 236 |
HashMap<Match,List<Annotation>> allAnnotationsThatCollides = new HashMap<Match, List<Annotation>>(); |
| 239 | 237 |
tempManager.getEntityManager().getTransaction().begin(); // warning |
| ... | ... | |
| 307 | 305 |
List<Annotation> temporaryAnnotations = null; |
| 308 | 306 |
List<Annotation> cqpAnnotations = null; |
| 309 | 307 |
try {
|
| 310 |
temporaryAnnotations = tempManager.getAnnotations(type, Arrays.asList(new Match(start, end)), null, false, overlap); |
|
| 308 |
temporaryAnnotations = tempManager.getAnnotations(type, Arrays.asList(new Match2P(start, end)), null, false, overlap);
|
|
| 311 | 309 |
cqpAnnotations = cqpManager.getAnnotations(type, start, end, overlap); |
| 312 | 310 |
|
| 313 | 311 |
int i = 0; |
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotationManager.java (revision 1969) | ||
|---|---|---|
| 6 | 6 |
import java.util.List; |
| 7 | 7 |
|
| 8 | 8 |
import org.osgi.service.prefs.BackingStoreException; |
| 9 |
import org.txm.Toolbox; |
|
| 10 | 9 |
import org.txm.annotation.kr.core.repository.AnnotationEffect; |
| 11 | 10 |
import org.txm.annotation.kr.core.repository.AnnotationType; |
| 12 | 11 |
import org.txm.annotation.kr.core.repository.KnowledgeRepository; |
| 12 |
import org.txm.objects.Match; |
|
| 13 |
import org.txm.objects.Match2P; |
|
| 13 | 14 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
| 14 | 15 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 15 | 16 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| ... | ... | |
| 17 | 18 |
import org.txm.searchengine.cqp.corpus.Property; |
| 18 | 19 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 19 | 20 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 20 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 21 | 21 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
| 22 |
import org.txm.utils.logger.Log; |
|
| 23 | 22 |
|
| 24 | 23 |
public class CQPAnnotationManager {
|
| 25 | 24 |
MainCorpus corpus; |
| ... | ... | |
| 51 | 50 |
} |
| 52 | 51 |
|
| 53 | 52 |
public List<Annotation> getAnnotations(AnnotationType type, int start, int end) throws CqiClientException, IOException, CqiServerError {
|
| 54 |
return getAnnotations(type, new Match(start, end), null, false); |
|
| 53 |
return getAnnotations(type, new Match2P(start, end), null, false);
|
|
| 55 | 54 |
} |
| 56 | 55 |
|
| 57 | 56 |
public List<Annotation> getAnnotations(AnnotationType type, int start, int end, boolean overlap) throws CqiClientException, IOException, CqiServerError {
|
| 58 |
return getAnnotations(type, new Match(start, end), null, overlap); |
|
| 57 |
return getAnnotations(type, new Match2P(start, end), null, overlap);
|
|
| 59 | 58 |
} |
| 60 | 59 |
|
| 61 | 60 |
/** |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Match.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.core; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.List; |
|
| 5 |
|
|
| 6 |
public abstract class Match implements Comparable<Match> {
|
|
| 7 |
public abstract int getStart(); |
|
| 8 |
public abstract int getEnd(); |
|
| 9 |
public abstract int getTarget(); |
|
| 10 |
|
|
| 11 |
public boolean contains(Match m) {
|
|
| 12 |
return (this.getStart() <= m.getStart() && m.getEnd() <= this.getEnd()); |
|
| 13 |
} |
|
| 14 |
|
|
| 15 |
/* (non-Javadoc) |
|
| 16 |
* @see java.lang.Comparable#compareTo(java.lang.Object) |
|
| 17 |
*/ |
|
| 18 |
@Override |
|
| 19 |
public int compareTo(Match m) {
|
|
| 20 |
|
|
| 21 |
if (m == null) |
|
| 22 |
return -1; |
|
| 23 |
if (this.getStart() < m.getStart()) |
|
| 24 |
return -1; |
|
| 25 |
else if (this.getStart() > m.getStart()) |
|
| 26 |
return 1; |
|
| 27 |
else if (this.getEnd() < m.getEnd()) |
|
| 28 |
return -1; |
|
| 29 |
else |
|
| 30 |
return 1; |
|
| 31 |
|
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
/* (non-Javadoc) |
|
| 35 |
* @see java.lang.Object#toString() |
|
| 36 |
*/ |
|
| 37 |
@Override |
|
| 38 |
public String toString() {
|
|
| 39 |
return "<" + this.getStart() + ", " + this.getEnd() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
/** |
|
| 43 |
* Size. |
|
| 44 |
* |
|
| 45 |
* @return the int |
|
| 46 |
*/ |
|
| 47 |
public int size() {
|
|
| 48 |
return getEnd() - getStart() + 1; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
public List<Integer> getRange() {
|
|
| 52 |
List<Integer> ret = new ArrayList<Integer>(size()); |
|
| 53 |
for (int i = getStart() ; i <= getEnd(); i++) ret.add(i); |
|
| 54 |
return ret; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
public abstract void setEnd(int p); |
|
| 58 |
|
|
| 59 |
public abstract void setStart(int p); |
|
| 60 |
|
|
| 61 |
public abstract void setTarget(int p); |
|
| 62 |
} |
|
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java (revision 1969) | ||
|---|---|---|
| 32 | 32 |
*/ |
| 33 | 33 |
public Query fixQuery(); |
| 34 | 34 |
|
| 35 |
public boolean equals(Query q); |
|
| 36 |
|
|
| 35 | 37 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java (revision 1969) | ||
|---|---|---|
| 1 | 1 |
package org.txm.searchengine.core; |
| 2 | 2 |
|
| 3 |
import java.util.ArrayList; |
|
| 3 | 4 |
import java.util.List; |
| 4 | 5 |
|
| 6 |
import org.txm.objects.Match; |
|
| 7 |
|
|
| 5 | 8 |
public abstract class Selection {
|
| 6 | 9 |
|
| 7 |
|
|
| 8 |
|
|
| 9 | 10 |
public abstract List<? extends Match> getMatches() throws Exception; |
| 10 | 11 |
|
| 11 | 12 |
public abstract List<? extends Match> getMatches(int from, int to) throws Exception; |
| ... | ... | |
| 17 | 18 |
public abstract boolean isTargetUsed() throws Exception; |
| 18 | 19 |
|
| 19 | 20 |
public abstract void drop() throws Exception; |
| 21 |
|
|
| 22 |
public abstract boolean delete(int iMatch); |
|
| 23 |
|
|
| 24 |
public abstract boolean delete(Match match); |
|
| 25 |
|
|
| 26 |
public abstract boolean delete(ArrayList<Match> matchesToRemove); |
|
| 20 | 27 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java (revision 1969) | ||
|---|---|---|
| 1 | 1 |
package org.txm.searchengine.core; |
| 2 | 2 |
|
| 3 |
import java.util.List; |
|
| 4 |
|
|
| 3 | 5 |
import org.txm.core.engines.Engine; |
| 4 | 6 |
import org.txm.objects.CorpusBuild; |
| 7 |
import org.txm.objects.Match; |
|
| 5 | 8 |
import org.txm.utils.LogMonitor; |
| 6 | 9 |
|
| 7 | 10 |
// FIXME: useless class |
| 8 |
public abstract class SearchEngine implements Engine {
|
|
| 11 |
public abstract class SearchEngine implements ISearchEngine {
|
|
| 9 | 12 |
|
| 10 | 13 |
public static final String EXTENSION_POINT_ID = SearchEngine.class.getCanonicalName(); |
| 11 | 14 |
|
| ... | ... | |
| 30 | 33 |
public String getDetails() {
|
| 31 | 34 |
return this.getClass()+ " "+this.toString(); |
| 32 | 35 |
} |
| 36 |
|
|
| 37 |
/** |
|
| 38 |
* |
|
| 39 |
* @param match |
|
| 40 |
* @param property |
|
| 41 |
* @return the first position property value |
|
| 42 |
*/ |
|
| 43 |
public abstract String getValueForProperty(Match match, SearchEngineProperty property); |
|
| 44 |
|
|
| 45 |
/** |
|
| 46 |
* |
|
| 47 |
* @param match |
|
| 48 |
* @param property |
|
| 49 |
* @return the positions property value |
|
| 50 |
*/ |
|
| 51 |
public abstract List<String> getValuesForProperty(Match match, SearchEngineProperty property); |
|
| 33 | 52 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngineProperty.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.core; |
|
| 2 |
|
|
| 3 |
/** |
|
| 4 |
* A SearchEngine queryable property for match positions |
|
| 5 |
* |
|
| 6 |
* @author mdecorde |
|
| 7 |
* |
|
| 8 |
*/ |
|
| 9 |
public interface SearchEngineProperty {
|
|
| 10 |
|
|
| 11 |
/** |
|
| 12 |
* |
|
| 13 |
* @return the property uniq name in the queried corpus |
|
| 14 |
*/ |
|
| 15 |
public String getName(); |
|
| 16 |
|
|
| 17 |
} |
|
| 0 | 18 | |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java (revision 1969) | ||
|---|---|---|
| 3 | 3 |
import java.util.ArrayList; |
| 4 | 4 |
import java.util.List; |
| 5 | 5 |
|
| 6 |
import org.txm.objects.Match; |
|
| 7 |
|
|
| 6 | 8 |
public class EmptySelection extends Selection {
|
| 7 | 9 |
|
| 8 | 10 |
private static final List<? extends Match> EMPTY = new ArrayList<Match>(); |
| ... | ... | |
| 36 | 38 |
@Override |
| 37 | 39 |
public void drop() throws Exception {
|
| 38 | 40 |
} |
| 41 |
|
|
| 42 |
@Override |
|
| 43 |
public boolean delete(int iMatch) {
|
|
| 44 |
// nothing to do |
|
| 45 |
return false; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
@Override |
|
| 49 |
public boolean delete(Match match) {
|
|
| 50 |
// nothing to do |
|
| 51 |
return false; |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
public boolean delete(ArrayList<Match> matchesToRemove) {
|
|
| 56 |
return false; |
|
| 57 |
} |
|
| 39 | 58 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/ISearchEngine.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.core; |
|
| 2 |
|
|
| 3 |
import org.txm.core.engines.Engine; |
|
| 4 |
import org.txm.objects.CorpusBuild; |
|
| 5 |
|
|
| 6 |
public interface ISearchEngine extends Engine {
|
|
| 7 |
|
|
| 8 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception; |
|
| 9 |
|
|
| 10 |
/** |
|
| 11 |
* |
|
| 12 |
* @return an empty Query for the engine implementation |
|
| 13 |
*/ |
|
| 14 |
public Query newQuery(); |
|
| 15 |
|
|
| 16 |
/** |
|
| 17 |
* |
|
| 18 |
* @param corpus |
|
| 19 |
* @return true if the Engine can query the corpus |
|
| 20 |
*/ |
|
| 21 |
public abstract boolean hasIndexes(CorpusBuild corpus); |
|
| 22 |
|
|
| 23 |
public String getDetails(); |
|
| 24 |
} |
|
| 0 | 25 | |
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 1969) | ||
|---|---|---|
| 103 | 103 |
maxright = conc.getRightContextSize(); |
| 104 | 104 |
properties = new ArrayList<WordProperty>(); |
| 105 | 105 |
properties.addAll(conc.getAnalysisProperty()); |
| 106 |
query = conc.getQuery();
|
|
| 106 |
query = (CQLQuery) conc.getQuery(); //TODO manage all kind of Query
|
|
| 107 | 107 |
|
| 108 | 108 |
try {
|
| 109 | 109 |
cooc = new Cooccurrence(corpus); |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 1969) | ||
|---|---|---|
| 50 | 50 |
import org.txm.index.core.functions.LineComparator.SortMode; |
| 51 | 51 |
import org.txm.index.core.messages.IndexCoreMessages; |
| 52 | 52 |
import org.txm.index.core.preferences.IndexPreferences; |
| 53 |
import org.txm.searchengine.core.Match;
|
|
| 53 |
import org.txm.objects.Match;
|
|
| 54 | 54 |
import org.txm.searchengine.core.Query; |
| 55 | 55 |
import org.txm.searchengine.core.Selection; |
| 56 | 56 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 1969) | ||
|---|---|---|
| 49 | 49 |
import org.txm.index.core.functions.LineComparator.SortMode; |
| 50 | 50 |
import org.txm.index.core.messages.IndexCoreMessages; |
| 51 | 51 |
import org.txm.index.core.preferences.IndexPreferences; |
| 52 |
import org.txm.searchengine.core.Match;
|
|
| 52 |
import org.txm.objects.Match;
|
|
| 53 | 53 |
import org.txm.searchengine.core.Query; |
| 54 | 54 |
import org.txm.searchengine.core.Selection; |
| 55 | 55 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 1969) | ||
|---|---|---|
| 42 | 42 |
import org.txm.concordance.core.functions.Line; |
| 43 | 43 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
| 44 | 44 |
import org.txm.core.preferences.TXMPreferences; |
| 45 |
import org.txm.searchengine.core.SearchEngine; |
|
| 45 | 46 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 46 | 47 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 47 | 48 |
import org.txm.searchengine.cqp.corpus.Property; |
| 48 | 49 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 50 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 49 | 51 |
import org.txm.utils.logger.Log; |
| 50 | 52 |
|
| 51 | 53 |
import vlcplayerrcp.MessagesMP; |
| ... | ... | |
| 84 | 86 |
return null; |
| 85 | 87 |
} |
| 86 | 88 |
ConcordanceEditor ce = (ConcordanceEditor) page; |
| 87 |
|
|
| 89 |
SearchEngine se = ce.getConcordance().getQuery().getSearchEngine(); |
|
| 88 | 90 |
selection = (IStructuredSelection)o; |
| 89 | 91 |
|
| 90 | 92 |
Object s = selection.getFirstElement(); |
| ... | ... | |
| 96 | 98 |
String startPropertyName = BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.STRUCTURE_START_PROPERTY); //$NON-NLS-1$ |
| 97 | 99 |
String endPropertyName = BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.STRUCTURE_END_PROPERTY); //$NON-NLS-1$ |
| 98 | 100 |
|
| 99 |
|
|
| 100 | 101 |
Line line = (Line)s; |
| 101 | 102 |
CQPCorpus corpus = line.getConcordance().getCorpus(); |
| 102 | 103 |
|
| ... | ... | |
| 110 | 111 |
|
| 111 | 112 |
StructuralUnit textS = corpus.getStructuralUnit("text"); //$NON-NLS-1$
|
| 112 | 113 |
Property textP = textS.getProperty("id"); //$NON-NLS-1$
|
| 113 |
String textid = line.getMatch().getValueForProperty(textP);// get text via text struc property id |
|
| 114 |
String textid = line.getTextId();//line.getMatch().getValueForProperty(textP);// get text via text struc property id |
|
| 115 |
|
|
| 114 | 116 |
Log.fine(MessagesMP.BackToMedia_7+textid); |
| 115 | 117 |
|
| 116 | 118 |
if (useWordProperty) {
|
| ... | ... | |
| 140 | 142 |
System.out.println(MessagesMP.bind(MessagesMP.BackToMedia_14, startPropertyName)); |
| 141 | 143 |
return null; |
| 142 | 144 |
} |
| 143 |
sStartTime = line.getMatch().getValueForProperty(startProperty); |
|
| 145 |
|
|
| 146 |
sStartTime = Match.getValueForProperty(startProperty, line.getMatch().getStart()); |
|
| 144 | 147 |
Log.fine(MessagesMP.BackToMedia_16+sStartTime); |
| 145 | 148 |
|
| 146 | 149 |
Property endProperty = structure.getProperty(endPropertyName); |
| ... | ... | |
| 148 | 151 |
System.out.println(MessagesMP.bind(MessagesMP.BackToMedia_17, endPropertyName)); |
| 149 | 152 |
return null; |
| 150 | 153 |
} |
| 151 |
sEndTime = line.getMatch().getValueForProperty(endProperty);
|
|
| 154 |
sEndTime = Match.getValueForProperty(endProperty, line.getMatch().getStart());
|
|
| 152 | 155 |
Log.fine(MessagesMP.BackToMedia_19+sEndTime); |
| 153 | 156 |
} |
| 154 | 157 |
|
| tmp/org.txm.core/src/java/org/txm/objects/CorpusBuild.java (revision 1969) | ||
|---|---|---|
| 881 | 881 |
protected void setID(String id) {
|
| 882 | 882 |
this.pID = id; |
| 883 | 883 |
} |
| 884 |
|
|
| 885 |
public abstract void setIsModified(boolean b); |
|
| 886 |
|
|
| 887 |
public abstract CorpusBuild getRootCorpusBuild(); |
|
| 888 |
|
|
| 889 |
public abstract List<? extends Match> getMatches(); |
|
| 884 | 890 |
} |
| tmp/org.txm.core/src/java/org/txm/objects/Match.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.objects; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.List; |
|
| 5 |
|
|
| 6 |
public abstract class Match implements Comparable<Match> {
|
|
| 7 |
public abstract int getStart(); |
|
| 8 |
public abstract int getEnd(); |
|
| 9 |
public abstract int getTarget(); |
|
| 10 |
|
|
| 11 |
public boolean contains(Match m) {
|
|
| 12 |
return (this.getStart() <= m.getStart() && m.getEnd() <= this.getEnd()); |
|
| 13 |
} |
|
| 14 |
|
|
| 15 |
/* (non-Javadoc) |
|
| 16 |
* @see java.lang.Comparable#compareTo(java.lang.Object) |
|
| 17 |
*/ |
|
| 18 |
@Override |
|
| 19 |
public int compareTo(Match m) {
|
|
| 20 |
|
|
| 21 |
if (m == null) |
|
| 22 |
return -1; |
|
| 23 |
if (this.getStart() < m.getStart()) |
|
| 24 |
return -1; |
|
| 25 |
else if (this.getStart() > m.getStart()) |
|
| 26 |
return 1; |
|
| 27 |
else if (this.getEnd() < m.getEnd()) |
|
| 28 |
return -1; |
|
| 29 |
else |
|
| 30 |
return 1; |
|
| 31 |
|
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
/* (non-Javadoc) |
|
| 35 |
* @see java.lang.Object#toString() |
|
| 36 |
*/ |
|
| 37 |
@Override |
|
| 38 |
public String toString() {
|
|
| 39 |
return "<" + this.getStart() + ", " + this.getEnd() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
/** |
|
| 43 |
* Size. |
|
| 44 |
* |
|
| 45 |
* @return the int |
|
| 46 |
*/ |
|
| 47 |
public int size() {
|
|
| 48 |
return getEnd() - getStart() + 1; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
public List<Integer> getRange() {
|
|
| 52 |
List<Integer> ret = new ArrayList<Integer>(size()); |
|
| 53 |
for (int i = getStart() ; i <= getEnd(); i++) ret.add(i); |
|
| 54 |
return ret; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
public abstract void setEnd(int p); |
|
| 58 |
|
|
| 59 |
public abstract void setStart(int p); |
|
| 60 |
|
|
| 61 |
public abstract void setTarget(int p); |
|
| 62 |
} |
|
| 0 | 63 | |
| tmp/org.txm.core/src/java/org/txm/objects/Match2P.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.objects; |
|
| 2 |
|
|
| 3 |
/** |
|
| 4 |
* A simple Match implementation with 2 positions: start and end |
|
| 5 |
* |
|
| 6 |
* @author mdecorde |
|
| 7 |
* |
|
| 8 |
*/ |
|
| 9 |
public class Match2P extends Match {
|
|
| 10 |
protected int start; |
|
| 11 |
protected int end; |
|
| 12 |
|
|
| 13 |
public Match2P(int start, int end) {
|
|
| 14 |
this.start = start; |
|
| 15 |
this.end = end; |
|
| 16 |
} |
|
| 17 |
|
|
| 18 |
@Override |
|
| 19 |
public int getStart() {
|
|
| 20 |
return start; |
|
| 21 |
} |
|
| 22 |
|
|
| 23 |
@Override |
|
| 24 |
public int getEnd() {
|
|
| 25 |
return end; |
|
| 26 |
} |
|
| 27 |
|
|
| 28 |
@Override |
|
| 29 |
public int getTarget() {
|
|
| 30 |
return -1; |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
@Override |
|
| 34 |
public void setEnd(int p) {
|
|
| 35 |
end = p; |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
@Override |
|
| 39 |
public void setStart(int p) {
|
|
| 40 |
start = p; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
@Override |
|
| 44 |
public void setTarget(int p) { }
|
|
| 45 |
} |
|
| 0 | 46 | |
| tmp/org.txm.analec.rcp/plugin.xml (revision 1969) | ||
|---|---|---|
| 344 | 344 |
description="URS annotations"> |
| 345 | 345 |
</AnnotationEngine> |
| 346 | 346 |
</extension> |
| 347 |
<extension |
|
| 348 |
point="org.txm.searchengine.core.SearchEngine"> |
|
| 349 |
<SearchEngine |
|
| 350 |
class="org.txm.annotation.urs.search.URSSearchEngine"> |
|
| 351 |
</SearchEngine> |
|
| 352 |
</extension> |
|
| 347 | 353 |
|
| 348 | 354 |
</plugin> |
| tmp/org.txm.analec.rcp/META-INF/MANIFEST.MF (revision 1969) | ||
|---|---|---|
| 161 | 161 |
org.txm.annotation.urs.export, |
| 162 | 162 |
org.txm.annotation.urs.imports, |
| 163 | 163 |
org.txm.annotation.urs.preferences, |
| 164 |
org.txm.annotation.urs.search, |
|
| 164 | 165 |
org.txm.annotation.urs.testers, |
| 165 | 166 |
org.txm.annotation.urs.toolbar, |
| 166 | 167 |
org.txm.annotation.urs.view, |
| 167 | 168 |
org.txm.annotation.urs.widgets, |
| 168 | 169 |
org.txm.macro.urs, |
| 170 |
org.txm.macro.urs.cqp, |
|
| 169 | 171 |
org.txm.macro.urs.edit, |
| 170 | 172 |
org.txm.macro.urs.exploit, |
| 171 | 173 |
org.txm.macro.urs.exploit.mesures1, |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSearchEngine.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.annotation.urs.search; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.Collections; |
|
| 5 |
import java.util.LinkedHashMap; |
|
| 6 |
import java.util.List; |
|
| 7 |
import java.util.regex.Pattern; |
|
| 8 |
|
|
| 9 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 10 |
import org.txm.annotation.urs.URSCorpora; |
|
| 11 |
import org.txm.core.results.TXMResult; |
|
| 12 |
import org.txm.objects.CorpusBuild; |
|
| 13 |
import org.txm.objects.Match; |
|
| 14 |
import org.txm.searchengine.core.Query; |
|
| 15 |
import org.txm.searchengine.core.SearchEngine; |
|
| 16 |
import org.txm.searchengine.core.SearchEngineProperty; |
|
| 17 |
import org.txm.searchengine.core.Selection; |
|
| 18 |
import org.txm.utils.logger.Log; |
|
| 19 |
|
|
| 20 |
import visuAnalec.donnees.Corpus; |
|
| 21 |
import visuAnalec.elements.*; |
|
| 22 |
|
|
| 23 |
public class URSSearchEngine extends SearchEngine {
|
|
| 24 |
|
|
| 25 |
public URSSearchEngine() {
|
|
| 26 |
// TODO Auto-generated constructor stub |
|
| 27 |
} |
|
| 28 |
|
|
| 29 |
@Override |
|
| 30 |
public boolean isRunning() {
|
|
| 31 |
return true; |
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
@Override |
|
| 35 |
public boolean initialize() throws Exception {
|
|
| 36 |
return true; |
|
| 37 |
} |
|
| 38 |
|
|
| 39 |
@Override |
|
| 40 |
public boolean start(IProgressMonitor monitor) throws Exception {
|
|
| 41 |
return true; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
@Override |
|
| 45 |
public boolean stop() throws Exception {
|
|
| 46 |
return true; |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
@Override |
|
| 50 |
public void notify(TXMResult r, String state) {
|
|
| 51 |
// nothing |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
public String getName() {
|
|
| 56 |
return "URS"; |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
@Override |
|
| 60 |
public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
|
|
| 61 |
|
|
| 62 |
ArrayList<Element> elements = findAllInCorpus(0, URSCorpora.getCorpus(corpus), corpus, Unite.class, query.getQueryString()); |
|
| 63 |
ArrayList<URSMatch> matches = new ArrayList<URSMatch>(); |
|
| 64 |
for (Element e : elements) {
|
|
| 65 |
matches.add(new URSMatch(e.getUnite0().getDeb(), e.getUnite0().getFin())); |
|
| 66 |
} |
|
| 67 |
return new URSSelection(query, matches); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
static String[] getFilterParameters(String URSQL) {
|
|
| 71 |
|
|
| 72 |
String type = ""; |
|
| 73 |
String prop = ""; |
|
| 74 |
String value = ""; |
|
| 75 |
|
|
| 76 |
if (URSQL == null) return new String[] {type, prop, value};
|
|
| 77 |
|
|
| 78 |
int atidx = URSQL.indexOf("@");
|
|
| 79 |
int equalidx = URSQL.indexOf("=");
|
|
| 80 |
|
|
| 81 |
if (atidx >= 0 && equalidx >= 0 && atidx < equalidx) {
|
|
| 82 |
type = URSQL.substring(0, atidx); |
|
| 83 |
prop = URSQL.substring(atidx+1, equalidx); |
|
| 84 |
value = URSQL.substring(equalidx+1); |
|
| 85 |
} else if (atidx >= 0) {
|
|
| 86 |
type = URSQL.substring(0, atidx); |
|
| 87 |
prop = URSQL.substring(atidx+1); |
|
| 88 |
} else if (equalidx >= 0) {
|
|
| 89 |
type = URSQL.substring(0, equalidx); |
|
| 90 |
value = URSQL.substring(equalidx+1); |
|
| 91 |
} else {
|
|
| 92 |
type = URSQL; |
|
| 93 |
} |
|
| 94 |
// println(["'"+type+"'", "'"+prop+"'", "'"+value+"'"]) |
|
| 95 |
|
|
| 96 |
return new String[] {type, prop, value};
|
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
static ArrayList<Element> findAllInCorpus(int debug, Corpus analecCorpus, CorpusBuild corpus, Class elemClazz, String URSQL) {
|
|
| 100 |
String[] params = getFilterParameters(URSQL); |
|
| 101 |
if (debug >= 2) Log.finer("PARAMS=$params");
|
|
| 102 |
return findAllInCorpus(debug, analecCorpus, corpus, elemClazz, params[0], params[1], params[2]); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
static ArrayList<Element> findAllInCorpus(int debug, Corpus analecCorpus, CorpusBuild corpus, Class elemClazz, String typeRegex, String propName, String valueRegex) {
|
|
| 106 |
ArrayList<Element> allElements = new ArrayList<Element>(); |
|
| 107 |
|
|
| 108 |
if (elemClazz != null) {
|
|
| 109 |
if (elemClazz == Unite.class) |
|
| 110 |
allElements.addAll(analecCorpus.getToutesUnites()); |
|
| 111 |
else if (elemClazz == Relation.class) |
|
| 112 |
allElements.addAll(analecCorpus.getToutesRelations()); |
|
| 113 |
else if (elemClazz == Schema.class) |
|
| 114 |
allElements.addAll(analecCorpus.getTousSchemas()); |
|
| 115 |
} else {
|
|
| 116 |
allElements.addAll(analecCorpus.getToutesUnites()); |
|
| 117 |
allElements.addAll(analecCorpus.getToutesRelations()); |
|
| 118 |
allElements.addAll(analecCorpus.getTousSchemas()); |
|
| 119 |
} |
|
| 120 |
|
|
| 121 |
return filterElements(debug, allElements, corpus, typeRegex, propName, valueRegex); |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/** |
|
| 125 |
* group units by CQP match |
|
| 126 |
* |
|
| 127 |
* units are sorted for faster processing |
|
| 128 |
* |
|
| 129 |
* @param allUnites |
|
| 130 |
* @param matches |
|
| 131 |
* @param strict_inclusion |
|
| 132 |
* @return |
|
| 133 |
*/ |
|
| 134 |
static LinkedHashMap groupByMatch(int debug, ArrayList<Element> allUnites, List<? extends Match> matches, boolean strict_inclusion) {
|
|
| 135 |
if (debug >= 2) Log.finer("group "+allUnites.size()+" units with "+matches.size()+" strict=$strict_inclusion");
|
|
| 136 |
//println allUnites.collect() {it -> it.getDeb()}
|
|
| 137 |
Collections.sort(allUnites);// { a, b -> a.getDeb() <=> b.getDeb() ?: a.getFin() <=> b.getFin() };
|
|
| 138 |
//println allUnites.collect() {it -> it.getDeb()}
|
|
| 139 |
int unitsSize = allUnites.size(); |
|
| 140 |
int iCurrentUnit = 0; |
|
| 141 |
ArrayList<Element> selectedUnits = new ArrayList<Element>(); |
|
| 142 |
|
|
| 143 |
int matchesSize = matches.size(); |
|
| 144 |
int iCurrentMatch = 0; |
|
| 145 |
|
|
| 146 |
LinkedHashMap<Match, ArrayList<Element>> selectedUnitsPerMatch = new LinkedHashMap<Match, ArrayList<Element>>(); |
|
| 147 |
selectedUnitsPerMatch.put(matches.get(iCurrentMatch), selectedUnits); |
|
| 148 |
|
|
| 149 |
while (iCurrentMatch < matchesSize && iCurrentUnit < unitsSize) {
|
|
| 150 |
if (debug >= 2) Log.finer("** M $iCurrentMatch < $matchesSize && U $iCurrentUnit < $unitsSize");
|
|
| 151 |
|
|
| 152 |
Element e = allUnites.get(iCurrentUnit); |
|
| 153 |
Unite unit = e.getUnite0(); |
|
| 154 |
Match match = matches.get(iCurrentMatch); |
|
| 155 |
if (debug >= 3) Log.finer(""+unit.getDeb()+"->"+unit.getFin()+" "+match.getStart()+"->"+match.getEnd());
|
|
| 156 |
if (unit.getFin() < match.getStart()) {
|
|
| 157 |
if (debug >= 3) Log.finer("next unit");
|
|
| 158 |
iCurrentUnit++; |
|
| 159 |
} else if (unit.getDeb() > match.getEnd()) {
|
|
| 160 |
if (debug >= 3) Log.finer("next match");
|
|
| 161 |
iCurrentMatch++; |
|
| 162 |
selectedUnits = new ArrayList<Element>(); |
|
| 163 |
selectedUnitsPerMatch.put(match, selectedUnits); |
|
| 164 |
} else {
|
|
| 165 |
if (debug >= 3) Log.finer("iCurrentUnit=$iCurrentUnit iCurrentMatch=$iCurrentMatch");
|
|
| 166 |
if (strict_inclusion) {
|
|
| 167 |
|
|
| 168 |
if (debug >= 3) Log.finer("m.start ${match.getStart()} <= u.deb ${unit.getDeb()} && u.fin ${unit.getFin()} <= m.end ${match.getEnd()}");
|
|
| 169 |
if (match.getStart() <= unit.getDeb() && unit.getFin() <= match.getEnd()) {
|
|
| 170 |
selectedUnits.add(unit); |
|
| 171 |
} |
|
| 172 |
} else {
|
|
| 173 |
selectedUnits.add(unit); |
|
| 174 |
} |
|
| 175 |
|
|
| 176 |
iCurrentUnit++; |
|
| 177 |
} |
|
| 178 |
} |
|
| 179 |
return selectedUnitsPerMatch; |
|
| 180 |
} |
|
| 181 |
|
|
| 182 |
static ArrayList<Element> filterUniteByInclusion(int debug, ArrayList<Element> allUnites, List<? extends Match> matches, boolean strict_inclusion, int limit_distance) {
|
|
| 183 |
|
|
| 184 |
LinkedHashMap<Match, ArrayList<Element>> selectedUnitsPerMatch = groupByMatch(debug, allUnites, matches, strict_inclusion); |
|
| 185 |
//println "selectedUnitsPerMatch size="+selectedUnitsPerMatch.size() |
|
| 186 |
ArrayList<Element> selectedUnits = new ArrayList<Element>(); |
|
| 187 |
if (limit_distance != 0) {
|
|
| 188 |
if (limit_distance > 0) limit_distance--; |
|
| 189 |
|
|
| 190 |
for (Match m : selectedUnitsPerMatch.keySet()) {
|
|
| 191 |
ArrayList<Element> units = selectedUnitsPerMatch.get(m); |
|
| 192 |
if (units.size() > limit_distance && units.size() > 0) {
|
|
| 193 |
//println "$m -> "+units.collect() {it -> it.getDeb()}
|
|
| 194 |
Collections.sort(units); |
|
| 195 |
//println "$m -> "+units.collect() {it -> it.getDeb()}
|
|
| 196 |
selectedUnits.add(units.get(limit_distance)); |
|
| 197 |
if (debug >=3) Log.finer("dist select: "+units.get(limit_distance).getUnite0().getDeb());
|
|
| 198 |
} |
|
| 199 |
} |
|
| 200 |
} else {
|
|
| 201 |
for (Match m : selectedUnitsPerMatch.keySet()) selectedUnits.addAll(selectedUnitsPerMatch.get(m)); |
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
return selectedUnits; |
|
| 205 |
} |
|
| 206 |
|
|
| 207 |
static ArrayList<Element> filterElements(int debug, ArrayList<Element> allElements, CorpusBuild corpus, String typeRegex, String propName, String valueRegex) {
|
|
| 208 |
if (debug >= 2) Log.finer("filtering "+allElements.size()+" elements with typeRegex='$typeRegex' propName='$propName' and valueRegex='$valueRegex'");
|
|
| 209 |
|
|
| 210 |
if (corpus != null) {
|
|
| 211 |
allElements = filterUniteByInclusion(debug, allElements, corpus.getMatches(), true, 0); |
|
| 212 |
} |
|
| 213 |
|
|
| 214 |
if (typeRegex != null && typeRegex.length() > 0) {
|
|
| 215 |
ArrayList<Element> filteredElements = new ArrayList<Element>(); |
|
| 216 |
Pattern pattern = Pattern.compile(typeRegex); |
|
| 217 |
for (Element element : allElements) {
|
|
| 218 |
if (pattern.matcher(element.getType()).matches()) {
|
|
| 219 |
filteredElements.add(element); |
|
| 220 |
} |
|
| 221 |
} |
|
| 222 |
|
|
| 223 |
allElements = filteredElements; |
|
| 224 |
} |
|
| 225 |
if (debug >= 2) Log.finer(" type step result: "+allElements.size());
|
|
| 226 |
|
|
| 227 |
if (propName != null && propName.length() > 0) {
|
|
| 228 |
ArrayList<Element> filteredElements = new ArrayList<Element>(); |
|
| 229 |
if (valueRegex != null && valueRegex.length() > 0) { // select only elements with the prop&value
|
|
| 230 |
Pattern pattern = Pattern.compile(valueRegex); |
|
| 231 |
for (Element element : allElements) {
|
|
| 232 |
String value = element.getProp(propName); |
|
| 233 |
if (value != null && pattern.matcher(value).matches()) {
|
|
| 234 |
filteredElements.add(element); |
|
| 235 |
} |
|
| 236 |
} |
|
| 237 |
} else { // select only elements with the prop
|
|
| 238 |
for (Element element : allElements) {
|
|
| 239 |
if (element.getProps().containsKey(propName)) {
|
|
| 240 |
filteredElements.add(element); |
|
| 241 |
} |
|
| 242 |
} |
|
| 243 |
} |
|
| 244 |
|
|
| 245 |
allElements = filteredElements; |
|
| 246 |
} |
|
| 247 |
if (debug >= 2) Log.finer(" prop&value step result: "+allElements.size());
|
|
| 248 |
return allElements; |
|
| 249 |
} |
|
| 250 |
|
|
| 251 |
@Override |
|
| 252 |
public Query newQuery() {
|
|
| 253 |
return new URSQuery(); |
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
@Override |
|
| 257 |
public boolean hasIndexes(CorpusBuild corpus) {
|
|
| 258 |
return URSCorpora.isAnnotationStructureReady(corpus); |
|
| 259 |
} |
|
| 260 |
|
|
| 261 |
@Override |
|
| 262 |
public String getValueForProperty(Match match, SearchEngineProperty property) {
|
|
| 263 |
// TODO Auto-generated method stub |
|
| 264 |
return null; |
|
| 265 |
} |
|
| 266 |
|
|
| 267 |
@Override |
|
| 268 |
public List<String> getValuesForProperty(Match match, SearchEngineProperty property) {
|
|
| 269 |
// TODO Auto-generated method stub |
|
| 270 |
return null; |
|
| 271 |
} |
|
| 272 |
|
|
| 273 |
} |
|
| 0 | 274 | |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSMatch.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.annotation.urs.search; |
|
| 2 |
|
|
| 3 |
import org.txm.objects.Match2P; |
|
| 4 |
|
|
| 5 |
public class URSMatch extends Match2P {
|
|
| 6 |
|
|
| 7 |
public URSMatch(int start, int end) {
|
|
| 8 |
super(start, end); |
|
| 9 |
} |
|
| 10 |
|
|
| 11 |
} |
|
| 0 | 12 | |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSQuery.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.annotation.urs.search; |
|
| 2 |
|
|
| 3 |
import org.txm.Toolbox; |
|
| 4 |
import org.txm.core.engines.EngineType; |
|
| 5 |
import org.txm.searchengine.core.Query; |
|
| 6 |
import org.txm.searchengine.core.SearchEngine; |
|
| 7 |
|
|
| 8 |
/** |
|
| 9 |
* |
|
| 10 |
* Simple implementation of URS query in the "TYPE@PROPERTY=REGEX" form |
|
| 11 |
* |
|
| 12 |
* @author mdecorde |
|
| 13 |
* |
|
| 14 |
*/ |
|
| 15 |
public class URSQuery implements Query {
|
|
| 16 |
|
|
| 17 |
String query = ""; //$NON-NLS-1$ |
|
| 18 |
|
|
| 19 |
@Override |
|
| 20 |
public String getQueryString() {
|
|
| 21 |
return query; |
|
| 22 |
} |
|
| 23 |
|
|
| 24 |
@Override |
|
| 25 |
public boolean isEmpty() {
|
|
| 26 |
return query == null || query.isEmpty(); |
|
| 27 |
} |
|
| 28 |
|
|
| 29 |
@Override |
|
| 30 |
public SearchEngine getSearchEngine() {
|
|
| 31 |
return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine("URS"); //$NON-NLS-1$
|
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
@Override |
|
| 35 |
public Query setQuery(String rawQuery) {
|
|
| 36 |
query = rawQuery; |
|
| 37 |
return this; |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
@Override |
|
| 41 |
public Query fixQuery() {
|
|
| 42 |
return this; |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
@Override |
|
| 46 |
public String toString() {
|
|
| 47 |
return query; |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
@Override |
|
| 51 |
public boolean equals(Query q) {
|
|
| 52 |
return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString()); |
|
| 53 |
} |
|
| 54 |
} |
|
| 0 | 55 | |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java (revision 1969) | ||
|---|---|---|
| 1 |
package org.txm.annotation.urs.search; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.List; |
|
| 5 |
|
|
| 6 |
import org.txm.objects.Match; |
|
| 7 |
import org.txm.searchengine.core.Query; |
|
| 8 |
import org.txm.searchengine.core.Selection; |
|
| 9 |
|
|
| 10 |
public class URSSelection extends Selection {
|
|
| 11 |
|
|
| 12 |
ArrayList<? extends Match> matches; |
|
| 13 |
Query query; |
|
| 14 |
|
|
| 15 |
public URSSelection(Query query, ArrayList<URSMatch> matches2) {
|
|
| 16 |
this.query = query; |
|
| 17 |
matches = matches2; |
|
| 18 |
} |
|
| 19 |
|
|
| 20 |
@Override |
|
| 21 |
public List<? extends Match> getMatches() throws Exception {
|
|
| 22 |
return matches; |
|
| 23 |
} |
|
| 24 |
|
|
| 25 |
@Override |
|
| 26 |
public List<? extends Match> getMatches(int from, int to) throws Exception {
|
|
| 27 |
if (to > matches.size()) to = matches.size(); |
|
| 28 |
return matches.subList(from, to + 1); // +1 because Match.getMatches is start-end inclusive and List.subList is start inclusif and end exclusif |
|
| 29 |
} |
|
| 30 |
|
|
| 31 |
@Override |
|
| 32 |
public int getNMatch() throws Exception {
|
|
| 33 |
return matches.size(); |
|
| 34 |
} |
|
| 35 |
|
|
| 36 |
@Override |
|
| 37 |
public Query getQuery() {
|
|
| 38 |
return query; |
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
@Override |
|
| 42 |
public boolean isTargetUsed() throws Exception {
|
|
| 43 |
return false; |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
@Override |
|
| 47 |
public void drop() throws Exception {
|
|
| 48 |
// TODO Auto-generated method stub |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
@Override |
|
| 52 |
public boolean delete(int iMatch) {
|
|
| 53 |
if (iMatch < 0) return false; |
|
| 54 |
if (iMatch >= matches.size()) return false; |
|
| 55 |
return matches.remove(iMatch) != null; |
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
@Override |
|
| 59 |
public boolean delete(Match match) {
|
|
| 60 |
return matches.remove(match); |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
@Override |
|
| 64 |
public boolean delete(ArrayList<Match> matchesToRemove) {
|
|
| 65 |
return matches.removeAll(matchesToRemove); |
|
| 66 |
} |
|
| 67 |
} |
|
| 0 | 68 | |
| tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/URSCorpora.java (revision 1969) | ||
|---|---|---|
| 5 | 5 |
|
| 6 | 6 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 7 | 7 |
import org.eclipse.osgi.util.NLS; |
| 8 |
import org.txm.Toolbox; |
|
| 9 | 8 |
import org.txm.annotation.core.AnnotationEngine; |
| 10 | 9 |
import org.txm.core.results.TXMResult; |
| 10 |
import org.txm.objects.CorpusBuild; |
|
| 11 | 11 |
import org.txm.objects.Project; |
| 12 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
| 13 | 12 |
import org.txm.utils.DeleteDir; |
| 14 | 13 |
|
| 15 | 14 |
import visuAnalec.donnees.Corpus; |
| ... | ... | |
| 24 | 23 |
*/ |
| 25 | 24 |
public class URSCorpora extends AnnotationEngine {
|
| 26 | 25 |
|
| 27 |
private static final HashMap<MainCorpus, Corpus> corpora = new HashMap<MainCorpus, Corpus>();
|
|
| 28 |
private static final HashMap<MainCorpus, Vue> vues = new HashMap<MainCorpus, Vue>();
|
|
| 26 |
private static final HashMap<CorpusBuild, Corpus> corpora = new HashMap<CorpusBuild, Corpus>();
|
|
| 27 |
private static final HashMap<CorpusBuild, Vue> vues = new HashMap<CorpusBuild, Vue>();
|
|
| 29 | 28 |
|
| 30 | 29 |
/** |
| 31 | 30 |
* Create the ec file if needed, store a reference to the corpus if not already done. |
| ... | ... | |
| 33 | 32 |
* @param mcorpus |
| 34 | 33 |
* @return the Corpus loaded and stored |
| 35 | 34 |
*/ |
| 36 |
public static Corpus getCorpus(MainCorpus mcorpus) {
|
|
| 35 |
public static Corpus getCorpus(CorpusBuild mcorpus) {
|
|
| 36 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 37 | 37 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ec"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 38 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ecv"); |
|
| 38 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ecv"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 39 | 39 |
Corpus corpus = null; |
| 40 | 40 |
if (URSCorpora.corpora.containsKey(mcorpus)) {
|
| 41 | 41 |
corpus = URSCorpora.corpora.get(mcorpus); |
| ... | ... | |
| 81 | 81 |
return corpus; |
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 |
public static boolean isAnnotationStructureReady(org.txm.searchengine.cqp.corpus.CQPCorpus corpus) {
|
|
| 85 |
return isAnnotationStructureReady(corpus.getMainCorpus()); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
public static boolean isAnnotationStructureReady(MainCorpus name) {
|
|
| 89 |
if (URSCorpora.corpora.containsKey(name)) {
|
|
| 90 |
return !URSCorpora.corpora.get(name).getStructure().isVide(); |
|
| 84 |
public static boolean isAnnotationStructureReady(CorpusBuild mcorpus) {
|
|
| 85 |
|
|
| 86 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 87 |
|
|
| 88 |
if (URSCorpora.corpora.containsKey(mcorpus)) {
|
|
| 89 |
return !URSCorpora.corpora.get(mcorpus).getStructure().isVide(); |
|
| 91 | 90 |
} else {
|
| 92 |
File fichierCorpus = new File(Toolbox.getTxmHomePath(), "corpora/"+name+"/analec/"+name+".ec"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 91 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ec"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 93 | 92 |
if (fichierCorpus.exists()) {
|
| 94 |
return !getCorpus(name).getStructure().isVide();
|
|
| 93 |
return !getCorpus(mcorpus).getStructure().isVide();
|
|
| 95 | 94 |
} else {
|
| 96 | 95 |
return false; |
| 97 | 96 |
} |
| ... | ... | |
| 104 | 103 |
* @param name |
| 105 | 104 |
* @return the corpus Vue |
| 106 | 105 |
*/ |
| 107 |
public static Vue getVue(MainCorpus name) {
|
|
| 108 |
if (!vues.containsKey(name)) {
|
|
| 109 |
if (!corpora.containsKey(name)) {
|
|
| 110 |
getCorpus(name); |
|
| 106 |
public static Vue getVue(CorpusBuild mcorpus) {
|
|
| 107 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 108 |
|
|
| 109 |
if (!vues.containsKey(mcorpus)) {
|
|
| 110 |
if (!corpora.containsKey(mcorpus)) {
|
|
| 111 |
getCorpus(mcorpus); |
|
| 111 | 112 |
} |
| 112 |
Corpus corpus = getCorpus(name);
|
|
| 113 |
Corpus corpus = getCorpus(mcorpus);
|
|
| 113 | 114 |
Vue vue = new Vue(corpus); |
| 114 |
vues.put(name, vue);
|
|
| 115 |
vues.put(mcorpus, vue);
|
|
| 115 | 116 |
} |
| 116 |
return vues.get(name);
|
|
| 117 |
return vues.get(mcorpus);
|
|
| 117 | 118 |
} |
| 118 | 119 |
|
| 119 |
public static boolean saveCorpus(MainCorpus mcorpus) {
|
|
| 120 |
/** |
|
| 121 |
* Save the associated AnalecCorpus |
|
| 122 |
* @param mcorpus |
|
| 123 |
* @return true if the annotations have been saved |
|
| 124 |
*/ |
|
| 125 |
public static boolean saveCorpus(CorpusBuild mcorpus) {
|
|
| 126 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 120 | 127 |
Corpus corpus = getCorpus(mcorpus); |
| 121 | 128 |
Vue vue = getVue(mcorpus); |
| 122 | 129 |
File dir = new File(mcorpus.getProjectDirectory(), "analec/"); //$NON-NLS-1$ //$NON-NLS-2$ |
| ... | ... | |
| 128 | 135 |
} |
| 129 | 136 |
|
| 130 | 137 |
public static Vue getVue(Corpus corpus) {
|
| 131 |
for (MainCorpus mcorpus : corpora.keySet()) {
|
|
| 138 |
for (CorpusBuild mcorpus : corpora.keySet()) {
|
|
| 132 | 139 |
if (corpora.get(mcorpus) == corpus) return vues.get(mcorpus); |
| 133 | 140 |
} |
| 134 | 141 |
return null; |
| 135 | 142 |
} |
| 136 | 143 |
|
| 137 | 144 |
public static boolean saveCorpus(Corpus corpus) {
|
| 138 |
for (MainCorpus mcorpus : corpora.keySet()) {
|
|
| 145 |
for (CorpusBuild mcorpus : corpora.keySet()) {
|
|
| 139 | 146 |
if (corpora.get(mcorpus) == corpus) return saveCorpus(mcorpus); |
| 140 | 147 |
} |
| 141 | 148 |
return false; |
| 142 | 149 |
} |
| 143 | 150 |
|
| 144 |
public static void removeCorpus(MainCorpus mcorpus) {
|
|
| 151 |
public static void removeCorpus(CorpusBuild mcorpus) {
|
|
| 152 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 153 |
|
|
| 145 | 154 |
if (!vues.containsKey(mcorpus)) {vues.remove(mcorpus);}
|
| 146 | 155 |
if (!corpora.containsKey(mcorpus)) {corpora.remove(mcorpus);}
|
| 147 | 156 |
} |
| 148 | 157 |
|
| 149 |
public static void revert(MainCorpus corpus) {
|
|
| 150 |
corpora.remove(corpus); |
|
| 151 |
vues.remove(corpus); |
|
| 152 |
corpus.setIsModified(false); |
|
| 158 |
public static void revert(CorpusBuild mcorpus) {
|
|
| 159 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 160 |
corpora.remove(mcorpus); |
|
| 161 |
vues.remove(mcorpus); |
|
| 162 |
mcorpus.setIsModified(false); |
|
| 153 | 163 |
} |
| 154 | 164 |
|
| 155 | 165 |
@Override |
| ... | ... | |
| 174 | 184 |
|
| 175 | 185 |
@Override |
| 176 | 186 |
public void notify(TXMResult r, String state) {
|
| 177 |
if (r instanceof MainCorpus && "clean".equals(state)) {
|
|
| 178 |
MainCorpus mcorpus = (MainCorpus)r; |
|
| 179 |
|
|
| 187 |
if (r instanceof CorpusBuild && "clean".equals(state)) { // $NON-NLS
|
|
| 188 |
CorpusBuild mcorpus = (CorpusBuild)r; |
|
| 189 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
|
| 190 |
|
|
| 180 | 191 |
URSCorpora.removeCorpus(mcorpus); |
| 181 | 192 |
|
| 182 | 193 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ec"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 183 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ecv"); |
|
| 194 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/"+mcorpus.getID()+".ecv"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 184 | 195 |
fichierCorpus.delete(); |
| 185 | 196 |
fichierVue.delete(); |
| 186 | 197 |
} else if (r instanceof Project) {
|
| ... | ... | |
| 191 | 202 |
DeleteDir.deleteDirectory(analecDir); |
| 192 | 203 |
} |
| 193 | 204 |
} else if ("save".equals(state)) {
|
| 194 |
for (TXMResult c : project.getChildren(MainCorpus.class)) {
|
|
| 195 |
URSCorpora.saveCorpus((MainCorpus)c);
|
|
| 205 |
for (TXMResult c : project.getChildren(CorpusBuild.class)) {
|
|
| 206 |
URSCorpora.saveCorpus((CorpusBuild)c);
|
|
| 196 | 207 |
} |
| 197 | 208 |
} |
| 198 | 209 |
} |
| tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java (revision 1969) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 | 4 |
import java.util.ArrayList; |
| 5 |
import java.util.List; |
|
| 5 | 6 |
|
| 6 | 7 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 7 | 8 |
import org.txm.core.results.TXMResult; |
| 8 | 9 |
import org.txm.function.tigersearch.TIGERSearch; |
Formats disponibles : Unified diff