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 2015/10/30 18:03:26 UTC
svn commit: r1711508 - in /uima/ruta/branches/UIMA-4408/ruta-core/src/main:
antlr3/org/apache/uima/ruta/parser/ java/org/apache/uima/ruta/condition/
java/org/apache/uima/ruta/expression/
java/org/apache/uima/ruta/expression/annotation/
Author: pkluegl
Date: Fri Oct 30 17:03:26 2015
New Revision: 1711508
URL: http://svn.apache.org/viewvc?rev=1711508&view=rev
Log:
UIMA-4657
- adapted grammar for variables
Modified:
uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.g
uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.tokens
uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.tokens
uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/ExpressionFactory.java
uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java
uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.g
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.g?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.g (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.g Fri Oct 30 17:03:26 2015
@@ -364,6 +364,10 @@ STRINGLIST
: 'STRINGLIST';
TYPELIST: 'TYPELIST';
+ANNOTATION
+ : 'ANNOTATION';
+ANNOTATIONLIST
+ : 'ANNOTATIONLIST';
EXP : 'EXP';
@@ -377,6 +381,10 @@ TRUE : 'true';
FALSE : 'false';
NULL : 'null';
+
+ADDRESS_PREFIX
+ : '$';
+
STARTANCHOR
: '@';
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.tokens
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.tokens?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.tokens (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaLexer.tokens Fri Oct 30 17:03:26 2015
@@ -1,163 +1,168 @@
-STAR=149
-FloatTypeSuffix=125
-OctalLiteral=123
-LOG=37
-CONTAINS=8
-REMOVE=72
-GREATEREQUAL=162
-MARKFAST=41
-CONDITION=102
-MATCHEDTEXT=78
-COUNT=14
-LOGN=111
-DYNAMICANCHORING=58
-NOT=70
-Identifier=135
-ACTION=103
-NOTEQUAL=159
-CLEAR=80
-VBAR=151
-DOUBLELIST=106
-ENDSWITH=65
-RPAREN=137
-CREATE=31
-GREATER=154
-SIN=112
-EXP=110
-CURRENTCOUNT=16
-COS=113
-TAN=114
-TYPELIST=109
-FloatString=94
-LESS=153
-REGEXP=25
-GET=75
-PARTOF=22
-UNMARK=54
-LAST=18
-COMMENT=165
-REMOVEDUPLICATE=73
-UNMARKALL=55
-RBRACK=139
-NEAR=20
-GREEDYANCHORING=59
-LINE_COMMENT=166
-IntegerTypeSuffix=120
-MARKSCORE=39
-REMOVESTRING=79
-TRANSFER=56
-LCURLY=140
-TRIE=7
-FILTERTYPE=47
-MARKFIRST=44
-STRINGLIST=108
-MARKONCE=40
-ScriptString=86
-EngineString=87
-WS=164
-WORDTABLE=11
-WORDLIST=10
-AutomataBlockString=90
-FromString=99
-FloatingPointLiteral=126
-STARTANCHOR=118
-INTLIST=105
-OR=21
-TRIM=60
-JavaIDDigit=134
-FLOATLIST=107
-CALL=48
-Annotation=5
-FALSE=117
-LESSEQUAL=161
-RessourceLiteral=130
-VOTE=27
-Letter=133
-EscapeSequence=127
-SIZE=77
-REMOVEFILTERTYPE=69
-LBRACK=138
-CharacterLiteral=128
-DEL=36
-ATTRIBUTE=34
-TypeString=91
-SHIFT=57
-Exponent=124
-THEN2=82
-ASSIGN_EQUAL=155
-RETAINTYPE=46
-TypeSystemString=97
-AND=12
-IntString=92
-ADDFILTERTYPE=68
-BlockString=89
-HexDigit=119
-COLOR=35
-LPAREN=136
-POSITION=24
-IF=28
-LogLevel=83
-CONFIGURE=50
-SLASH=150
-THEN=81
-FILL=33
-COMMA=145
-IS=63
-AMPER=152
-REPLACE=45
-GETLIST=76
-WILDCARD=163
-AsString=100
-EQUAL=158
-GATHER=32
-INLIST=17
-PLUS=147
-BooleanString=96
-GETFEATURE=53
-DOT=143
-ListIdentifier=6
-PARTOFNEQ=23
-BOOLEANLIST=104
-ADD=71
-MARKTABLE=42
-HexLiteral=121
-XOR=115
-PERCENT=156
-MARK=38
-PARSE=30
-PackageString=85
-OldColor=84
-MARKLAST=43
-MERGE=74
-CONTEXTCOUNT=13
-BEFORE=61
+ACTION=4
+ADD=5
+ADDFILTERTYPE=6
+ADDRETAINTYPE=7
+AFTER=8
+ALT_NOTEQUAL=9
+AMPER=10
+AND=11
+ANNOTATION=12
+ANNOTATIONLIST=13
+ASSIGN=14
+ASSIGN_EQUAL=15
+ATTRIBUTE=16
+Annotation=17
+AsString=18
+BEFORE=19
+BOOLEANLIST=20
+BlockString=21
+BooleanString=22
+CALL=23
+CIRCUMFLEX=24
+CLEAR=25
+COLON=26
+COLOR=27
+COMMA=28
+COMMENT=29
+CONDITION=30
+CONFIGURE=31
+CONTAINS=32
+CONTEXTCOUNT=33
+COS=34
+COUNT=35
+CREATE=36
+CURRENTCOUNT=37
+CharacterLiteral=38
+DECLARE=39
+DEL=40
+DOT=41
+DOUBLELIST=42
+DYNAMICANCHORING=43
+DecimalLiteral=44
+DocComment=45
+DoubleString=46
+ENDSWITH=47
+EQUAL=48
EXEC=49
-ImportString=98
-MINUS=148
-AFTER=62
-DecimalLiteral=122
-SEMI=146
-TRUE=116
-FEATURE=29
-SymbolString=101
-COLON=144
-StringLiteral=129
-StringString=95
-SCORE=26
-QUESTION=157
-ADDRETAINTYPE=66
-UnicodeEscape=131
-RCURLY=141
-STARTSWITH=64
-ASSIGN=51
-REMOVERETAINTYPE=67
-TOTALCOUNT=15
-DECLARE=9
-UimafitString=88
-DocComment=4
-MOFN=19
-OctalEscape=132
-SETFEATURE=52
-DoubleString=93
-CIRCUMFLEX=142
-ALT_NOTEQUAL=160
+EXP=50
+EngineString=51
+EscapeSequence=52
+Exponent=53
+FALSE=54
+FEATURE=55
+FILL=56
+FILTERTYPE=57
+FLOATLIST=58
+FloatString=59
+FloatTypeSuffix=60
+FloatingPointLiteral=61
+FromString=62
+GATHER=63
+GET=64
+GETFEATURE=65
+GETLIST=66
+GREATER=67
+GREATEREQUAL=68
+GREEDYANCHORING=69
+HexDigit=70
+HexLiteral=71
+IF=72
+INLIST=73
+INTLIST=74
+IS=75
+Identifier=76
+ImportString=77
+IntString=78
+IntegerTypeSuffix=79
+JavaIDDigit=80
+LAST=81
+LBRACK=82
+LCURLY=83
+LESS=84
+LESSEQUAL=85
+LINE_COMMENT=86
+LOG=87
+LOGN=88
+LPAREN=89
+Letter=90
+ListIdentifier=91
+LogLevel=92
+MARK=93
+MARKFAST=94
+MARKFIRST=95
+MARKLAST=96
+MARKONCE=97
+MARKSCORE=98
+MARKTABLE=99
+MATCHEDTEXT=100
+MERGE=101
+MINUS=102
+MOFN=103
+NEAR=104
+NOT=105
+NOTEQUAL=106
+NULL=107
+OR=108
+OctalEscape=109
+OctalLiteral=110
+OldColor=111
+PARSE=112
+PARTOF=113
+PARTOFNEQ=114
+PERCENT=115
+PLUS=116
+POSITION=117
+POW=118
+PackageString=119
+QUESTION=120
+RBRACK=121
+RCURLY=122
+REGEXP=123
+REMOVE=124
+REMOVEDUPLICATE=125
+REMOVEFILTERTYPE=126
+REMOVERETAINTYPE=127
+REMOVESTRING=128
+REPLACE=129
+RESOURCE=130
+RETAINTYPE=131
+RPAREN=132
+RessourceLiteral=133
+SCORE=134
+SEMI=135
+SETFEATURE=136
+SHIFT=137
+SIN=138
+SIZE=139
+SLASH=140
+SPLIT=141
+STAR=142
+STARTANCHOR=143
+STARTSWITH=144
+STRINGLIST=145
+ScriptString=146
+StringLiteral=147
+StringString=148
+SymbolString=149
+TAN=150
+THEN=151
+THEN2=152
+TOTALCOUNT=153
+TRANSFER=154
+TRIE=155
+TRIM=156
+TRUE=157
+TYPELIST=158
+TypeString=159
+TypeSystemString=160
+UNMARK=161
+UNMARKALL=162
+UimafitString=163
+UnicodeEscape=164
+VBAR=165
+VOTE=166
+WILDCARD=167
+WORDLIST=168
+WORDTABLE=169
+WS=170
+XOR=171
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g Fri Oct 30 17:03:26 2015
@@ -71,6 +71,7 @@ import org.apache.uima.ruta.expression.I
import org.apache.uima.ruta.expression.MatchReference;
import org.apache.uima.ruta.expression.feature.FeatureExpression;
import org.apache.uima.ruta.expression.feature.FeatureMatchExpression;
+import org.apache.uima.ruta.expression.annotation.IAnnotationExpression;
import org.apache.uima.ruta.expression.bool.IBooleanExpression;
import org.apache.uima.ruta.expression.list.BooleanListExpression;
import org.apache.uima.ruta.expression.list.ListExpression;
@@ -544,6 +545,18 @@ List<String> vars = new ArrayList<String
type = TYPELIST
{!isVariableOfType($blockDeclaration::env, input.LT(1).getText(), type.getText())}?
name = Identifier (ASSIGN_EQUAL tl = typeListExpression)? SEMI {addVariable($blockDeclaration::env, name.getText(), type.getText());if(tl != null){setValue($blockDeclaration::env, name.getText(), tl);}}
+
+ |
+ type = ANNOTATION
+ {!isVariableOfType($blockDeclaration::env, input.LT(1).getText(), type.getText())}?
+ name = Identifier (ASSIGN_EQUAL a = annotationExpression)? SEMI {addVariable($blockDeclaration::env, name.getText(), type.getText());if(a != null){setValue($blockDeclaration::env, name.getText(), a);}}
+ |
+ type = ANNOTATIONLIST
+ {!isVariableOfType($blockDeclaration::env, input.LT(1).getText(), type.getText())}?
+ name = Identifier (ASSIGN_EQUAL al = annotationExpression)? SEMI {addVariable($blockDeclaration::env, name.getText(), type.getText());if(al != null){setValue($blockDeclaration::env, name.getText(), al);}}
+
+
+
//|
//stmt1 = conditionDeclaration {stmt = stmt1;}
//|
@@ -2134,8 +2147,8 @@ options {
| a4 = stringExpression {expr = a4;}
| (listExpression)=> l = listExpression {expr = l;}
| a5 = nullExpression {expr = a5;}
- //| a6 = annotationExpression {expr = a6;}
- | a1 = typeExpression {expr = a1;}
+ | a6 = annotationOrTypeExpression {expr = a6;}
+ //| a1 = typeExpression {expr = a1;}
//(a2 = booleanExpression)=> a2 = booleanExpression {expr = a2;}
//| (a3 = numberExpression)=> a3 = numberExpression {expr = a3;}
@@ -2143,16 +2156,34 @@ options {
//| (a1 = typeExpression)=> a1 = typeExpression {expr = a1;}
;
+annotationOrTypeExpression returns [IRutaExpression expr = null]
+ :
+ a1 = typeExpression {expr = a1;}
+ ;
-//annotationExpression returns [IRutaExpression expr = null]
- //:
- //ale = annotationLabelExpression {expr = ale}
- //;
-
-//annotationLabelExpression returns [IRutaExpression expr = null]
- //:
- //label = Identifier {expr = ExpressionFactory.createRuleElementLabelExpression();}
- //;
+annotationExpression returns [IRutaExpression expr = null]
+ :
+ {isVariableOfType($blockDeclaration::env,input.LT(1).getText(), "ANNOTATION") }?
+ id = Identifier {expr = ExpressionFactory.createAnnotationVariableExpression(id);}
+ |
+ {isVariableOfType($blockDeclaration::env,input.LT(1).getText(), "ANNOTATIONLIST") }?
+ id = Identifier {expr = ExpressionFactory.createAnnotationListVariableExpression(id);}
+ |
+ aae = annotationAddressExpression {expr = aae;}
+ |
+ ale = annotationLabelExpression {expr = ale;}
+
+ ;
+
+annotationAddressExpression returns [IRutaExpression expr = null]
+ :
+ ADDRESS_PREFIX address = DecimalLiteral {expr = ExpressionFactory.createAnnotationAddressExpression(address);}
+ ;
+
+annotationLabelExpression returns [IRutaExpression expr = null]
+ :
+ label = Identifier {expr = ExpressionFactory.createAnnotationLabelExpression(label);}
+ ;
nullExpression returns [IRutaExpression expr = null]
:
@@ -2232,6 +2263,7 @@ annotationType returns [Token ref = null
did = dottedId {ref = did;}
)
;
+
wordListExpression returns [WordListExpression expr = null]
@init {
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.tokens
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.tokens?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.tokens (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.tokens Fri Oct 30 17:03:26 2015
@@ -1,163 +1,168 @@
-STAR=149
-FloatTypeSuffix=125
-OctalLiteral=123
-LOG=37
-CONTAINS=8
-REMOVE=72
-GREATEREQUAL=162
-MARKFAST=41
-CONDITION=102
-MATCHEDTEXT=78
-COUNT=14
-LOGN=111
-DYNAMICANCHORING=58
-NOT=70
-Identifier=135
-ACTION=103
-CLEAR=80
-NOTEQUAL=159
-ENDSWITH=65
-DOUBLELIST=106
-VBAR=151
-RPAREN=137
-CREATE=31
-GREATER=154
-SIN=112
-EXP=110
-CURRENTCOUNT=16
-COS=113
-TAN=114
-TYPELIST=109
-FloatString=94
-LESS=153
-REGEXP=25
-GET=75
-UNMARK=54
-PARTOF=22
-LAST=18
-COMMENT=165
-REMOVEDUPLICATE=73
-UNMARKALL=55
-RBRACK=139
-NEAR=20
-GREEDYANCHORING=59
-LINE_COMMENT=166
-IntegerTypeSuffix=120
-MARKSCORE=39
-REMOVESTRING=79
-TRANSFER=56
-LCURLY=140
-TRIE=7
-FILTERTYPE=47
-MARKFIRST=44
-STRINGLIST=108
-MARKONCE=40
-ScriptString=86
-EngineString=87
-WS=164
-WORDTABLE=11
-WORDLIST=10
-AutomataBlockString=90
-FromString=99
-FloatingPointLiteral=126
-STARTANCHOR=118
-INTLIST=105
-OR=21
-TRIM=60
-JavaIDDigit=134
-FLOATLIST=107
-CALL=48
-Annotation=5
-FALSE=117
-LESSEQUAL=161
-RessourceLiteral=130
-VOTE=27
-Letter=133
-EscapeSequence=127
-SIZE=77
-REMOVEFILTERTYPE=69
-LBRACK=138
-CharacterLiteral=128
-DEL=36
-ATTRIBUTE=34
-TypeString=91
-SHIFT=57
-Exponent=124
-THEN2=82
-ASSIGN_EQUAL=155
-RETAINTYPE=46
-AND=12
-TypeSystemString=97
-BlockString=89
-ADDFILTERTYPE=68
-IntString=92
-HexDigit=119
-COLOR=35
-POSITION=24
-LPAREN=136
-IF=28
-LogLevel=83
-CONFIGURE=50
-SLASH=150
-THEN=81
-FILL=33
-COMMA=145
-IS=63
-GETLIST=76
-REPLACE=45
-AMPER=152
-AsString=100
-WILDCARD=163
-EQUAL=158
-GATHER=32
-INLIST=17
-PLUS=147
-BooleanString=96
-GETFEATURE=53
-DOT=143
-ListIdentifier=6
-PARTOFNEQ=23
-ADD=71
-BOOLEANLIST=104
-MARKTABLE=42
-HexLiteral=121
-XOR=115
-MARK=38
-PERCENT=156
-PackageString=85
-PARSE=30
-OldColor=84
-MERGE=74
-MARKLAST=43
-CONTEXTCOUNT=13
-BEFORE=61
+ACTION=4
+ADD=5
+ADDFILTERTYPE=6
+ADDRETAINTYPE=7
+AFTER=8
+ALT_NOTEQUAL=9
+AMPER=10
+AND=11
+ANNOTATION=12
+ANNOTATIONLIST=13
+ASSIGN=14
+ASSIGN_EQUAL=15
+ATTRIBUTE=16
+Annotation=17
+AsString=18
+BEFORE=19
+BOOLEANLIST=20
+BlockString=21
+BooleanString=22
+CALL=23
+CIRCUMFLEX=24
+CLEAR=25
+COLON=26
+COLOR=27
+COMMA=28
+COMMENT=29
+CONDITION=30
+CONFIGURE=31
+CONTAINS=32
+CONTEXTCOUNT=33
+COS=34
+COUNT=35
+CREATE=36
+CURRENTCOUNT=37
+CharacterLiteral=38
+DECLARE=39
+DEL=40
+DOT=41
+DOUBLELIST=42
+DYNAMICANCHORING=43
+DecimalLiteral=44
+DocComment=45
+DoubleString=46
+ENDSWITH=47
+EQUAL=48
EXEC=49
-ImportString=98
-AFTER=62
-MINUS=148
-DecimalLiteral=122
-TRUE=116
-SEMI=146
-FEATURE=29
-SymbolString=101
-StringString=95
-StringLiteral=129
-COLON=144
-SCORE=26
-QUESTION=157
-ADDRETAINTYPE=66
-UnicodeEscape=131
-STARTSWITH=64
-RCURLY=141
-ASSIGN=51
-REMOVERETAINTYPE=67
-TOTALCOUNT=15
-UimafitString=88
-DECLARE=9
-DocComment=4
-MOFN=19
-SETFEATURE=52
-OctalEscape=132
-DoubleString=93
-CIRCUMFLEX=142
-ALT_NOTEQUAL=160
+EXP=50
+EngineString=51
+EscapeSequence=52
+Exponent=53
+FALSE=54
+FEATURE=55
+FILL=56
+FILTERTYPE=57
+FLOATLIST=58
+FloatString=59
+FloatTypeSuffix=60
+FloatingPointLiteral=61
+FromString=62
+GATHER=63
+GET=64
+GETFEATURE=65
+GETLIST=66
+GREATER=67
+GREATEREQUAL=68
+GREEDYANCHORING=69
+HexDigit=70
+HexLiteral=71
+IF=72
+INLIST=73
+INTLIST=74
+IS=75
+Identifier=76
+ImportString=77
+IntString=78
+IntegerTypeSuffix=79
+JavaIDDigit=80
+LAST=81
+LBRACK=82
+LCURLY=83
+LESS=84
+LESSEQUAL=85
+LINE_COMMENT=86
+LOG=87
+LOGN=88
+LPAREN=89
+Letter=90
+ListIdentifier=91
+LogLevel=92
+MARK=93
+MARKFAST=94
+MARKFIRST=95
+MARKLAST=96
+MARKONCE=97
+MARKSCORE=98
+MARKTABLE=99
+MATCHEDTEXT=100
+MERGE=101
+MINUS=102
+MOFN=103
+NEAR=104
+NOT=105
+NOTEQUAL=106
+NULL=107
+OR=108
+OctalEscape=109
+OctalLiteral=110
+OldColor=111
+PARSE=112
+PARTOF=113
+PARTOFNEQ=114
+PERCENT=115
+PLUS=116
+POSITION=117
+POW=118
+PackageString=119
+QUESTION=120
+RBRACK=121
+RCURLY=122
+REGEXP=123
+REMOVE=124
+REMOVEDUPLICATE=125
+REMOVEFILTERTYPE=126
+REMOVERETAINTYPE=127
+REMOVESTRING=128
+REPLACE=129
+RESOURCE=130
+RETAINTYPE=131
+RPAREN=132
+RessourceLiteral=133
+SCORE=134
+SEMI=135
+SETFEATURE=136
+SHIFT=137
+SIN=138
+SIZE=139
+SLASH=140
+SPLIT=141
+STAR=142
+STARTANCHOR=143
+STARTSWITH=144
+STRINGLIST=145
+ScriptString=146
+StringLiteral=147
+StringString=148
+SymbolString=149
+TAN=150
+THEN=151
+THEN2=152
+TOTALCOUNT=153
+TRANSFER=154
+TRIE=155
+TRIM=156
+TRUE=157
+TYPELIST=158
+TypeString=159
+TypeSystemString=160
+UNMARK=161
+UNMARKALL=162
+UimafitString=163
+UnicodeEscape=164
+VBAR=165
+VOTE=166
+WILDCARD=167
+WORDLIST=168
+WORDTABLE=169
+WS=170
+XOR=171
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java Fri Oct 30 17:03:26 2015
@@ -19,9 +19,10 @@
package org.apache.uima.ruta.condition;
-import java.util.Iterator;
-
+import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.ruta.RutaStream;
import org.apache.uima.ruta.expression.number.INumberExpression;
import org.apache.uima.ruta.expression.number.SimpleNumberExpression;
@@ -49,12 +50,9 @@ public class TotalCountCondition extends
public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
InferenceCrowd crowd) {
int count = 0;
- Iterator<?> it = stream.getJCas().getAnnotationIndex(type.getType(element.getParent()))
- .iterator();
- while (it.hasNext()) {
- it.next();
- count++;
- }
+ Type t = type.getType(element.getParent());
+ AnnotationIndex<Annotation> annotationIndex = stream.getJCas().getAnnotationIndex(t);
+ count= annotationIndex.size();
if (var != null) {
element.getParent().getEnvironment().setVariableValue(var, count);
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/ExpressionFactory.java?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/ExpressionFactory.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/ExpressionFactory.java Fri Oct 30 17:03:26 2015
@@ -75,225 +75,271 @@ import org.apache.uima.ruta.expression.t
public class ExpressionFactory {
- private ExpressionFactory() {
- }
-
- public static INumberExpression createIntegerExpression(Token number, Token minus) {
- Integer valueOf = Integer.valueOf(number.getText());
- SimpleNumberExpression simpleNumberExpression = new SimpleNumberExpression(valueOf);
- if (minus != null) {
- return new NegativeNumberExpression(simpleNumberExpression);
- } else {
- return simpleNumberExpression;
- }
- }
-
- public static INumberExpression createDoubleExpression(Token number, Token minus) {
- Double valueOf = Double.valueOf(number.getText());
- SimpleNumberExpression simpleNumberExpression = new SimpleNumberExpression(valueOf);
- if (minus != null) {
- return new NegativeNumberExpression(simpleNumberExpression);
- } else {
- return simpleNumberExpression;
- }
- }
-
- public static INumberExpression createReferenceNumberExpression(Token var, Token minus) {
- ReferenceNumberExpression simpleNumberExpression = new ReferenceNumberExpression(var.getText());
- if (minus != null) {
- return new NegativeNumberExpression(simpleNumberExpression);
- } else {
- return simpleNumberExpression;
- }
- }
-
- public static INumberExpression createComposedNumberExpression(List<INumberExpression> expressions,
- List<Token> opTokens) {
- List<String> ops = new ArrayList<String>();
- for (Token token : opTokens) {
- ops.add(token.getText());
- }
- return new ComposedNumberExpression(expressions, ops);
- }
-
- public static INumberExpression createComposedNumberExpression(INumberExpression expression,
- Token opToken) {
- List<String> ops = new ArrayList<String>();
- List<INumberExpression> exprList = new ArrayList<INumberExpression>();
- ops.add(opToken.getText());
- exprList.add(expression);
- return new ComposedNumberExpression(exprList, ops);
- }
-
- public static INumberExpression createComposedNumberExpression(INumberExpression expression1,
- Token opToken, INumberExpression expression2) {
- List<String> ops = new ArrayList<String>();
- List<INumberExpression> exprList = new ArrayList<INumberExpression>();
- ops.add(opToken.getText());
- exprList.add(expression1);
- exprList.add(expression2);
- return new ComposedNumberExpression(exprList, ops);
- }
-
- public static AbstractStringExpression createSimpleStringExpression(Token token) {
- String text = token.getText();
- String substring = text.substring(1, text.length() - 1);
- return new SimpleStringExpression(substring);
- }
-
- public static IStringExpression createComposedStringExpression(List<IStringExpression> expressions) {
- return new ComposedStringExpression(expressions);
- }
-
- public static AbstractStringExpression createReferenceStringExpression(Token var) {
- return new ReferenceStringExpression(var.getText());
- }
-
- public static IBooleanExpression createBooleanNumberExpression(INumberExpression e1, Token op,
- INumberExpression e2) {
- return new BooleanNumberExpression(e1, op.getText(), e2);
- }
-
- public static IBooleanExpression createSimpleBooleanExpression(Token v) {
- return new SimpleBooleanExpression(Boolean.valueOf(v.getText()));
- }
-
- public static IBooleanExpression createReferenceBooleanExpression(Token id) {
- return new ReferenceBooleanExpression(id.getText());
- }
-
- public static TypeExpression createSimpleTypeExpression(Token typeToken, RutaBlock parent) {
- String typeString = typeToken == null ? "uima.tcas.DocumentAnnotation" : typeToken.getText();
- return new SimpleTypeExpression(typeString);
- }
-
- public static TypeExpression createReferenceTypeExpression(Token varToken) {
- String varString = varToken == null ? "" : varToken.getText();
- return new ReferenceTypeExpression(varString);
- }
-
- public static TypeExpression createSimpleTypeExpression(String typeString, RutaBlock parent) {
- return new SimpleTypeExpression(typeString);
- }
-
- public static IBooleanExpression createBooleanFunction(Token op, IBooleanExpression e1,
- IBooleanExpression e2) {
- return new SimpleBooleanFunction(op.getText(), e1, e2);
- }
-
- public static WordTableExpression createReferenceWordTableExpression(Token id) {
- return new ReferenceWordTableExpression(id.getText());
- }
-
- public static WordListExpression createReferenceWordListExpression(Token id) {
- return new ReferenceWordListExpression(id.getText());
- }
-
- public static WordListExpression createLiteralWordListExpression(Token path) {
- return new LiteralWordListExpression(path.getText());
- }
-
- public static WordTableExpression createLiteralWordTableExpression(Token path) {
- return new LiteralWordTableExpression(path.getText());
- }
-
- public static IBooleanExpression createBooleanTypeExpression(TypeExpression e1, Token op,
- TypeExpression e2) {
- return new BooleanTypeExpression(e1, op.getText(), e2);
- }
-
- public static BooleanListExpression createReferenceBooleanListExpression(Token var) {
- return new ReferenceBooleanListExpression(var.getText());
- }
-
- public static StringListExpression createReferenceStringListExpression(Token var) {
- return new ReferenceStringListExpression(var.getText());
- }
-
- public static TypeListExpression createReferenceTypeListExpression(Token var) {
- return new ReferenceTypeListExpression(var.getText());
- }
-
- public static NumberListExpression createReferenceDoubleListExpression(Token var) {
- return new ReferenceNumberListExpression(var.getText());
- }
-
- public static NumberListExpression createReferenceIntListExpression(Token var) {
- return new ReferenceNumberListExpression(var.getText());
- }
-
- public static NumberListExpression createReferenceFloatListExpression(Token var) {
- return new ReferenceNumberListExpression(var.getText());
- }
-
- public static BooleanListExpression createBooleanListExpression(List<IBooleanExpression> list) {
- return new SimpleBooleanListExpression(list);
- }
-
- public static NumberListExpression createNumberListExpression(List<INumberExpression> list) {
- return new SimpleNumberListExpression(list);
- }
-
- public static TypeListExpression createTypeListExpression(List<TypeExpression> list) {
- return new SimpleTypeListExpression(list);
- }
-
- public static StringListExpression createStringListExpression(List<IStringExpression> list) {
- return new SimpleStringListExpression(list);
- }
-
- public static FeatureExpression createFeatureExpression(MatchReference mr, RutaBlock env) {
- return new SimpleFeatureExpression(mr);
- }
-
- public static FeatureMatchExpression createFeatureMatchExpression(MatchReference mr, RutaBlock env) {
- return new FeatureMatchExpression(mr, env);
- }
-
- public static MatchReference createMatchReference(Token refToken, Token opToken,
- IRutaExpression arg) {
- String match = refToken.getText();
- String op = null;
- if (opToken != null) {
- op = opToken.getText();
- }
- return new MatchReference(match, op, arg);
- }
-
- public static INumberExpression createNumberFeatureExpression(FeatureExpression fe) {
- return new NumberFeatureExpression(fe);
- }
-
- public static AbstractStringExpression createStringFeatureExpression(FeatureExpression fe) {
- return new StringFeatureExpression(fe);
- }
-
- public static IBooleanExpression createBooleanFeatureExpression(FeatureExpression fe) {
- return new BooleanFeatureExpression(fe);
- }
-
- public static GenericFeatureExpression createGenericFeatureExpression(FeatureExpression fe) {
- return new GenericFeatureExpression(fe);
- }
-
- public static ListExpression<Object> createUntypedListExpression(List<IRutaExpression> list) {
- return new UntypedListExpression(list);
- }
-
- public static WordListExpression createExternalWordListExpression(Token name,
- List<IStringExpression> args) {
- return new ExternalWordListExpression(name.getText(), args);
- }
-
- public static WordTableExpression createExternalWordTableExpression(Token name,
- List<IStringExpression> args) {
- return new ExternalWordTableExpression(name.getText(), args);
- }
-
- public static IRutaExpression createNullExpression() {
- return new NullExpression();
- }
-
+ private ExpressionFactory() {
+ }
+ public static INumberExpression createIntegerExpression(Token number,
+ Token minus) {
+ Integer valueOf = Integer.valueOf(number.getText());
+ SimpleNumberExpression simpleNumberExpression = new SimpleNumberExpression(
+ valueOf);
+ if (minus != null) {
+ return new NegativeNumberExpression(simpleNumberExpression);
+ } else {
+ return simpleNumberExpression;
+ }
+ }
+
+ public static INumberExpression createDoubleExpression(Token number,
+ Token minus) {
+ Double valueOf = Double.valueOf(number.getText());
+ SimpleNumberExpression simpleNumberExpression = new SimpleNumberExpression(
+ valueOf);
+ if (minus != null) {
+ return new NegativeNumberExpression(simpleNumberExpression);
+ } else {
+ return simpleNumberExpression;
+ }
+ }
+
+ public static INumberExpression createReferenceNumberExpression(Token var,
+ Token minus) {
+ ReferenceNumberExpression simpleNumberExpression = new ReferenceNumberExpression(
+ var.getText());
+ if (minus != null) {
+ return new NegativeNumberExpression(simpleNumberExpression);
+ } else {
+ return simpleNumberExpression;
+ }
+ }
+
+ public static INumberExpression createComposedNumberExpression(
+ List<INumberExpression> expressions, List<Token> opTokens) {
+ List<String> ops = new ArrayList<String>();
+ for (Token token : opTokens) {
+ ops.add(token.getText());
+ }
+ return new ComposedNumberExpression(expressions, ops);
+ }
+
+ public static INumberExpression createComposedNumberExpression(
+ INumberExpression expression, Token opToken) {
+ List<String> ops = new ArrayList<String>();
+ List<INumberExpression> exprList = new ArrayList<INumberExpression>();
+ ops.add(opToken.getText());
+ exprList.add(expression);
+ return new ComposedNumberExpression(exprList, ops);
+ }
+
+ public static INumberExpression createComposedNumberExpression(
+ INumberExpression expression1, Token opToken,
+ INumberExpression expression2) {
+ List<String> ops = new ArrayList<String>();
+ List<INumberExpression> exprList = new ArrayList<INumberExpression>();
+ ops.add(opToken.getText());
+ exprList.add(expression1);
+ exprList.add(expression2);
+ return new ComposedNumberExpression(exprList, ops);
+ }
+
+ public static AbstractStringExpression createSimpleStringExpression(
+ Token token) {
+ String text = token.getText();
+ String substring = text.substring(1, text.length() - 1);
+ return new SimpleStringExpression(substring);
+ }
+
+ public static IStringExpression createComposedStringExpression(
+ List<IStringExpression> expressions) {
+ return new ComposedStringExpression(expressions);
+ }
+
+ public static AbstractStringExpression createReferenceStringExpression(
+ Token var) {
+ return new ReferenceStringExpression(var.getText());
+ }
+
+ public static IBooleanExpression createBooleanNumberExpression(
+ INumberExpression e1, Token op, INumberExpression e2) {
+ return new BooleanNumberExpression(e1, op.getText(), e2);
+ }
+
+ public static IBooleanExpression createSimpleBooleanExpression(Token v) {
+ return new SimpleBooleanExpression(Boolean.valueOf(v.getText()));
+ }
+
+ public static IBooleanExpression createReferenceBooleanExpression(Token id) {
+ return new ReferenceBooleanExpression(id.getText());
+ }
+
+ public static TypeExpression createSimpleTypeExpression(Token typeToken,
+ RutaBlock parent) {
+ String typeString = typeToken == null ? "uima.tcas.DocumentAnnotation"
+ : typeToken.getText();
+ return new SimpleTypeExpression(typeString);
+ }
+
+ public static TypeExpression createReferenceTypeExpression(Token varToken) {
+ String varString = varToken == null ? "" : varToken.getText();
+ return new ReferenceTypeExpression(varString);
+ }
+
+ public static TypeExpression createSimpleTypeExpression(String typeString,
+ RutaBlock parent) {
+ return new SimpleTypeExpression(typeString);
+ }
+
+ public static IBooleanExpression createBooleanFunction(Token op,
+ IBooleanExpression e1, IBooleanExpression e2) {
+ return new SimpleBooleanFunction(op.getText(), e1, e2);
+ }
+
+ public static WordTableExpression createReferenceWordTableExpression(
+ Token id) {
+ return new ReferenceWordTableExpression(id.getText());
+ }
+
+ public static WordListExpression createReferenceWordListExpression(Token id) {
+ return new ReferenceWordListExpression(id.getText());
+ }
+
+ public static WordListExpression createLiteralWordListExpression(Token path) {
+ return new LiteralWordListExpression(path.getText());
+ }
+
+ public static WordTableExpression createLiteralWordTableExpression(
+ Token path) {
+ return new LiteralWordTableExpression(path.getText());
+ }
+
+ public static IBooleanExpression createBooleanTypeExpression(
+ TypeExpression e1, Token op, TypeExpression e2) {
+ return new BooleanTypeExpression(e1, op.getText(), e2);
+ }
+
+ public static BooleanListExpression createReferenceBooleanListExpression(
+ Token var) {
+ return new ReferenceBooleanListExpression(var.getText());
+ }
+
+ public static StringListExpression createReferenceStringListExpression(
+ Token var) {
+ return new ReferenceStringListExpression(var.getText());
+ }
+
+ public static TypeListExpression createReferenceTypeListExpression(Token var) {
+ return new ReferenceTypeListExpression(var.getText());
+ }
+
+ public static NumberListExpression createReferenceDoubleListExpression(
+ Token var) {
+ return new ReferenceNumberListExpression(var.getText());
+ }
+
+ public static NumberListExpression createReferenceIntListExpression(
+ Token var) {
+ return new ReferenceNumberListExpression(var.getText());
+ }
+
+ public static NumberListExpression createReferenceFloatListExpression(
+ Token var) {
+ return new ReferenceNumberListExpression(var.getText());
+ }
+
+ public static BooleanListExpression createBooleanListExpression(
+ List<IBooleanExpression> list) {
+ return new SimpleBooleanListExpression(list);
+ }
+
+ public static NumberListExpression createNumberListExpression(
+ List<INumberExpression> list) {
+ return new SimpleNumberListExpression(list);
+ }
+
+ public static TypeListExpression createTypeListExpression(
+ List<TypeExpression> list) {
+ return new SimpleTypeListExpression(list);
+ }
+
+ public static StringListExpression createStringListExpression(
+ List<IStringExpression> list) {
+ return new SimpleStringListExpression(list);
+ }
+
+ public static FeatureExpression createFeatureExpression(MatchReference mr,
+ RutaBlock env) {
+ return new SimpleFeatureExpression(mr);
+ }
+
+ public static FeatureMatchExpression createFeatureMatchExpression(
+ MatchReference mr, RutaBlock env) {
+ return new FeatureMatchExpression(mr, env);
+ }
+
+ public static MatchReference createMatchReference(Token refToken,
+ Token opToken, IRutaExpression arg) {
+ String match = refToken.getText();
+ String op = null;
+ if (opToken != null) {
+ op = opToken.getText();
+ }
+ return new MatchReference(match, op, arg);
+ }
+
+ public static INumberExpression createNumberFeatureExpression(
+ FeatureExpression fe) {
+ return new NumberFeatureExpression(fe);
+ }
+
+ public static AbstractStringExpression createStringFeatureExpression(
+ FeatureExpression fe) {
+ return new StringFeatureExpression(fe);
+ }
+
+ public static IBooleanExpression createBooleanFeatureExpression(
+ FeatureExpression fe) {
+ return new BooleanFeatureExpression(fe);
+ }
+
+ public static GenericFeatureExpression createGenericFeatureExpression(
+ FeatureExpression fe) {
+ return new GenericFeatureExpression(fe);
+ }
+
+ public static ListExpression<Object> createUntypedListExpression(
+ List<IRutaExpression> list) {
+ return new UntypedListExpression(list);
+ }
+
+ public static WordListExpression createExternalWordListExpression(
+ Token name, List<IStringExpression> args) {
+ return new ExternalWordListExpression(name.getText(), args);
+ }
+
+ public static WordTableExpression createExternalWordTableExpression(
+ Token name, List<IStringExpression> args) {
+ return new ExternalWordTableExpression(name.getText(), args);
+ }
+
+ public static IRutaExpression createNullExpression() {
+ return new NullExpression();
+ }
+
+ public static IRutaExpression createAnnotationAddressExpression(
+ Token address) {
+ return null;
+ }
+
+ public static IRutaExpression createAnnotationLabelExpression(Token label) {
+ return null;
+ }
+
+ public static IRutaExpression createAnnotationVariableExpression(Token var) {
+ return null;
+ }
+
+ public static IRutaExpression createAnnotationListVariableExpression(Token var) {
+ return null;
+ }
}
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/IAnnotationExpression.java Fri Oct 30 17:03:26 2015
@@ -38,8 +38,7 @@ public interface IAnnotationExpression {
List<AnnotationFS> getAnnotations(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
- AnnotationFS getAnnotation(RutaBlock parent, RuleMatch match, RuleElement element,
- RutaStream stream);
+ AnnotationFS getAnnotation(RutaBlock parent, RuleMatch match, RuleElement element, RutaStream stream);
List<AnnotationFS> getAnnotations(RutaBlock parent, RuleMatch match, RuleElement element,
RutaStream stream);
Modified: uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java
URL: http://svn.apache.org/viewvc/uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java?rev=1711508&r1=1711507&r2=1711508&view=diff
==============================================================================
--- uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java (original)
+++ uima/ruta/branches/UIMA-4408/ruta-core/src/main/java/org/apache/uima/ruta/expression/annotation/LabelAnnotationExpression.java Fri Oct 30 17:03:26 2015
@@ -29,6 +29,7 @@ public class LabelAnnotationExpression e
@Override
public AnnotationFS getAnnotation(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+ // TODO
return getAnnotations(parent, annotation, stream).get(0);
}