public class Expressions
extends java.lang.Object
Field | Description |
---|---|
Accessing captured groups as list of tokens | |
$n | Capture group (as list of tokens) corresponding to the variable $n .
If n is a integer, then the n-th captured group. Capture group 0 is the entire matched expression.
Otherwise, if n is a string, then the captured group with name n . |
$n[i] | The i-th token of the captured group $n .
Use negative indices to count from the end of the list (e.g. -1 is the last token). |
$n[i].key | The value of annotation key of the i-th token of the captured group $n . |
Accessing captured groups as MatchedGroupInfo | |
$$n | Capture group (as MatchedGroupInfo) corresponding to the variable $n .
Use to get the associated value of the group and any embedded capture groups.
If n is a integer, then the n-th captured group. Capture group 0 is the entire matched expression.
Otherwise, if n is a string, then the captured group with name n . |
$$n.text | Text of the capture group n . |
$$n.nodes | Tokens of the capture group n (this is equivalent to $n ). |
$$n.value | Value associated with capture group n . |
$$n.matchResults | Additional match results associated with capture group n .
Use to get embedded capture groups. For instance, when the TokensRegex /(\d\d)-(\d\d)/ is matched
against the sentence "the score was 10-12", $$0.text will be "10-12" and
$$0.matchResults[0].word.group(1) will be "10". |
The following functions are supported:
Function | Description |
---|---|
Annotate(CoreMap, field, value) | Annotates the CoreMap with specified field=value |
Aggregate(function, initialValue,...) | Aggregates values using function (like fold) |
Split(CoreMap, delimRegex, includeMatched) | Split one CoreMap into smaller coremaps using the specified delimRegex on the text of the CoreMap. If includeMatched is true, pieces that matches the delimRegex are included in the final list of CoreMaps |
Tagging functions | |
Tag(CoreMap or List<CoreMap>, tag, value)<br>VTag(Value,tag,value) | Sets a temporary tag on the CoreMap(s) or Value |
GetTag(CoreMap or List<CoreMap>, tag)<br>GetVTag(Value,tag) | Returns the temporary tag on the CoreMap(s) or Value |
RemoveTag(CoreMap or List<CoreMap>, tag)<br>RemoveVTag(Value,tag) | Removes the temporary tag on the CoreMap(s) or Value |
Regex functions | |
Match(List<CoreMap>, tokensregex)<br>Match(String,regex) | Returns whether the tokens or text matched |
Replace(List<CoreMap>, tokensregex, replacement)<br>Match(String,regex,replacement) | Replaces the matched tokens or text |
CreateRegex(List<String>) | Creates one big string regular expression that matches any of the strings in the list |
Accessor functions | |
Map(list,function) | Returns a new list that is the result of applying the function on every element of the List |
Keys(map) | Returns list of keys for the given map |
Set(object or map, fieldname, value) Set(list,index,value) | Set the field to the specified value |
Get(object or map, fieldname) or object.fieldname <br>Get(list,index) or list[index] | Returns the value of the specified field |
String functions | |
Format(format,arg1,arg2,...) | Returns formatted string |
Concat(str1,str2,...) | Returns strings concatenated together |
Join(glue,str1,str2,...) | Returns strings concatenated together with glue in the middle |
Lowercase(str) | Returns the lowercase form of the string |
Uppercase(str) | Returns the uppercase form of the string |
Numeric functions | |
Subtract(X,Y) | Returns X-Y |
Add(X,Y) | Returns X+Y |
Subtract(X,Y) | Returns X-Y |
Multiply(X,Y) | Returns X*Y |
Divide(X,Y) | Returns X/Y |
Mod(X,Y) | Returns X%Y |
Negate(X) | Returns -X |
Boolean functions | |
And(X,Y) | Returns X&&Y |
Or(X,Y) | Returns X||Y |
Not(X) | Returns !X |
GE(X,Y) or X >= Y | Returns X >= Y |
GT(X,Y) or X > Y | Returns X > Y |
LE(X,Y) or X <= Y | Returns X <= Y |
LT(X,Y) or X < Y | Returns X < Y |
EQ(X,Y) or X == Y | Returns X == Y |
NE(X,Y) or X != Y | Returns X != Y |
Modifier and Type | Class and Description |
---|---|
static class |
Expressions.AndExpression |
static class |
Expressions.AssignableFunctionCallExpression
A function call that can be assigned a value.
|
static class |
Expressions.CaseExpression |
static class |
Expressions.CompositeValue
A composite value with field names and values for each field
|
static class |
Expressions.ConditionalExpression |
static class |
Expressions.FieldExpression |
static class |
Expressions.FunctionCallExpression |
static class |
Expressions.IfExpression |
static class |
Expressions.IndexedExpression |
static class |
Expressions.ListExpression |
static class |
Expressions.MethodCallExpression |
static class |
Expressions.NotExpression |
static class |
Expressions.OrExpression |
static class |
Expressions.PrimitiveValue<T>
Primitive value that is directly represented by a Java object of type T
|
static class |
Expressions.RegexMatchResultVarExpression |
static class |
Expressions.RegexMatchVarExpression |
static class |
Expressions.RegexValue
A string that represents a regular expression
|
static class |
Expressions.SimpleCachedExpression<T>
A simple implementation of an expression that is represented by a java object of type T
and which also has a cached Value stored with it
|
static class |
Expressions.SimpleExpression<T>
A simple implementation of an expression that is represented by a java object of type T
|
static class |
Expressions.SimpleValue<T>
Simple implementation of Value backed by a java object of type T
|
static class |
Expressions.TypedExpression
An expression with a typename and tags.
|
static class |
Expressions.VarAssignmentExpression
A variable assignment with the name of the variable, and the expression to assign to that variable
|
static class |
Expressions.VarExpression
A variable, which can be assigned any expression.
|
static class |
Expressions.WrappedExpression
An expression that is a wrapper around another expression.
|
Modifier and Type | Field and Description |
---|---|
static Value<java.lang.Boolean> |
FALSE |
protected static java.lang.String |
NEWLINE |
static Value |
NIL |
static Value<java.lang.Boolean> |
TRUE |
static java.lang.String |
TYPE_ANNOTATION_KEY |
static java.lang.String |
TYPE_BOOLEAN |
static java.lang.String |
TYPE_CLASS
CLASS - Maps to a Java class
|
static java.lang.String |
TYPE_COMPOSITE
COMPOSITE - Composite value with field names and field values
|
static java.lang.String |
TYPE_FUNCTION
FUNCTION - (input) => (output) where input is a list of Values, and output is a single Value
|
static java.lang.String |
TYPE_LIST
LIST - List
|
static java.lang.String |
TYPE_NUMBER
NUMBER - Numeric value (can be integer or real)
|
static java.lang.String |
TYPE_REGEX
REGEX - Regular expression pattern (for tokens or string)
|
static java.lang.String |
TYPE_REGEXMATCHVAR
REGEXMATCHVAR - Variable that refers to variable resulting from a regex match or used in a regex match (starts with $)
|
static java.lang.String |
TYPE_SET |
static java.lang.String |
TYPE_STRING
STRING - String
|
static java.lang.String |
TYPE_STRING_REGEX |
static java.lang.String |
TYPE_TOKEN_REGEX |
static java.lang.String |
TYPE_TOKENS |
static java.lang.String |
TYPE_VAR
VAR - Variable
|
static java.lang.String |
VAR_SELF |
Modifier and Type | Method and Description |
---|---|
static Expression |
asExpression(Env env,
java.lang.Object v) |
static <C> C |
asObject(Env env,
java.lang.Object v) |
static Value |
asValue(Env env,
java.lang.Object v) |
static java.lang.Boolean |
convertValueToBoolean(Value v,
boolean keepNull) |
static Value<java.lang.Boolean> |
convertValueToBooleanValue(Value v,
boolean keepNull) |
static <T> Value |
createValue(java.lang.String typename,
T value,
java.lang.String... tags) |
public static final java.lang.String TYPE_VAR
public static final java.lang.String TYPE_FUNCTION
public static final java.lang.String TYPE_REGEX
public static final java.lang.String TYPE_STRING_REGEX
public static final java.lang.String TYPE_TOKEN_REGEX
public static final java.lang.String TYPE_REGEXMATCHVAR
public static final java.lang.String TYPE_STRING
public static final java.lang.String TYPE_NUMBER
public static final java.lang.String TYPE_COMPOSITE
public static final java.lang.String TYPE_LIST
public static final java.lang.String TYPE_SET
public static final java.lang.String TYPE_ANNOTATION_KEY
public static final java.lang.String TYPE_CLASS
public static final java.lang.String TYPE_TOKENS
public static final java.lang.String TYPE_BOOLEAN
public static final java.lang.String VAR_SELF
public static final Value<java.lang.Boolean> TRUE
public static final Value<java.lang.Boolean> FALSE
public static final Value NIL
protected static final java.lang.String NEWLINE
public static java.lang.Boolean convertValueToBoolean(Value v, boolean keepNull)
public static Value<java.lang.Boolean> convertValueToBooleanValue(Value v, boolean keepNull)
public static <C> C asObject(Env env, java.lang.Object v)
public static Expression asExpression(Env env, java.lang.Object v)
public static <T> Value createValue(java.lang.String typename, T value, java.lang.String... tags)