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 2013/12/09 10:54:23 UTC

svn commit: r1549527 - in /uima/ruta/trunk: ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/ ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/output/ ruta-core/src/main/java/org/apache/uima/ruta/ ruta-core/src/main/java/org/apache/uima/ruta/...

Author: pkluegl
Date: Mon Dec  9 09:54:23 2013
New Revision: 1549527

URL: http://svn.apache.org/r1549527
Log:
UIMA-2768
- added option for greedy rule anchoring
- had to change AE parameters

Added:
    uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/output/
    uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/output/
Modified:
    uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ActionFactory.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/verbalize/ActionVerbalizer.java
    uima/ruta/trunk/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/GreedyAnchoringTest.java
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.actions.xml
    uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g

Modified: uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g (original)
+++ uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g Mon Dec  9 09:54:23 2013
@@ -1647,8 +1647,8 @@ actionDynamicAnchoring returns [Abstract
 
 actionGreedyAnchoring returns [AbstractRutaAction action = null]
     :
-    name = GREEDYANCHORING LPAREN active = booleanExpression 
-    {action = ActionFactory.createGreedyAnchoringAction(active, $blockDeclaration::env);}
+    name = GREEDYANCHORING LPAREN active = booleanExpression (COMMA active2 = booleanExpression )?
+    {action = ActionFactory.createGreedyAnchoringAction(active, active2, $blockDeclaration::env);}
     RPAREN
     ;
 

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java Mon Dec  9 09:54:23 2013
@@ -80,7 +80,9 @@ public class RutaStream extends FSIterat
 
   private InferenceCrowd crowd;
 
-  private Boolean greedyAnchoring;
+  private Boolean greedyRuleElement;
+  
+  private Boolean greedyRule;
 
   protected RutaStream(CAS cas, FSIterator<AnnotationFS> current, Type basicType,
           FilterManager filter, boolean lowMemoryProfile, boolean simpleGreedyForComposed,
@@ -348,7 +350,8 @@ public class RutaStream extends FSIterat
     RutaStream stream = new RutaStream(cas, basicIt, basicType, filterManager, lowMemoryProfile,
             simpleGreedyForComposed, crowd);
     stream.setDynamicAnchoring(dynamicAnchoring);
-    stream.setGreedyAnchoring(greedyAnchoring);
+    stream.setGreedyRuleElement(greedyRuleElement);
+    stream.setGreedyRule(greedyRule);
     return stream;
   }
 
@@ -356,7 +359,8 @@ public class RutaStream extends FSIterat
     RutaStream stream = new RutaStream(cas, currentIt.copy(), basicType, filter, lowMemoryProfile,
             simpleGreedyForComposed, crowd);
     stream.setDynamicAnchoring(dynamicAnchoring);
-    stream.setGreedyAnchoring(greedyAnchoring);
+    stream.setGreedyRuleElement(greedyRuleElement);
+    stream.setGreedyRule(greedyRule);
     return stream;
   }
 
@@ -702,7 +706,8 @@ public class RutaStream extends FSIterat
     RutaStream stream = new RutaStream(getCas(), basicIt, basicType, defaultFilter, lowMemoryProfile,
             simpleGreedyForComposed, crowd);
     stream.setDynamicAnchoring(dynamicAnchoring);
-    stream.setGreedyAnchoring(greedyAnchoring);
+    stream.setGreedyRuleElement(greedyRuleElement);
+    stream.setGreedyRule(greedyRule);
     return stream;
   }
 
@@ -730,12 +735,20 @@ public class RutaStream extends FSIterat
     this.dynamicAnchoring = dynamicAnchoring;
   }
   
