Modified: uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/wien/Wien.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/wien/Wien.java?rev=1869491&r1=1869490&r2=1869491&view=diff ============================================================================== --- uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/wien/Wien.java (original) +++ uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/wien/Wien.java Thu Nov 7 08:27:02 2019 @@ -100,8 +100,8 @@ public class Wien extends TextRulerBasic TextRulerLearnerState.ML_RUNNING, false); if (!findRightPatterns()) allOk = false; - sendStatusUpdateToDelegate("Searching for left patterns...", - TextRulerLearnerState.ML_RUNNING, false); + sendStatusUpdateToDelegate("Searching for left patterns...", TextRulerLearnerState.ML_RUNNING, + false); if (!findLeftPatterns()) allOk = false; sendStatusUpdateToDelegate("Searching for head, tail and left1 patterns...", @@ -181,7 +181,6 @@ public class Wien extends TextRulerBasic boolean allFound = true; for (int k = 0; k < slotNames.length; k++) { List<TextRulerRulePattern> rightContexts = getRightContextForSlot(doc, k); - System.out.println(rightContexts.get(0)); int shortest = Integer.MAX_VALUE; for (TextRulerRulePattern p : rightContexts) shortest = p.size() < shortest ? p.size() : shortest; @@ -386,13 +385,13 @@ public class Wien extends TextRulerBasic } else { CAS cas = doc.getCAS(); TextRulerExample firstExample = doc.getPositiveExamples().get(0); - TextRulerExample lastExample = doc.getPositiveExamples().get( - doc.getPositiveExamples().size() - 1); + TextRulerExample lastExample = doc.getPositiveExamples() + .get(doc.getPositiveExamples().size() - 1); TypeSystem ts = cas.getTypeSystem(); Type tokenType = ts.getType(TextRulerToolkit.RUTA_ALL_TYPE_NAME); List<AnnotationFS> headTokens = TextRulerToolkit.getAnnotationsBeforePosition(cas, - firstExample.getAnnotations()[0].getBegin(), 0, TextRulerToolkit - .getFilterSetWithSlotNames(slotNames, filterSet), tokenType); + firstExample.getAnnotations()[0].getBegin(), 0, + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); TextRulerAnnotation[] lastExampleAnnotations = lastExample.getAnnotations(); List<AnnotationFS> tailTokens = TextRulerToolkit.getAnnotationsAfterPosition(cas, lastExampleAnnotations[lastExampleAnnotations.length - 1].getEnd(), 0, @@ -424,9 +423,9 @@ public class Wien extends TextRulerBasic TextRulerAnnotation[] exampleAnnotations2 = examples.get(i + 1).getAnnotations(); TextRulerAnnotation lastOf1 = exampleAnnotations1[exampleAnnotations1.length - 1]; TextRulerAnnotation firstOf2 = exampleAnnotations2[0]; - List<AnnotationFS> theTokens = TextRulerToolkit.getAnnotationsWithinBounds(cas, lastOf1 - .getEnd(), firstOf2.getBegin(), TextRulerToolkit.getFilterSetWithSlotNames( - slotNames, filterSet), tokenType); + List<AnnotationFS> theTokens = TextRulerToolkit.getAnnotationsWithinBounds(cas, + lastOf1.getEnd(), firstOf2.getBegin(), + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); TextRulerRulePattern thePattern = new TextRulerRulePattern(); for (AnnotationFS afs : theTokens) thePattern.add(new WienRuleItem(new TextRulerAnnotation(afs, doc))); @@ -470,8 +469,8 @@ public class Wien extends TextRulerBasic TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); else theTokens = TextRulerToolkit.getAnnotationsWithinBounds(cas, slotAnnotation.getEnd(), - nextSlotAnnotation.getBegin(), TextRulerToolkit.getFilterSetWithSlotNames( - slotNames, filterSet), tokenType); + nextSlotAnnotation.getBegin(), + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); TextRulerRulePattern thePattern = new TextRulerRulePattern(); for (AnnotationFS afs : theTokens) thePattern.add(new WienRuleItem(new TextRulerAnnotation(afs, doc))); @@ -510,12 +509,12 @@ public class Wien extends TextRulerBasic List<AnnotationFS> theTokens; if (prevSlotAnnotation == null) - theTokens = TextRulerToolkit.getAnnotationsBeforePosition(cas, slotAnnotation.getBegin(), - 0, TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); + theTokens = TextRulerToolkit.getAnnotationsBeforePosition(cas, slotAnnotation.getBegin(), 0, + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); else theTokens = TextRulerToolkit.getAnnotationsWithinBounds(cas, prevSlotAnnotation.getEnd(), - slotAnnotation.getBegin(), TextRulerToolkit.getFilterSetWithSlotNames(slotNames, - filterSet), tokenType); + slotAnnotation.getBegin(), + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); TextRulerRulePattern thePattern = new TextRulerRulePattern(); for (AnnotationFS afs : theTokens) thePattern.add(new WienRuleItem(new TextRulerAnnotation(afs, doc), true)); @@ -535,8 +534,8 @@ public class Wien extends TextRulerBasic for (TextRulerExample e : examples) { TextRulerAnnotation slotAnnotation = e.getAnnotations()[slotIndex]; List<AnnotationFS> theTokens = TextRulerToolkit.getAnnotationsWithinBounds(cas, - slotAnnotation.getBegin(), slotAnnotation.getEnd(), TextRulerToolkit - .getFilterSetWithSlotNames(slotNames, filterSet), tokenType); + slotAnnotation.getBegin(), slotAnnotation.getEnd(), + TextRulerToolkit.getFilterSetWithSlotNames(slotNames, filterSet), tokenType); TextRulerRulePattern thePattern = new TextRulerRulePattern(); for (AnnotationFS afs : theTokens) thePattern.add(new WienRuleItem(new TextRulerAnnotation(afs, doc))); @@ -620,8 +619,8 @@ public class Wien extends TextRulerBasic ((WienRuleItem) it).getWordConstraint().setGeneralizeLinkMarkUp(true); int l1Pos = restForL1.find(l1); if (l1Pos < 0 || l1Pos != restForL1.size() - l1.size()) { - TextRulerToolkit.logIf(logReasons, "REASON 1\n\tl1 \t" + l1 + "\n\trestforl1\t" - + restForL1); + TextRulerToolkit.logIf(logReasons, + "REASON 1\n\tl1 \t" + l1 + "\n\trestforl1\t" + restForL1); return constraint3ReturnType.C3_L1CandidateSuffixError; } @@ -690,6 +689,7 @@ public class Wien extends TextRulerBasic return constraint3ReturnType.C3_SUCCESS; } + @Override public String getResultString() { if (theRule == null) return "<no results yet>"; @@ -711,11 +711,8 @@ public class Wien extends TextRulerBasic result += ")};\n\n"; result += "BLOCK(findData) wien_content {\n" - + "\t// find out if tail is before the next occurence of l1\n" - + "\t" - + theRule.getRuleString() - + "\n" - + "\tDocument{->ASSIGN(wien_redo, false)};\n" + + "\t// find out if tail is before the next occurence of l1\n" + "\t" + + theRule.getRuleString() + "\n" + "\tDocument{->ASSIGN(wien_redo, false)};\n" + "\twien_tail{PARTOF(wien_rulemark)->UNMARK(wien_tail), ASSIGN(wien_redo, true)}; // remove tail marks that are no longer relevant for us after the last rule !\n" + "\tDocument{IF(wien_redo)->CALL(filename.findData)};\n" + "}\n"; @@ -725,6 +722,7 @@ public class Wien extends TextRulerBasic return result; } + @Override public void setParameters(Map<String, Object> params) { }
Modified: uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerView.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerView.java?rev=1869491&r1=1869490&r2=1869491&view=diff ============================================================================== --- uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerView.java (original) +++ uima/ruta/trunk/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/ui/TextRulerView.java Thu Nov 7 08:27:02 2019 @@ -60,7 +60,8 @@ public class TextRulerView extends ViewP } public boolean yesNoAlert(String message) { - MessageBox alert = new MessageBox(getSite().getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); + MessageBox alert = new MessageBox(getSite().getShell(), + SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); alert.setMessage(message); int result = alert.open(); return result == SWT.OK; // THIS DOES NOT WORK IN OS X !!?? @@ -104,16 +105,14 @@ public class TextRulerView extends ViewP } String[] slotNames = viewContent.getSlotNames(); - for (String string : slotNames) { - System.out.println(string); - } String[] filterArray = viewContent.getFilters(); Set<String> filters = new HashSet<String>(); for (String s : filterArray) filters.add(s); if (slotNames.length == 0 || inputDir.length() == 0 || preProcTMFile.length() == 0) { - errorAlert("Please specify at least one slot type, the input directory and the preprocessing file (this is needed even if preprocessing is skipped)!"); + errorAlert( + "Please specify at least one slot type, the input directory and the preprocessing file (this is needed even if preprocessing is skipped)!"); return; } File dir = new File(inputDir); @@ -138,10 +137,7 @@ public class TextRulerView extends ViewP if ((resultView = getView(TextRulerResultsView.ID, c.getID())) == null) { try { - IViewPart view = PlatformUI - .getWorkbench() - .getActiveWorkbenchWindow() - .getActivePage() + IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(TextRulerResultsView.ID, ((TextRulerLearnerController) i).getID(), IWorkbenchPage.VIEW_CREATE); ((TextRulerResultsView) view).setViewTitle(c.getName() + " - Results"); @@ -152,7 +148,7 @@ public class TextRulerView extends ViewP ((TextRulerResultsView) resultView).setViewTitle(c.getName() + " - Results"); } } - + if (TextRulerController.enabledAlgorithmsCount() > 0) { // GlobalCASSource.releaseAll(); TextRulerController.start(inputDir, additionalDir, preProcTMFile, slotNames, filters, this, @@ -169,6 +165,7 @@ public class TextRulerView extends ViewP public void asyncUpdateGlobalStatus(final String str) { viewContent.getDisplay().asyncExec(new Runnable() { + @Override public void run() { viewContent.setGlobalStatusString(str); updateEnabledStatus(); @@ -179,6 +176,7 @@ public class TextRulerView extends ViewP public void asyncUpdateList(final TextRulerLearnerController algController, final boolean ruleBaseChanged) { viewContent.getDisplay().asyncExec(new Runnable() { + @Override public void run() { updateList(algController, ruleBaseChanged); } @@ -196,6 +194,7 @@ public class TextRulerView extends ViewP } } + @Override public synchronized void algorithmDidEnd(TextRulerLearnerController algController) { asyncUpdateList(algController, true); @@ -222,15 +221,18 @@ public class TextRulerView extends ViewP return null; } + @Override public synchronized void algorithmStatusUpdate(TextRulerLearnerController algController, String statusString, TextRulerLearnerState state, boolean ruleBaseChanged) { asyncUpdateList(algController, ruleBaseChanged); } + @Override public void preprocessorStatusUpdate(TextRulerPreprocessor p, String statusString) { asyncUpdateGlobalStatus("Preprocessing... " + statusString); } + @Override public void globalStatusUpdate(String str) { asyncUpdateGlobalStatus(str); }
