Author: pkluegl
Date: Fri Jul 27 11:49:32 2012
New Revision: 1366343

URL: http://svn.apache.org/viewvc?rev=1366343&view=rev
Log:
UIMA-2438
- added argument to regexp condition in order to evaluate given pattern on the 
variable value instead of the matched text
- extended grammars
- updated documentation

Modified:
    uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/   (props changed)
    
uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/src/docbook/tools.textmarker.conditions.xml
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
    
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g
    
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java

Propchange: uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 27 11:49:32 2012
@@ -0,0 +1,2 @@
+target
+.settings

Modified: 
uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/src/docbook/tools.textmarker.conditions.xml
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/src/docbook/tools.textmarker.conditions.xml?rev=1366343&r1=1366342&r2=1366343&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/src/docbook/tools.textmarker.conditions.xml
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uima-docbook-textmarker/src/docbook/tools.textmarker.conditions.xml
 Fri Jul 27 11:49:32 2012
@@ -726,8 +726,11 @@
                <title>REGEXP</title>
                <para>
                        The REGEXP condition is fulfilled if the given pattern 
matches on the
-                       matched annotation. For more details on the syntax of 
regular
-                       expressions, have a look at the
+                       matched annotation. However, if a string variable is 
given as the first
+      argument, then the pattern is evaluated on the value of the variable.
+      For more details on the syntax of regular
+      expressions, have a look at
+      the
                        <ulink
                                
url="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html";>Java
 API</ulink>
                        . By default the REGEXP condition is case-sensitive. To 
change this
@@ -738,7 +741,7 @@
                                <emphasis role="bold">Definition:</emphasis>
                        </title>
                        <para>
-                               
<programlisting><![CDATA[REGEXP(StringExpression(,BooleanExpression)?)]]></programlisting>
+                               
<programlisting><![CDATA[REGEXP((StringVariable,)? 
StringExpression(,BooleanExpression)?)]]></programlisting>
                        </para>
                </section>
                <section>

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g?rev=1366343&r1=1366342&r2=1366343&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
 Fri Jul 27 11:49:32 2012
@@ -1060,8 +1060,8 @@ conditionPosition returns [TextMarkerCon
     ;
 conditionRegExp returns [TextMarkerCondition cond = null]
     :
-    name = REGEXP LPAREN pattern = stringExpression (COMMA caseSensitive = 
booleanExpression)? 
-    {cond = ConditionFactory.createCondition(name, pattern, caseSensitive);}   
+    name = REGEXP LPAREN (v = variable COMMA)? pattern = stringExpression 
(COMMA caseSensitive = booleanExpression)? 
+    {cond = ConditionFactory.createCondition(name, v, pattern, 
caseSensitive);}   
     RPAREN 
     ;
     

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=1366343&r1=1366342&r2=1366343&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 Jul 27 11:49:32 2012
@@ -1005,8 +1005,8 @@ conditionPosition returns [AbstractTextM
     ;
 conditionRegExp returns [AbstractTextMarkerCondition cond = null]
     :
-    REGEXP LPAREN pattern = stringExpression (COMMA caseSensitive = 
booleanExpression)? RPAREN
-    {cond = ConditionFactory.createConditionRegExp(pattern, caseSensitive, 
$blockDeclaration::env);}    
+    REGEXP LPAREN (v = variable COMMA)? pattern = stringExpression (COMMA 
caseSensitive = booleanExpression)? RPAREN
+    {cond = ConditionFactory.createConditionRegExp(v, pattern, caseSensitive, 
$blockDeclaration::env);}    
     ;
 
 conditionScore returns [AbstractTextMarkerCondition cond = null]

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java?rev=1366343&r1=1366342&r2=1366343&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/condition/ConditionFactory.java
 Fri Jul 27 11:49:32 2012
@@ -131,6 +131,11 @@ public class ConditionFactory {
     return new RegExpCondition(patternExpr, ignoreCase);
   }
 
+  public static AbstractTextMarkerCondition createConditionRegExp(Token var, 
StringExpression patternExpr,
+          BooleanExpression ignoreCase, TextMarkerBlock parent) {
+    return new RegExpCondition(var == null ? null : var.getText(), 
patternExpr, ignoreCase);
+  }
+  
   public static AbstractTextMarkerCondition 
createConditionScore(NumberExpression min,
           NumberExpression max, Token var, TextMarkerBlock parent) {
     String varString = null;


Reply via email to