-  public boolean isGreedyAnchoring() {
-    return greedyAnchoring;
+  public boolean isGreedyRuleElement() {
+    return greedyRuleElement;
   }
   
-  public void setGreedyAnchoring(Boolean greedyAnchoring) {
-    this.greedyAnchoring = greedyAnchoring;
+  public void setGreedyRuleElement(Boolean greedyAnchoring) {
+    this.greedyRuleElement = greedyAnchoring;
+  }
+  
+  public boolean isGreedyRule() {
+    return greedyRule;
+  }
+  
+  public void setGreedyRule(Boolean greedyAnchoring) {
+    this.greedyRule = greedyAnchoring;
   }
   
   public void setIndexPenalty(double indexPenalty) {
@@ -785,6 +798,10 @@ public class RutaStream extends FSIterat
     }
   }
 
+  public boolean isGreedyAnchoring() {
+    return greedyRule || greedyRuleElement;
+  }
+
 
   
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ActionFactory.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ActionFactory.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ActionFactory.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ActionFactory.java Mon Dec  9 09:54:23 2013
@@ -274,8 +274,8 @@ public class ActionFactory {
   }
 
   public static AbstractRutaAction createGreedyAnchoringAction(IBooleanExpression active,
-          RutaBlock env) {
-    return new GreedyAnchoringAction(active);
+          IBooleanExpression active2, RutaBlock env) {
+    return new GreedyAnchoringAction(active, active2);
   }
 
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GreedyAnchoringAction.java Mon Dec  9 09:54:23 2013
@@ -22,29 +22,40 @@ package org.apache.uima.ruta.action;
 import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
+import org.apache.uima.ruta.expression.bool.SimpleBooleanExpression;
 import org.apache.uima.ruta.rule.RuleElement;
 import org.apache.uima.ruta.rule.RuleMatch;
 import org.apache.uima.ruta.visitor.InferenceCrowd;
 
 public class GreedyAnchoringAction extends AbstractRutaAction {
 
-  private final IBooleanExpression active;
+  private final IBooleanExpression greedyRuleElement;
 
-  public GreedyAnchoringAction(IBooleanExpression active) {
+  private final IBooleanExpression greedyRule;
+  
+  public GreedyAnchoringAction(IBooleanExpression active, IBooleanExpression active2) {
     super();
-    this.active = active;
+    this.greedyRuleElement = active;
+    this.greedyRule = active2 == null ? new SimpleBooleanExpression(false) : active2;
   }
 
   @Override
   public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
     RutaBlock parent = element.getParent();
-    boolean activated = active.getBooleanValue(parent, null, stream);
-    stream.setGreedyAnchoring(activated);
+    boolean greedy1 = greedyRuleElement.getBooleanValue(parent, match, element, stream);
+    boolean greedy2 = greedyRule.getBooleanValue(parent, match, element, stream);
+    stream.setGreedyRuleElement(greedy1);
+    stream.setGreedyRule(greedy2);
   }
 
-  public IBooleanExpression getActive() {
-    return active;
+  public IBooleanExpression getGreedyRuleElement() {
+    return greedyRuleElement;
   }
 
+  public IBooleanExpression getGreedyRule() {
+    return greedyRule;
+  }
+
+  
 
 }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java Mon Dec  9 09:54:23 2013
@@ -271,16 +271,24 @@ public class RutaEngine extends JCasAnno
   private Boolean simpleGreedyForComposed;
 
   /**
-   * If this parameter is set to true, then start positions already matched by the same rule will be ignored. This situation 
-   * occurs mostly for rules that start with a quantifier. The following rule, for example, matches only once, 
-   * if this parameter is set to true: {@code ANY+;}
+   * If this parameter is set to true, then start positions already matched by the same rule element will be
+   * ignored. This situation occurs mostly for rules that start with a quantifier. The following
+   * rule, for example, matches only once, if this parameter is set to true: {@code ANY+;}
    */
-  public static final String PARAM_GREEDY_ANCHORING = "greedyAnchoring";
+  public static final String PARAM_GREEDY_RULE_ELEMENT = "greedyRuleElement";
+
+  @ConfigurationParameter(name = PARAM_GREEDY_RULE_ELEMENT, mandatory = false, defaultValue = "false")
+  private Boolean greedyRuleElement = false;
+
+  /**
+   * If this parameter is set to true, then start positions already matched by the rule will be
+   * ignored and only positions not part of an match will be considered.
+   */
+  public static final String PARAM_GREEDY_RULE = "greedyRule";
+
+  @ConfigurationParameter(name = PARAM_GREEDY_RULE, mandatory = false, defaultValue = "false")
+  private Boolean greedyRule = false;
 
-  @ConfigurationParameter(name = PARAM_GREEDY_ANCHORING, mandatory = false, defaultValue = "false")
-  private Boolean greedyAnchoring = false;
-  
-  
   /**
    * If this parameter is set to true, then additional information about the execution of a rule
    * script is added to the CAS. The actual information is specified by the following parameters.
@@ -338,7 +346,8 @@ public class RutaEngine extends JCasAnno
   private Boolean createdBy;
 
   /**
-   * If this parameter is set to true, then only types in declared type systems are available by their short name.
+   * If this parameter is set to true, then only types in declared type systems are available by
+   * their short name.
    */
   public static final String PARAM_STRICT_IMPORTS = "strictImports";
 
@@ -398,8 +407,8 @@ public class RutaEngine extends JCasAnno
     lowMemoryProfile = (Boolean) aContext.getConfigParameterValue(PARAM_LOW_MEMORY_PROFILE);
     simpleGreedyForComposed = (Boolean) aContext
             .getConfigParameterValue(PARAM_SIMPLE_GREEDY_FOR_COMPOSED);
-    greedyAnchoring = (Boolean) aContext
-            .getConfigParameterValue(PARAM_GREEDY_ANCHORING);
+    greedyRuleElement = (Boolean) aContext.getConfigParameterValue(PARAM_GREEDY_RULE_ELEMENT);
+    greedyRule = (Boolean) aContext.getConfigParameterValue(PARAM_GREEDY_RULE);
 
     resourcePaths = resourcePaths == null ? new String[0] : resourcePaths;
     removeBasics = removeBasics == null ? false : removeBasics;
@@ -416,9 +425,9 @@ public class RutaEngine extends JCasAnno
     reloadScript = reloadScript == null ? false : reloadScript;
     lowMemoryProfile = lowMemoryProfile == null ? false : lowMemoryProfile;
     simpleGreedyForComposed = simpleGreedyForComposed == null ? false : simpleGreedyForComposed;
-    greedyAnchoring = greedyAnchoring == null ? false : greedyAnchoring;
+    greedyRuleElement = greedyRuleElement == null ? false : greedyRuleElement;
+    greedyRule = greedyRule == null ? false : greedyRule;
 
-    
     this.context = aContext;
 
     factory = new RutaExternalFactory();
@@ -458,7 +467,8 @@ public class RutaEngine extends JCasAnno
     InferenceCrowd crowd = initializeCrowd();
     RutaStream stream = initializeStream(cas, crowd);
     stream.setDynamicAnchoring(dynamicAnchoring);
-    stream.setGreedyAnchoring(greedyAnchoring);
+    stream.setGreedyRuleElement(greedyRuleElement);
+    stream.setGreedyRule(greedyRule);
     try {
       script.apply(stream, crowd);
     } catch (Throwable e) {
@@ -905,7 +915,7 @@ public class RutaEngine extends JCasAnno
   private RutaModule loadScriptIS(String scriptLocation) throws IOException, RecognitionException {
     InputStream scriptInputStream = getClass().getClassLoader().getResourceAsStream(scriptLocation);
     if (scriptInputStream == null) {
-            throw new FileNotFoundException("No script found in location [" + scriptLocation + "]");
+      throw new FileNotFoundException("No script found in location [" + scriptLocation + "]");
     }
     CharStream st = new ANTLRInputStream(scriptInputStream, scriptEncoding);
     RutaLexer lexer = new RutaLexer(st);
@@ -947,8 +957,7 @@ public class RutaEngine extends JCasAnno
   private String collectionToString(Object[] collection) {
     if (collection == null) {
       return "";
-    }
-    else {
+    } else {
       return collectionToString(Arrays.asList(collection));
     }
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java Mon Dec  9 09:54:23 2013
@@ -124,7 +124,12 @@ public class RutaRuleElement extends Abs
     for (AbstractRuleMatch<? extends AbstractRule> each : list) {
       if(each instanceof RuleMatch) {
         RuleMatch rm = (RuleMatch) each;
-        List<AnnotationFS> matchedAnnotationsOf = rm.getMatchedAnnotationsOf(this);
+        List<AnnotationFS> matchedAnnotationsOf = Collections.emptyList();
+        if(stream.isGreedyRule()) {
+          matchedAnnotationsOf = rm.getMatchedAnnotationsOfRoot();
+        } else if(stream.isGreedyRuleElement()) {
+          matchedAnnotationsOf = rm.getMatchedAnnotationsOf(this);
+        }
         for (AnnotationFS annotationFS : matchedAnnotationsOf) {
           if(eachAnchor.getBegin() >= annotationFS.getBegin() && eachAnchor.getEnd() <= annotationFS.getEnd())
           return true;

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/verbalize/ActionVerbalizer.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/verbalize/ActionVerbalizer.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/verbalize/ActionVerbalizer.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/verbalize/ActionVerbalizer.java Mon Dec  9 09:54:23 2013
@@ -427,9 +427,14 @@ public class ActionVerbalizer {
       return name + pa + pp + pf + ")";
     } else if (action instanceof GreedyAnchoringAction) {
       GreedyAnchoringAction a = (GreedyAnchoringAction) action;
-      IBooleanExpression active = a.getActive();
+      IBooleanExpression active = a.getGreedyRuleElement();
+      IBooleanExpression active2 = a.getGreedyRule();
       String pa = verbalizer.verbalize(active);
-      return name + pa + ")";
+      String pa2 = "";
+      if (active2 != null) {
+        pa2 = ", " + verbalizer.verbalize(active2);
+      }
+      return name + pa + pa2 + ")";
     } else if (action instanceof GetListAction) {
       GetListAction a = (GetListAction) action;
       String var = a.getVar();
@@ -484,9 +489,9 @@ public class ActionVerbalizer {
       TrimAction a = (TrimAction) action;
       TypeListExpression typeList = a.getTypeList();
       String verbalize = "";
-      if(typeList != null) {
+      if (typeList != null) {
         verbalize = verbalizer.verbalize(typeList);
-      } else if(a.getTypes() != null) {
+      } else if (a.getTypes() != null) {
         verbalize = verbalizer.verbalizeExpressionList(a.getTypes());
       }
       return name + verbalize + ")";

Modified: uima/ruta/trunk/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml (original)
+++ uima/ruta/trunk/ruta-core/src/main/resources/org/apache/uima/ruta/engine/BasicEngine.xml Mon Dec  9 09:54:23 2013
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+
 <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
@@ -17,7 +18,6 @@
   specific language governing permissions and limitations
   under the License.
 -->
-
 <analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
   <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
   <primitive>true</primitive>
@@ -138,8 +138,15 @@
         <mandatory>false</mandatory>
       </configurationParameter>
       <configurationParameter>
-        <name>greedyAnchoring</name>
-        <description>Activates greedy anchoring.</description>
+        <name>greedyRuleElement</name>
+        <description>Activates greedy anchoring for rule elements.</description>
+        <type>Boolean</type>
+        <multiValued>false</multiValued>
+        <mandatory>false</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>greedyRule</name>
+        <description>Activates greedy anchoring for complete rules.</description>
         <type>Boolean</type>
         <multiValued>false</multiValued>
         <mandatory>false</mandatory>

Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/GreedyAnchoringTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/GreedyAnchoringTest.java?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/GreedyAnchoringTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/GreedyAnchoringTest.java Mon Dec  9 09:54:23 2013
@@ -36,7 +36,7 @@ import org.junit.Test;
 public class GreedyAnchoringTest {
 
   @Test
-  public void test() {
+  public void testGreedyRuleElement() {
     String document = "Peter Kluegl, Joern Kottmann, Marshall Schor.";
     String script = "";
     script += "ANY+{->T1};";
@@ -44,7 +44,7 @@ public class GreedyAnchoringTest {
     
     CAS cas = null;
     Map<String, Object> params = new HashMap<String, Object>();
-    params.put(RutaEngine.PARAM_GREEDY_ANCHORING, true);
+    params.put(RutaEngine.PARAM_GREEDY_RULE_ELEMENT, true);
     try {
       cas = RutaTestUtils.getCAS(document);
       Ruta.apply(cas, script, params);
@@ -74,4 +74,39 @@ public class GreedyAnchoringTest {
     }
 
   }
+  
+  @Test
+  public void testGreedyRule() {
+    String document = "Peter Kluegl Joern Kottmann Marshall Schor.";
+    String script = "";
+    script += "(CW CW){->T1};";
+    
+    CAS cas = null;
+    Map<String, Object> params = new HashMap<String, Object>();
+    params.put(RutaEngine.PARAM_GREEDY_RULE, true);
+    try {
+      cas = RutaTestUtils.getCAS(document);
+      Ruta.apply(cas, script, params);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+    Type t = null;
+    AnnotationIndex<AnnotationFS> ai = null;
+    FSIterator<AnnotationFS> iterator = null;
+
+    t = RutaTestUtils.getTestType(cas, 1);
+    ai = cas.getAnnotationIndex(t);
+    assertEquals(3, ai.size());
+    iterator = ai.iterator();
+    assertEquals("Peter Kluegl", iterator.next().getCoveredText());
+    assertEquals("Joern Kottmann", iterator.next().getCoveredText());
+    assertEquals("Marshall Schor", iterator.next().getCoveredText());
+    
+    if (cas != null) {
+      cas.release();
+    }
+
+  }
+  
 }

Modified: uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.actions.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.actions.xml?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.actions.xml (original)
+++ uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.actions.xml Mon Dec  9 09:54:23 2013
@@ -663,16 +663,17 @@ A B{-> GATHER(C, 1, 2, "a" = 1, "b" = 2)
   <section id="ugr.tools.ruta.language.actions.greedyanchoring">
     <title>GREEDYANCHORING</title>
     <para>
-      The GREEDYANCHORING action turns greedy anchoring on or off
-      (first parameter). If this parameter is set to true, then start positions already matched by the same rule will be ignored. This situation 
-      occurs mostly for rules that start with a quantifier. 
+      The GREEDYANCHORING action turns greedy anchoring on or off. 
+      If the first parameter is set to true, then start positions already matched by the same rule element will be ignored. This situation 
+      occurs mostly for rules that start with a quantifier. The second optional parameter activates greedy acnhoring for the complete rule.
+      Later rule matches are only possible after previous matches.
     </para>
     <section>
       <title>
         <emphasis role="bold">Definition:</emphasis>
       </title>
       <para>
-        <programlisting><![CDATA[GREEDYANCHORING(BooleanExpression)]]></programlisting>
+        <programlisting><![CDATA[GREEDYANCHORING(BooleanExpression(,BooleanExpression)?)]]></programlisting>
       </para>
     </section>
     <section>
@@ -680,12 +681,14 @@ A B{-> GATHER(C, 1, 2, "a" = 1, "b" = 2)
         <emphasis role="bold">Example:</emphasis>
       </title>
       <para>
-        <programlisting><![CDATA[Document{->GREEDYANCHORING(true)};
-        ANY+;]]></programlisting>
+        <programlisting><![CDATA[Document{->GREEDYANCHORING(true, true)};
+        ANY+;
+        CW CW;]]></programlisting>
       </para>
       <para>
         The above mentioned example activates dynamic anchoring and the second rule will then only match once 
         since the next positions, e.g., the second token, are already covered by the first attempt.
+        The third rule will not match on capitalized word that have benn already considered by previous matches of the rule.
       </para>
     </section>
   </section>

Modified: uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g?rev=1549527&r1=1549526&r2=1549527&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/antlr3/org/apache/uima/ruta/ide/core/parser/RutaParser.g Mon Dec  9 09:54:23 2013
@@ -1759,8 +1759,10 @@ actionDynamicAnchoring returns [RutaActi
 
 actionGreedyAnchoring returns [RutaAction action = null]
     :
-    name = GREEDYANCHORING LPAREN active = booleanExpression 
-     {action = ActionFactory.createAction(name, active);}
+    name = GREEDYANCHORING 
+    {action = ActionFactory.createAction(name, active);}
+    LPAREN active = booleanExpression (COMMA active2 = booleanExpression)?
+     {action = ActionFactory.createAction(name, active, active2);}
     RPAREN
     ;