public static final class NCIntentSolver.RULE extends Object implements NCIntentSolver.Predicate
token
.Constructor and Description |
---|
RULE(String expr)
Shortcut constructor for use cases where rule expression can be expressed as a
whitespace separated string of parameter, its operation and value.
|
RULE(String param,
String op,
Object value)
Creates new binary operator with given parameters.
|
Modifier and Type | Method and Description |
---|---|
org.apache.commons.lang3.tuple.Pair<Boolean,int[]> |
apply(NCToken tok) |
String |
getOp()
Gets binary operation of this rule.
|
String |
getParameter()
Gets left-side parameter of this rule.
|
Object |
getValue()
Gets right-side value of this rule.
|
String |
toString() |
public RULE(String param, String op, Object value)
new RULE("id", "==", "x:time"); new RULE("~GEO_KIND", "==", "CITY"); new RULE("value", "%%", "^[Ff]oo[Bb]ar$");
param
- Rule's left-side parameter. Parameter can be one of the following:
Parameter | Description |
---|---|
id |
Token ID
|
group |
Token group
|
parent |
Token parent ID
|
value |
Token value
|
~META |
Token metadata or
element metadata property META .
|
op
- Rule's operation. Operation can be one of the following:
Operation | Description |
---|---|
== |
param is equal to value .
Java Object.equals(Object) method is used for equality check.
|
!= |
param is not equal to value .
Java Object.equals(Object) method is used for equality check.
|
>= |
param is greater or equal than value .
Applicable to Number and ZonedDateTime values only.
|
<= |
param is less or equal than value .
Applicable to Number and ZonedDateTime values only.
|
> |
param is greater than value .
Applicable to Number and ZonedDateTime values only.
|
< |
param is less than value .
Applicable to Number and ZonedDateTime values only.
|
%% |
param matches the regular expression in value .
Applicable to String and Pattern values only.
|
!% |
param does not match the regular expression in value .
Applicable to String and Pattern values only.
|
value
- Rule's right-side string value. It's processing depends on param
and op
.public RULE(String expr)
null
, boolean
, Integer
or
a String
otherwise.
new RULE("id == x:time"); // Value is converted to string. new RULE("~GEO_KIND == CITY"); // Value is converted to string. new RULE("value %% ^[Ff]oo[Bb]ar$"); // Value is converted to string. new RULE("~NUM_INDEX != null"); // Value is converted to 'null'. new RULE("~NUM_VALUE >= 100"); // Value is converted to integer.
expr
- Whitespace separated string of parameter, its operation and value for this rule.public String getParameter()
public String getOp()
public Object getValue()
Copyright © 2013-2019 NLPCraft Project. All rights reserved.