Author: pkluegl
Date: Fri Oct 21 13:29:24 2011
New Revision: 1187332

URL: http://svn.apache.org/viewvc?rev=1187332&view=rev
Log:
UIMA-2272
added new action DYNAMICACHORING

Added:
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DynamicAnchoringAction.java
Modified:
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.g
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.tokens
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.tokens
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywords.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.tokens

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java?rev=1187332&r1=1187331&r2=1187332&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
 Fri Oct 21 13:29:24 2011
@@ -72,6 +72,10 @@ public class TextMarkerStream extends FS
 
   private boolean dynamicAnchoring;
 
+  private double indexPenalty = 5;
+
+  private double anchoringFactor;
+
   protected TextMarkerStream(CAS cas, FSIterator<AnnotationFS> basic,
           FSIterator<AnnotationFS> current, Type basicType, FilterManager 
filter) {
     super();
@@ -584,7 +588,7 @@ public class TextMarkerStream extends FS
   }
 
   public double getIndexPenalty() {
-    return 2;
+    return indexPenalty;
   }
 
   public TextMarkerBasic getEndAnchor(int end) {
@@ -603,4 +607,16 @@ public class TextMarkerStream extends FS
     this.dynamicAnchoring = dynamicAnchoring;
   }
 
+  public void setIndexPenalty(double indexPenalty) {
+    this.indexPenalty = indexPenalty;
+  }
+
+  public double getAnchoringFactor() {
+    return anchoringFactor;
+  }
+
+  public void setAnchoringFactor(double anchoringFactor) {
+    this.anchoringFactor = anchoringFactor;
+  }
+
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java?rev=1187332&r1=1187331&r2=1187332&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
 Fri Oct 21 13:29:24 2011
@@ -234,4 +234,9 @@ public class ActionFactory {
     return new ExpandAction(type, list);
   }
 
+  public static AbstractTextMarkerAction 
createDynamicAnchoringAction(BooleanExpression active,
+          NumberExpression penalty, NumberExpression factor, TextMarkerBlock 
env) {
+    return new DynamicAnchoringAction(active, penalty, factor);
+  }
+
 }

Added: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DynamicAnchoringAction.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DynamicAnchoringAction.java?rev=1187332&view=auto
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DynamicAnchoringAction.java
 (added)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DynamicAnchoringAction.java
 Fri Oct 21 13:29:24 2011
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.uima.textmarker.TextMarkerBlock;
+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.rule.RuleElement;
+import org.apache.uima.textmarker.rule.RuleMatch;
+import org.apache.uima.textmarker.visitor.InferenceCrowd;
+
+public class DynamicAnchoringAction extends AbstractTextMarkerAction {
+
+  private final BooleanExpression active;
+
+  private final NumberExpression panelty;
+
+  private final NumberExpression factor;
+
+  public DynamicAnchoringAction(BooleanExpression active, NumberExpression 
panelty,
+          NumberExpression factor) {
+    super();
+    this.active = active;
+    this.panelty = panelty;
+    this.factor = factor;
+  }
+
+  @Override
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream 
stream,
+          InferenceCrowd crowd) {
+    TextMarkerBlock parent = element.getParent();
+    boolean activated = active.getBooleanValue(parent);
+    stream.setDynamicAnchoring(activated);
+    if (panelty != null) {
+      double p = panelty.getDoubleValue(parent);
+      stream.setIndexPenalty(p);
+    }
+    if (factor != null) {
+      double f = factor.getDoubleValue(parent);
+      stream.setAnchoringFactor(f);
+    }
+  }
+
+  public BooleanExpression getActive() {
+    return active;
+  }
+
+  public NumberExpression getPanelty() {
+    return panelty;
+  }
+
+  public NumberExpression getFactor() {
+    return factor;
+  }
+
+}

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.g
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.g?rev=1187332&r1=1187331&r2=1187332&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.g
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerLexer.g
 Fri Oct 21 13:29:24 2011
@@ -255,6 +255,10 @@ EXPAND     
        :       'EXPAND'         
        ;
 
+DYNAMICANCHORING       
+       :       'DYNAMICANCHORING'       
+       ;
+
 BEFORE
        :       'BEFORE'
        ;


Reply via email to