You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2012/11/09 15:21:47 UTC
svn commit: r1407465 [3/3] - in /uima/sandbox/trunk/TextMarker:
uima-docbook-textmarker/src/docbook/language/
uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/
uimaj-ep-textmarker-ide/src/main/resources/org/apache/uima...
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g?rev=1407465&r1=1407464&r2=1407465&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g Fri Nov 9 14:21:46 2012
@@ -1429,9 +1429,28 @@ actionDynamicAnchoring returns [Abstract
actionUnmark returns [AbstractTextMarkerAction action = null]
+@init {
+List<NumberExpression> list = new ArrayList<NumberExpression>();
+}
:
- name = UNMARK LPAREN f = typeExpression RPAREN
- {action = ActionFactory.createUnmarkAction(f,$blockDeclaration::env);}
+ name = UNMARK LPAREN
+
+ f = typeExpression
+
+ (COMMA
+ (
+ (b = booleanExpression)=> b = booleanExpression
+ |
+ (
+ index = numberExpression {list.add(index);}
+ (COMMA index = numberExpression {list.add(index);})*
+ )
+ )
+
+ )?
+
+ RPAREN
+ {action = ActionFactory.createUnmarkAction(f, list, b,$blockDeclaration::env);}
;
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java?rev=1407465&r1=1407464&r2=1407465&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java Fri Nov 9 14:21:46 2012
@@ -143,8 +143,8 @@ public class ActionFactory {
return null;
}
- public static AbstractTextMarkerAction createUnmarkAction(TypeExpression f, TextMarkerBlock env) {
- return new UnmarkAction(f);
+ public static AbstractTextMarkerAction createUnmarkAction(TypeExpression f, List<NumberExpression> list, BooleanExpression b, TextMarkerBlock env) {
+ return new UnmarkAction(f, list, b);
}
public static AbstractTextMarkerAction createUnmarkAllAction(TypeExpression f,
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java?rev=1407465&r1=1407464&r2=1407465&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java Fri Nov 9 14:21:46 2012
@@ -26,6 +26,8 @@ import java.util.Set;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
import org.apache.uima.textmarker.expression.type.TypeExpression;
import org.apache.uima.textmarker.rule.RuleElement;
import org.apache.uima.textmarker.rule.RuleMatch;
@@ -34,21 +36,33 @@ import org.apache.uima.textmarker.visito
public class UnmarkAction extends TypeSensitiveAction {
- public UnmarkAction(TypeExpression type) {
+ private List<NumberExpression> list;
+
+ private BooleanExpression allAnchor;
+
+ public UnmarkAction(TypeExpression type, List<NumberExpression> list, BooleanExpression b) {
super(type);
+ this.list = list;
+ this.allAnchor = b;
}
@Override
public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
InferenceCrowd crowd) {
- List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element, stream);
Type t = type.getType(element.getParent());
- for (AnnotationFS annotationFS : matchedAnnotationsOf) {
+ boolean allAtAnchor = false;
+ if (allAnchor != null) {
+ allAtAnchor = allAnchor.getBooleanValue(element.getParent());
+ }
+ List<Integer> indexList = getIndexList(element, list);
+ List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, indexList,
+ element.getContainer());
+ for (AnnotationFS annotationFS : matchedAnnotations) {
TextMarkerBasic beginAnchor = stream.getBeginAnchor(annotationFS.getBegin());
Set<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
if (beginAnchors != null) {
for (AnnotationFS each : new ArrayList<AnnotationFS>(beginAnchors)) {
- if (each.getEnd() == annotationFS.getEnd()) {
+ if (allAtAnchor || each.getEnd() == annotationFS.getEnd()) {
stream.removeAnnotation(each, t);
}
}
@@ -57,4 +71,29 @@ public class UnmarkAction extends TypeSe
}
+ public List<NumberExpression> getList() {
+ return list;
+ }
+
+ public BooleanExpression getAllAnchor() {
+ return allAnchor;
+ }
+
+ protected List<Integer> getIndexList(RuleElement element, List<NumberExpression> list) {
+ List<Integer> indexList = new ArrayList<Integer>();
+ if (list == null || list.isEmpty()) {
+ int self = element.getContainer().getRuleElements().indexOf(element) + 1;
+ indexList.add(self);
+ return indexList;
+ }
+ int last = Integer.MAX_VALUE - 1;
+ for (NumberExpression each : list) {
+ int value = each.getIntegerValue(element.getParent());
+ for (int i = Math.min(value, last + 1); i < value; i++) {
+ indexList.add(i);
+ }
+ indexList.add(value);
+ }
+ return indexList;
+ }
}
Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/verbalize/ActionVerbalizer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/verbalize/ActionVerbalizer.java?rev=1407465&r1=1407464&r2=1407465&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/verbalize/ActionVerbalizer.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/verbalize/ActionVerbalizer.java Fri Nov 9 14:21:46 2012
@@ -289,7 +289,17 @@ public class ActionVerbalizer {
+ ")";
} else if (action instanceof UnmarkAction) {
UnmarkAction a = (UnmarkAction) action;
- return "UNMARK(" + verbalizer.verbalize(a.getType()) + ")";
+ if (a.getAllAnchor() == null) {
+ if (a.getList() == null) {
+ return "UNMARK(" + verbalizer.verbalize(a.getType()) + ")";
+ } else {
+ return "UNMARK(" + verbalizer.verbalize(a.getType()) + ","
+ + verbalizer.verbalizeExpressionList(a.getList()) + ")";
+ }
+ } else {
+ return "UNMARK(" + verbalizer.verbalize(a.getType()) + ","
+ + verbalizer.verbalize(a.getAllAnchor()) + ")";
+ }
} else if (action instanceof TransferAction) {
TransferAction a = (TransferAction) action;
return "TRANSFER(" + verbalizer.verbalize(a.getType()) + ")";