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/12/16 17:29:42 UTC

svn commit: r1422622 [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/java/org/apache/uima/text...

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.g
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.g?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.g (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.g Sun Dec 16 16:29:40 2012
@@ -248,6 +248,10 @@ DYNAMICANCHORING 	
 	:	'DYNAMICANCHORING'	 
 	;
 
+TRIM
+  : 'TRIM'
+  ;
+
 BEFORE
 	:	'BEFORE'
 	;

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.tokens
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.tokens?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.tokens (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerLexer.tokens Sun Dec 16 16:29:40 2012
@@ -1,151 +1,152 @@
-ACTION=4
-ADD=5
-AFTER=6
-ALT_NOTEQUAL=7
-AMPER=8
-AND=9
-ASSIGN=10
-ASSIGN_EQUAL=11
-AT=12
-ATTRIBUTE=13
-Annotation=14
-AutomataBlockString=15
-BEFORE=16
-BOOLEANLIST=17
-BasicAnnotationType=18
-BlockString=19
-BooleanString=20
-CALL=21
-CIRCUMFLEX=22
-CLEAR=23
-COLON=24
-COLOR=25
-COMMA=26
-COMMENT=27
-CONDITION=28
-CONFIGURE=29
-CONTAINS=30
-CONTEXTCOUNT=31
-COS=32
-COUNT=33
-CREATE=34
-CURRENTCOUNT=35
-CharacterLiteral=36
-DECLARE=37
-DEL=38
-DOT=39
-DOUBLELIST=40
-DYNAMICANCHORING=41
-DecimalLiteral=42
-DocComment=43
-DoubleString=44
-ENDSWITH=45
-EQUAL=46
-EXEC=47
-EXP=48
-EngineString=49
-EscapeSequence=50
-Exponent=51
-FALSE=52
-FEATURE=53
-FILL=54
-FILTERTYPE=55
-FLOATLIST=56
-FloatString=57
-FloatTypeSuffix=58
-FloatingPointLiteral=59
-GATHER=60
-GET=61
-GETFEATURE=62
-GETLIST=63
-GREATER=64
-GREATEREQUAL=65
-HexDigit=66
-HexLiteral=67
-IF=68
-INLIST=69
-INTLIST=70
-IS=71
-Identifier=72
-IntString=73
-IntegerTypeSuffix=74
-JavaIDDigit=75
-LAST=76
-LBRACK=77
-LCURLY=78
-LESS=79
-LESSEQUAL=80
-LINE_COMMENT=81
-LOG=82
-LOGN=83
-LPAREN=84
-Letter=85
-ListIdentifier=86
-LogLevel=87
-MARK=88
-MARKFAST=89
-MARKLAST=90
-MARKONCE=91
-MARKSCORE=92
-MARKTABLE=93
-MATCHEDTEXT=94
-MERGE=95
-MINUS=96
-MOFN=97
-NEAR=98
-NOT=99
-NOTEQUAL=100
-OR=101
-OctalEscape=102
-OctalLiteral=103
-OldColor=104
-PARSE=105
-PARTOF=106
-PARTOFNEQ=107
-PERCENT=108
-PLUS=109
-POSITION=110
-PackageString=111
-QUESTION=112
-RBRACK=113
-RCURLY=114
-REGEXP=115
-REMOVE=116
-REMOVEDUPLICATE=117
-REMOVESTRING=118
-REPLACE=119
-RETAINTYPE=120
-RPAREN=121
-RessourceLiteral=122
-SCORE=123
-SEMI=124
-SETFEATURE=125
-SHIFT=126
-SIN=127
-SIZE=128
-SLASH=129
-STAR=130
-STARTSWITH=131
-STRINGLIST=132
-ScriptString=133
-StringLiteral=134
-StringString=135
-SymbolString=136
-TAN=137
-THEN=138
-TOTALCOUNT=139
-TRANSFER=140
-TRIE=141
-TRUE=142
-TYPELIST=143
-TypeString=144
-TypeSystemString=145
-UNMARK=146
-UNMARKALL=147
-UnicodeEscape=148
-VBAR=149
-VOTE=150
-WORDLIST=151
-WORDTABLE=152
+STAR=139
+FloatTypeSuffix=114
+OctalLiteral=112
+LOG=37
+CONTAINS=8
+REMOVE=66
+GREATEREQUAL=152
+MARKFAST=41
+CONDITION=92
+MATCHEDTEXT=72
+COUNT=14
+LOGN=101
+DYNAMICANCHORING=57
+NOT=64
+Identifier=124
+ACTION=93
+NOTEQUAL=149
+CLEAR=74
+VBAR=141
+DOUBLELIST=96
+ENDSWITH=63
+RPAREN=126
+CREATE=31
+GREATER=144
+SIN=102
+EXP=100
+CURRENTCOUNT=16
+COS=103
+TAN=104
+TYPELIST=99
+FloatString=87
+LESS=143
+REGEXP=25
+GET=69
+PARTOF=22
+UNMARK=53
+LAST=18
+COMMENT=154
+REMOVEDUPLICATE=67
+UNMARKALL=54
+RBRACK=128
+NEAR=20
+LINE_COMMENT=155
+IntegerTypeSuffix=109
+MARKSCORE=39
+REMOVESTRING=73
+TRANSFER=55
+LCURLY=129
+TRIE=7
+FILTERTYPE=46
+STRINGLIST=98
+MARKONCE=40
+ScriptString=80
+EngineString=81
 WS=153
-XOR=154
+WORDTABLE=11
+WORDLIST=10
+AutomataBlockString=83
+FloatingPointLiteral=115
+INTLIST=95
+OR=21
+TRIM=58
+JavaIDDigit=123
+FLOATLIST=97
+CALL=47
+Annotation=5
+FALSE=107
+LESSEQUAL=151
+RessourceLiteral=119
+VOTE=27
+Letter=122
+EscapeSequence=116
+SIZE=71
+BasicAnnotationType=76
+LBRACK=127
+CharacterLiteral=117
+DEL=36
+ATTRIBUTE=34
+TypeString=84
+SHIFT=56
+Exponent=113
+ASSIGN_EQUAL=145
+RETAINTYPE=45
+AND=12
+TypeSystemString=90
+BlockString=82
+IntString=85
+HexDigit=108
+COLOR=35
+LPAREN=125
+POSITION=24
+IF=28
+AT=132
+LogLevel=77
+CONFIGURE=49
+SLASH=140
+THEN=75
+FILL=33
+COMMA=135
+IS=61
+AMPER=142
+REPLACE=44
+GETLIST=70
+EQUAL=148
+GATHER=32
+INLIST=17
+PLUS=137
+BooleanString=89
+GETFEATURE=52
+DOT=133
+ListIdentifier=6
+PARTOFNEQ=23
+BOOLEANLIST=94
+ADD=65
+MARKTABLE=42
+HexLiteral=110
+XOR=105
+PERCENT=146
+MARK=38
+PARSE=30
+PackageString=79
+OldColor=78
+MARKLAST=43
+MERGE=68
+CONTEXTCOUNT=13
+BEFORE=59
+EXEC=48
+MINUS=138
+AFTER=60
+DecimalLiteral=111
+SEMI=136
+TRUE=106
+FEATURE=29
+SymbolString=91
+COLON=134
+StringLiteral=118
+StringString=88
+SCORE=26
+QUESTION=147
+UnicodeEscape=120
+RCURLY=130
+STARTSWITH=62
+ASSIGN=50
+TOTALCOUNT=15
+DECLARE=9
+DocComment=4
+MOFN=19
+OctalEscape=121
+SETFEATURE=51
+DoubleString=86
+CIRCUMFLEX=131
+ALT_NOTEQUAL=150

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=1422622&r1=1422621&r2=1422622&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 Sun Dec 16 16:29:40 2012
@@ -1114,7 +1114,8 @@ action  returns [AbstractTextMarkerActio
 	| a = actionClear
 	| a = actionShift
 	| a = actionConfigure
-	| a = actionDynamicAnchoring 
+	| a = actionDynamicAnchoring
+	| a = actionTrim 
 	| (a = externalAction)=> a = externalAction
 //	| a = variableAction
 	) {result = a;}
@@ -1427,6 +1428,23 @@ actionDynamicAnchoring returns [Abstract
     RPAREN
     ;
 
+actionTrim returns [AbstractTextMarkerAction action = null]
+@init {
+  List<TypeExpression> types = new ArrayList<TypeExpression>();
+}
+    :
+    name = TRIM LPAREN 
+    (
+    typeList = typeListExpression
+    |
+    t1 = typeExpression {types.add(t1);} (COMMA t2 = typeExpression {types.add(t2);})*
+    )
+    
+    {action = ActionFactory.createTrimAction(types, typeList, $blockDeclaration::env);}
+    RPAREN
+    ;
+
+
 
 actionUnmark returns [AbstractTextMarkerAction action = null]
 @init {

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java Sun Dec 16 16:29:40 2012
@@ -38,14 +38,8 @@ public abstract class AbstractMarkAction
     super(type);
   }
 
-  protected void createAnnotation(AnnotationFS matchedAnnotation, RuleElement element,
+  protected Annotation createAnnotation(AnnotationFS matchedAnnotation, RuleElement element,
           TextMarkerStream stream, RuleMatch match) {
-    TextMarkerBasic first = stream.getFirstBasicInWindow(matchedAnnotation);
-    createAnnotation(first, element, stream, matchedAnnotation, match);
-  }
-
-  protected Annotation createAnnotation(TextMarkerBasic anchor, RuleElement element,
-          TextMarkerStream stream, AnnotationFS matchedAnnotation, RuleMatch match) {
     Type t = type.getType(element.getParent());
     AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t,
             matchedAnnotation.getBegin(), matchedAnnotation.getEnd());

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=1422622&r1=1422621&r2=1422622&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 Sun Dec 16 16:29:40 2012
@@ -239,4 +239,9 @@ public class ActionFactory {
     return new DynamicAnchoringAction(active, penalty, factor);
   }
 
+  public static AbstractTextMarkerAction createTrimAction(List<TypeExpression> types,
+          TypeListExpression typeList, TextMarkerBlock env) {
+    return new TrimAction(types, typeList);
+  }
+
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java Sun Dec 16 16:29:40 2012
@@ -88,8 +88,7 @@ public class MarkFastAction extends Abst
                 ignoreLength.getIntegerValue(element.getParent()), null, 0,
                 ignoreWS.getBooleanValue(element.getParent()));
         for (AnnotationFS annotation : found) {
-          TextMarkerBasic anchor = windowStream.getFirstBasicInWindow(annotation);
-          createAnnotation(anchor, element, windowStream, annotation, match);
+          createAnnotation(annotation, element, windowStream, match);
         }
       }
     }

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java Sun Dec 16 16:29:40 2012
@@ -44,7 +44,7 @@ public class MarkLastAction extends Abst
       List<TextMarkerBasic> list = stream.getBasicsInWindow(matchedAnnotation);
       if (!list.isEmpty()) {
         TextMarkerBasic last = list.get(list.size() - 1);
-        createAnnotation(last, element, stream, last, match);
+        createAnnotation(last, element, stream, match);
       }
 
     }

Added: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TrimAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TrimAction.java?rev=1422622&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TrimAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/TrimAction.java Sun Dec 16 16:29:40 2012
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.textmarker.TextMarkerElement;
+import org.apache.uima.textmarker.TextMarkerStatement;
+import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.type.TextMarkerBasic;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class TrimAction extends AbstractTextMarkerAction {
+
+  private TypeListExpression typeList;
+
+  private List<TypeExpression> types;
+
+  public TrimAction(List<TypeExpression> types, TypeListExpression typeList) {
+    super();
+    this.types = types;
+    this.typeList = typeList;
+  }
+
+  @Override
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd) {
+    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element, stream);
+    List<Type> typesToTrim = getTypes(element.getParent());
+    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
+      trimAnnotation(annotationFS, typesToTrim, match, stream);
+    }
+  }
+
+  private void trimAnnotation(AnnotationFS annotation, List<Type> typesToTrim, RuleMatch match,
+          TextMarkerStream stream) {
+    int oldBegin = annotation.getBegin();
+    int oldEnd = annotation.getEnd();
+    int newBegin = oldBegin;
+    int newEnd = oldEnd;
+
+    TextMarkerBasic beginBasic = stream.getBeginAnchor(oldBegin);
+    while (isPartof(beginBasic, typesToTrim) && beginBasic.getBegin() < oldEnd) {
+      beginBasic = stream.getBasicNextTo(false, beginBasic);
+    }
+    newBegin = beginBasic.getBegin();
+
+    TextMarkerBasic endBasic = stream.getEndAnchor(oldEnd);
+    while (isPartof(endBasic, typesToTrim) && endBasic.getEnd() > newBegin) {
+      endBasic = stream.getBasicNextTo(true, endBasic);
+    }
+    newEnd = endBasic.getEnd();
+
+    if (oldBegin != newBegin || newEnd != oldEnd) {
+      stream.removeAnnotation(annotation);
+      if (annotation instanceof Annotation) {
+        Annotation a = (Annotation) annotation;
+        a.setBegin(newBegin);
+        a.setEnd(newEnd);
+      }
+      if (newBegin < newEnd) {
+        stream.addAnnotation(annotation, true, match);
+      }
+    }
+  }
+
+  private boolean isPartof(TextMarkerBasic basic, List<Type> typesToTrim) {
+    for (Type type : typesToTrim) {
+      boolean partOf = basic.isPartOf(type);
+      if (partOf) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private List<Type> getTypes(TextMarkerStatement parent) {
+    List<Type> result = new ArrayList<Type>();
+    if (types != null) {
+      for (TypeExpression each : types) {
+        result.add(each.getType(parent));
+      }
+    } else if (typeList != null) {
+      result = typeList.getList(parent);
+    }
+    return result;
+  }
+
+  public TypeListExpression getTypeList() {
+    return typeList;
+  }
+
+  public List<TypeExpression> getTypes() {
+    return types;
+  }
+
+}

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/AllActionsTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/AllActionsTest.java?rev=1422622&r1=1422621&r2=1422622&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/AllActionsTest.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/AllActionsTest.java Sun Dec 16 16:29:40 2012
@@ -20,12 +20,13 @@
 package org.apache.uima.textmarker;
 
 import org.apache.uima.textmarker.action.MarkFastTest;
+import org.apache.uima.textmarker.action.TrimTest;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
-@SuiteClasses({ MarkFastTest.class })
+@SuiteClasses({ MarkFastTest.class, TrimTest.class })
 public class AllActionsTest {
 
 }

Added: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/action/TrimTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/action/TrimTest.java?rev=1422622&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/action/TrimTest.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/java/org/apache/uima/textmarker/action/TrimTest.java Sun Dec 16 16:29:40 2012
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.action;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.textmarker.TextMarkerTestUtils;
+import org.junit.Test;
+
+public class TrimTest {
+
+  @Test
+  public void test() {
+    String name = this.getClass().getSimpleName();
+    String namespace = this.getClass().getPackage().getName().replaceAll("\\.", "/");
+    
+    CAS cas = null;
+    try {
+      cas = TextMarkerTestUtils.process(namespace + "/" + name + ".tm", namespace + "/" + name
+              + ".txt", 50);
+    } catch (Exception e) {
+      e.printStackTrace();
+      assert (false);
+    }
+    Type t = null;
+    AnnotationIndex<AnnotationFS> ai = null;
+    FSIterator<AnnotationFS> iterator = null;
+
+    t = TextMarkerTestUtils.getTestType(cas, 1);
+    ai = cas.getAnnotationIndex(t);
+    iterator = ai.iterator();
+    assertEquals(1, ai.size());
+    assertEquals("some text", iterator.next().getCoveredText());
+    
+    t = TextMarkerTestUtils.getTestType(cas, 2);
+    ai = cas.getAnnotationIndex(t);
+    iterator = ai.iterator();
+    assertEquals(1, ai.size());
+    assertEquals("some text", iterator.next().getCoveredText());
+    
+    t = TextMarkerTestUtils.getTestType(cas, 3);
+    ai = cas.getAnnotationIndex(t);
+    iterator = ai.iterator();
+    assertEquals(1, ai.size());
+    assertEquals("some text", iterator.next().getCoveredText());
+    
+  }
+}

Added: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.tm
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.tm?rev=1422622&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.tm (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.tm Sun Dec 16 16:29:40 2012
@@ -0,0 +1,10 @@
+PACKAGE org.apache.uima;
+
+DECLARE T1, T2, T3, T4, T5, T6, T7, T8;
+
+Document{ -> RETAINTYPE(SPACE, MARKUP)};
+SPACE ANY+{-PARTOF(T1) -> MARK(T1), MARK(T2), MARK(T3)};
+
+T1{-> TRIM(SPACE), TRIM(MARKUP)};
+T2{-> TRIM(SPACE, MARKUP)};
+T3{-> TRIM({SPACE, MARKUP})};
\ No newline at end of file

Added: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.txt
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.txt?rev=1422622&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.txt (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/test/resources/org/apache/uima/textmarker/action/TrimTest.txt Sun Dec 16 16:29:40 2012
@@ -0,0 +1 @@
+only some text<br/>
\ No newline at end of file