You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/02/20 02:48:09 UTC
[incubator-nlpcraft] branch NLPCRAFT-247 updated: WIP.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-247
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-247 by this push:
new 9c00e57 WIP.
9c00e57 is described below
commit 9c00e57ba8b26255d310a111d3c2c8923aa22c22
Author: Aaron Radzinski <ar...@apache.org>
AuthorDate: Fri Feb 19 18:47:57 2021 -0800
WIP.
---
.../nlpcraft/common/makro/NCMacroParser.scala | 20 +++----
.../nlpcraft/examples/alarm/alarm_model.json | 4 +-
.../examples/lightswitch/lightswitch_model.yaml | 10 ++--
.../nlpcraft/examples/phone/phone_model.json | 2 +-
.../apache/nlpcraft/examples/sql/sql_model.yaml | 14 ++---
.../nlpcraft/examples/sql/sql_model_init.yaml | 2 +-
.../apache/nlpcraft/examples/time/time_model.yaml | 4 +-
.../nlpcraft/examples/weather/weather_model.json | 2 +-
.../scala/org/apache/nlpcraft/model/NCElement.java | 18 +++---
.../org/apache/nlpcraft/model/NCModelView.java | 4 +-
.../sqlgen/impl/NCSqlModelGeneratorImpl.scala | 2 +-
.../mgrs/nlp/enrichers/limit/NCLimitEnricher.scala | 2 +-
.../mgrs/nlp/enrichers/sort/NCSortEnricher.scala | 4 +-
.../coordinate/NCCoordinatesEnricher.scala | 4 +-
.../nlp/enrichers/date/NCDateConstants.scala | 24 ++++----
.../nlpcraft/common/makro/NCMacroParserSpec.scala | 70 +++++++++++-----------
.../model/NCEnricherNestedModelSpec.scala | 6 +-
17 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
index fe13ce8..8766066 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
@@ -67,16 +67,16 @@ object NCMacroParser {
* Syntax:
* - all macros should start with '<' and end with '>'.
* - '{A|B}' denotes either 'A' or 'B'.
- * - '{A|B|*}' denotes either 'A', or 'B' or nothing.
- * - '\' can be used only for escaping '{', '}', '|', and '*' special symbols.
+ * - '{A|B|_}' denotes either 'A', or 'B' or nothing ('_').
+ * - '\' can be used only for escaping '{', '}', '|', and '_' special symbols.
*
* Examples:
* "A {B|C} D" ⇒ "A B D", "A C D"
* "A \{B\|C\} D" ⇒ "A {B|C} D"
- * "A {B|*} D" ⇒ "A D", "A B D"
- * "A {*|B|C} D" ⇒ "A D", "A B D", "A C D"
+ * "A {B|_} D" ⇒ "A D", "A B D"
+ * "A {_|B|C} D" ⇒ "A D", "A B D", "A C D"
* "A <MACRO>" ⇒ "A ..." based on <MACRO> content.
- * "A {<MACRO>|*}" ⇒ "A", "A ..." based on <MACRO> content.
+ * "A {<MACRO>|_}" ⇒ "A", "A ..." based on <MACRO> content.
*
* NOTE: Macros cannot be recursive.
* NOTE: Macros and '{...}' options groups can be nested.
@@ -178,7 +178,7 @@ class NCMacroParser {
/**
* Gets the next lexical token.
*
- * Special symbols are: ' ', '{', '}', '*' and '|'. Use `\` for escaping.
+ * Special symbols are: ' ', '{', '}', '_' and '|'. Use `\` for escaping.
*
* @param s Input string to get the next lexical token from.
*/
@@ -269,7 +269,7 @@ class NCMacroParser {
else {
if (!isEscape)
ch match {
- case '|' | '*' | '}' ⇒ throw new NCE(s"Suspicious '$ch' at pos $i: '$s'")
+ case '|' | '_' | '}' ⇒ throw new NCE(s"Suspicious '$ch' at pos $i: '$s'")
case '{' ⇒ found = true // Found start of the option group.
case _ ⇒
}
@@ -295,7 +295,7 @@ class NCMacroParser {
// Trims all duplicate spaces.
private def trimDupSpaces(s: String) = U.splitTrimFilter(s, " ").mkString(" ")
- // Processes '\' escapes for '{', '}', '|', and '*'.
+ // Processes '\' escapes for '{', '}', '|', and '_'.
private def processEscapes(s: String): String = {
val len = s.length()
val buf = new StringBuilder()
@@ -308,7 +308,7 @@ class NCMacroParser {
if (ch == '\\' && !isEscape)
isEscape = true
else {
- if (isEscape && ch != '|' && ch != '}' && ch != '{' && ch != '*')
+ if (isEscape && ch != '|' && ch != '}' && ch != '{' && ch != '_')
buf += '\\'
buf += ch
@@ -353,7 +353,7 @@ class NCMacroParser {
val tails = expand0(tok.tail)
if (tok.head.head == '{') // Option group.
parseGroup(tok.head).flatMap(x ⇒
- if (x.head == "*")
+ if (x.head == "_")
mixTails("", tails)
else
expand0(x.head).flatMap(z ⇒ mixTails(z, tails))
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/alarm_model.json b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/alarm_model.json
index 0e17713..254f098 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/alarm_model.json
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/alarm_model.json
@@ -28,8 +28,8 @@
"id": "x:alarm",
"description": "Alarm token indicator.",
"synonyms": [
- "{ping|buzz|wake|call|hit} {me|up|me up|*}",
- "{set|*} {my|*} {wake|wake up|*} {alarm|timer|clock|buzzer|call} {up|*}"
+ "{ping|buzz|wake|call|hit} {me|up|me up|_}",
+ "{set|_} {my|_} {wake|wake up|_} {alarm|timer|clock|buzzer|call} {up|_}"
]
}
],
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
index d7676ad..3055efb 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
@@ -25,16 +25,16 @@ macros:
- name: "<KILL>"
macro: "{shut|kill|stop|eliminate}"
- name: "<ENTIRE_OPT>"
- macro: "{entire|full|whole|total|*}"
+ macro: "{entire|full|whole|total|_}"
- name: "<LIGHT>"
- macro: "{all|*} {it|them|light|illumination|lamp|lamplight}"
+ macro: "{all|_} {it|them|light|illumination|lamp|lamplight}"
enabledBuiltInTokens: [] # This example doesn't use any built-in tokens.
elements:
- id: "ls:loc"
description: "Location of lights."
synonyms:
- - "<ENTIRE_OPT> {upstairs|downstairs|*} {kitchen|library|closet|garage|office|playroom|{dinning|laundry|play} room}"
- - "<ENTIRE_OPT> {upstairs|downstairs|*} {master|kid|children|child|guest|*} {bedroom|bathroom|washroom|storage} {closet|*}"
+ - "<ENTIRE_OPT> {upstairs|downstairs|_} {kitchen|library|closet|garage|office|playroom|{dinning|laundry|play} room}"
+ - "<ENTIRE_OPT> {upstairs|downstairs|_} {master|kid|children|child|guest|_} {bedroom|bathroom|washroom|storage} {closet|_}"
- "<ENTIRE_OPT> {house|home|building|{1st|first} floor|{2nd|second} floor}"
- id: "ls:on"
@@ -42,7 +42,7 @@ elements:
- "act"
description: "Light switch ON action."
synonyms:
- - "<ACTION> {on|up|*} <LIGHT> {on|up|*}"
+ - "<ACTION> {on|up|_} <LIGHT> {on|up|_}"
- "<LIGHT> {on|up}"
- id: "ls:off"
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/phone/phone_model.json b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/phone/phone_model.json
index ef205f9..044e1aa 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/phone/phone_model.json
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/phone/phone_model.json
@@ -32,7 +32,7 @@
"id": "phone:act",
"description": "Phone action.",
"synonyms": [
- "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
]
}
]
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model.yaml b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model.yaml
index 70bf2b3..fdfdb4e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model.yaml
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model.yaml
@@ -102,7 +102,7 @@ macros:
- name: "<OF>"
macro: "{of|for|per}"
- name: "<ID>"
- macro: "{unique|*} {id|identifier}"
+ macro: "{unique|_} {id|identifier}"
elements:
- id: "tbl:region"
groups:
@@ -713,7 +713,7 @@ elements:
groups:
- "column"
synonyms:
- - "{orders|*} {unit_price|unit price}"
+ - "{orders|_} {unit_price|unit price}"
- "{order_details|order details} {unit_price|unit price}"
- "{unit_price|unit price} <OF> {order_details|order details}"
metadata:
@@ -727,7 +727,7 @@ elements:
groups:
- "column"
synonyms:
- - "{orders|*} quantity"
+ - "{orders|_} quantity"
- "{order_details|order details} quantity"
- "quantity <OF> {order_details|order details}"
metadata:
@@ -741,7 +741,7 @@ elements:
groups:
- "column"
synonyms:
- - "{orders|*} discount"
+ - "{orders|_} discount"
- "{order_details|order details} discount"
- "discount <OF> {order_details|order details}"
metadata:
@@ -1475,7 +1475,7 @@ elements:
groups:
- "condition"
synonyms:
- - "^^id == 'col:varchar'^^ {is|equal|*} ^^id == 'col:val'^^"
+ - "^^id == 'col:varchar'^^ {is|equal|_} ^^id == 'col:val'^^"
- "^^id == 'col:val'^^"
- id: "condition:date"
groups:
@@ -1486,12 +1486,12 @@ elements:
groups:
- "Sort criteria"
synonyms:
- - "best {performing|*}"
+ - "best {performing|_}"
- id: "sort:worst"
groups:
- "Sort criteria"
synonyms:
- - "{worst|least} {performing|*}"
+ - "{worst|least} {performing|_}"
enabledBuiltInTokens:
- "nlpcraft:date"
- "nlpcraft:num"
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model_init.yaml b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model_init.yaml
index dd4af10..c85950c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model_init.yaml
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/sql_model_init.yaml
@@ -102,7 +102,7 @@ macros:
- name: "<OF>"
macro: "{of|for|per}"
- name: "<ID>"
- macro: "{unique|*} {id|identifier}"
+ macro: "{unique|_} {id|identifier}"
elements:
- id: "tbl:region"
groups:
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/time_model.yaml b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/time_model.yaml
index 16dff18..087e7b4 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/time_model.yaml
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/time_model.yaml
@@ -30,5 +30,5 @@ elements:
- id: "x:time"
description: "Date and/or time token indicator."
synonyms:
- - "{<CUR>|*} <TIME>"
- - "what <TIME> {is it now|now|is it|*}"
\ No newline at end of file
+ - "{<CUR>|_} <TIME>"
+ - "what <TIME> {is it now|now|is it|_}"
\ No newline at end of file
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/weather_model.json b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/weather_model.json
index 4eee3ee..94134e5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/weather_model.json
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/weather_model.json
@@ -28,7 +28,7 @@
"description": "Weather phenomenon.",
"synonyms": [
"{high sea|severe weather|hail|heat wave|cold wave|derecho|supercell|avalanche|cyclone|wildfire|landslide|firestorm|dust storm|thunder snow|winter storm|cloudburst|shower|condensation|precipitation|drizzle|rainstorm|rain storm|rainfall|rain|storm|sun|sunshine|cloud|hot|cold|dry|wet|wind||hurricane|typhoon|sand-storm|sand storm|tornado|humid|fog|snow|smog|black ice|haze|thundershower|thundersnow|sleet|drought|wildfire|blizzard|avalanche|mist|thunderstorm}",
- "{weather {condition|temp|temperature|data|*}|condition|temp|temperature}"
+ "{weather {condition|temp|temperature|data|_}|condition|temp|temperature}"
]
},
{
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
index ef19bdc..f6b2106 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
@@ -63,7 +63,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ]
* }
* ]
@@ -97,7 +97,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "description": "Phone action.",
* "groups": ["group1", "group2"]
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ]
* }
* ]
@@ -138,7 +138,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ],
* "metadata": {
* "str": "val1",
@@ -167,7 +167,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ]
* }
* ]
@@ -192,7 +192,7 @@ public interface NCElement extends NCMetadata, Serializable {
* <ul>
* <li>
* Set of general synonyms:
- * <code>{transportation|transport|*} {vehicle|car|sedan|auto|automobile|suv|crossover|coupe|truck}</code>
+ * <code>{transportation|transport|_} {vehicle|car|sedan|auto|automobile|suv|crossover|coupe|truck}</code>
* </li>
* <li>Set of values:
* <ul>
@@ -223,7 +223,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ],
* "values": [
* {
@@ -254,7 +254,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "description": "Phone action.",
* "parentId": "parent",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ]
* }
* ]
@@ -281,7 +281,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ]
* }
* ]
@@ -309,7 +309,7 @@ public interface NCElement extends NCMetadata, Serializable {
* "id": "phone:act",
* "description": "Phone action.",
* "synonyms": [
- * "{give|*} {call|phone|ring|dial|dial up|ping|contact}"
+ * "{give|_} {call|phone|ring|dial|dial up|ping|contact}"
* ],
* "values": [
* {
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
index ab4b6b8..7fcd1a9 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
@@ -986,8 +986,8 @@ public interface NCModelView extends NCMetadata {
* {
* "id": "wt:hist",
* "synonyms": [
- * "{<WEATHER>|*} <HISTORY>",
- * "<HISTORY> {<OF>|*} <WEATHER>"
+ * "{<WEATHER>|_} <HISTORY>",
+ * "<HISTORY> {<OF>|_} <WEATHER>"
* ],
* "description": "Past weather conditions."
* }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
index 752bc8b..0424ecf 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImpl.scala
@@ -315,7 +315,7 @@ object NCSqlModelGeneratorImpl {
mdl.setMacros(Array(
new NCMacroJson("<OF>", "{of|for|per}"),
- new NCMacroJson("<ID>", "{unique|*} {id|identifier}")
+ new NCMacroJson("<ID>", "{unique|_} {id|identifier}")
))
mdl.setAdditionalStopWords(Array())
mdl.setSuspiciousWords(Array())
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
index 52c9e6a..d0ed457 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
@@ -56,7 +56,7 @@ object NCLimitEnricher extends NCProbeEnricher {
// - Any simple word.
// Note that `CD` is optional (DFLT_LIMIT will be used)
private final val SYNONYMS = Seq(
- s"<TOP_WORDS> {of|*} {$CD|*} {<POST_WORDS>|*}",
+ s"<TOP_WORDS> {of|_} {$CD|_} {<POST_WORDS>|_}",
s"$CD of",
s"$CD <POST_WORDS>",
s"<POST_WORDS> $CD"
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCSortEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCSortEnricher.scala
index 3e133d6..54529ad 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCSortEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCSortEnricher.scala
@@ -80,8 +80,8 @@ object NCSortEnricher extends NCProbeEnricher {
"asc" → true,
"descending" → false,
"desc" → false,
- "{in|by|from} {top down|descending} {order|way|fashion|*}" → false,
- "{in|by|from} {bottom up|ascending} {order|way|fashion|*}" → true
+ "{in|by|from} {top down|descending} {order|way|fashion|_}" → false,
+ "{in|by|from} {bottom up|ascending} {order|way|fashion|_}" → true
)
case class NoteData(note: String, indexes: Seq[Int]) {
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/coordinate/NCCoordinatesEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/coordinate/NCCoordinatesEnricher.scala
index ac82456..cc3f8f8 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/coordinate/NCCoordinatesEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/coordinate/NCCoordinatesEnricher.scala
@@ -43,8 +43,8 @@ object NCCoordinatesEnricher extends NCServerEnricher {
Seq(
"°",
- "{exact|approximate|*} {latitude|lat|longitude|lon}",
- "{following|*} {geo|*} coordinates {data|info|information|*}"
+ "{exact|approximate|_} {latitude|lat|longitude|lon}",
+ "{following|_} {geo|_} coordinates {data|info|information|_}"
).flatMap(p.expand).map(NCNlpCoreManager.stem)
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateConstants.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateConstants.scala
index ac72af6..631c6aa 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateConstants.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateConstants.scala
@@ -58,11 +58,11 @@ private[date] object NCDateConstants {
val FOR: Seq[String] = Seq(
"for",
"during",
- "during {the|*} {time|*} period of",
+ "during {the|_} {time|_} period of",
"within",
- "within {the|*} {time|*} period of",
+ "within {the|_} {time|_} period of",
"of",
- "for {the|*} {time|*} period of"
+ "for {the|_} {time|_} period of"
).flatMap(parser.expand)
val AGO: Seq[String] = Seq(
@@ -116,8 +116,8 @@ private[date] object NCDateConstants {
// 'dd' will be duplicated as 'd'
// 'dd' will be duplicated as 'dth' (st, rd)
val YEAR_MONTH_DAY_COMMON_1: Seq[String] = Seq(
- "{yy|yyyy} dd {'of'|*} {MMMM|MMM}",
- "dd {'of'|*} {MMMM|MMM} {'of'|*} yyyy"
+ "{yy|yyyy} dd {'of'|_} {MMMM|MMM}",
+ "dd {'of'|_} {MMMM|MMM} {'of'|_} yyyy"
).flatMap(parser.expand)
// 'dd' will be duplicated as 'd'.
@@ -162,7 +162,7 @@ private[date] object NCDateConstants {
// 'dd' will be duplicated as 'd'
// 'dd' will be duplicated as 'dth' (st, rd)
val MONTH_DAY_COMMON_1: Seq[String] = Seq(
- "dd {'of'|*} {MMMM|MMM}"
+ "dd {'of'|_} {MMMM|MMM}"
).flatMap(parser.expand)
// 'dd' will be duplicated as 'd'.
@@ -179,12 +179,12 @@ private[date] object NCDateConstants {
)
val MONTH_YEAR_COMMON: Seq[String] = Seq(
- "{'month of'|'month'|*} {MMMM|MMM} {'of'|'year'|'of year'|'year of'|*} {yy|yyyy} {'year'|*}",
+ "{'month of'|'month'|_} {MMMM|MMM} {'of'|'year'|'of year'|'year of'|_} {yy|yyyy} {'year'|_}",
"yyyy {MMMM|MMM}",
- "{'month of'|'month'|*} {MMMMyyyy|MMMyyyy|MMMMyy|MMMyy}",
- "{'month of'|'month'|*} {yyyyMMMM|yyyyMMM|yyMMMM|yyMMM}",
- "{'month of'|'month'|*} {yyyyMMMM|yyyyMMM|yyMMMM|yyMMM}",
- "{'month of'|'month'|*} {MM.yyyy|MM/yyyy|MM-yyyy|yyyy.MM|yyyy/MM|yyyy-MM}"
+ "{'month of'|'month'|_} {MMMMyyyy|MMMyyyy|MMMMyy|MMMyy}",
+ "{'month of'|'month'|_} {yyyyMMMM|yyyyMMM|yyMMMM|yyMMM}",
+ "{'month of'|'month'|_} {yyyyMMMM|yyyyMMM|yyMMMM|yyMMM}",
+ "{'month of'|'month'|_} {MM.yyyy|MM/yyyy|MM-yyyy|yyyy.MM|yyyy/MM|yyyy-MM}"
).flatMap(parser.expand)
val MONTH_YEAR_COUNTRY: Map[NCDateFormatType, Seq[String]] =
@@ -195,7 +195,7 @@ private[date] object NCDateConstants {
).map { case (typ, seq) ⇒ typ → seq.flatMap(parser.expand) }
val YEAR: Seq[String] = Seq(
- "'year' {'of'|*} {yyyy|yy}",
+ "'year' {'of'|_} {yyyy|yy}",
"{yy|yyyy} 'year'",
"yyyy"
).flatMap(parser.expand)
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
index 1a77bf4..8927d17 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
@@ -37,18 +37,18 @@ class NCMacroParserSpec {
// Add macros for testing...
parser.addMacro("<OF>", "{of|for|per}")
parser.addMacro("<QTY>", "{number|tally|count|quantity|amount}")
- parser.addMacro("<NUM>", "{overall|total|grand total|entire|complete|full|*} <QTY>")
- parser.addMacro("<WEBSITE>", "{html|*} {site|website|web site|web-site|web property}")
- parser.addMacro("<BY>", "{segmented|grouped|combined|arranged|organized|categorized|*} {for|by|over|along|over by}")
+ parser.addMacro("<NUM>", "{overall|total|grand total|entire|complete|full|_} <QTY>")
+ parser.addMacro("<WEBSITE>", "{html|_} {site|website|web site|web-site|web property}")
+ parser.addMacro("<BY>", "{segmented|grouped|combined|arranged|organized|categorized|_} {for|by|over|along|over by}")
parser.addMacro("<RATE>", "{rate|percentage|speed|momentum|frequency}")
parser.addMacro("<AVG>", "{avg|average} <QTY>")
- parser.addMacro("<ID>", "{unique|*} {id|guid|identifier|identification} {number|*}")
- parser.addMacro("<USER>", "{{<WEBSITE>}|web|*} {user|visitor}")
- parser.addMacro("<SES>", "{{<WEBSITE>}|web|*} {session|visit}")
- parser.addMacro("<DCM>", "{double click|double-click|doubleclick|dcm} {manager|*}")
- parser.addMacro("<PAGE>", "{{<WEBSITE>}|*} {web page|web-page|webpage|page} {path|*}")
+ parser.addMacro("<ID>", "{unique|_} {id|guid|identifier|identification} {number|_}")
+ parser.addMacro("<USER>", "{{<WEBSITE>}|web|_} {user|visitor}")
+ parser.addMacro("<SES>", "{{<WEBSITE>}|web|_} {session|visit}")
+ parser.addMacro("<DCM>", "{double click|double-click|doubleclick|dcm} {manager|_}")
+ parser.addMacro("<PAGE>", "{{<WEBSITE>}|_} {web page|web-page|webpage|page} {path|_}")
parser.addMacro("<CTR>", "{ctr|click-through-rate|{click through|click-through} <RATE>}")
- parser.addMacro("<URL>", "{{uniform|*} resource {locator|identifier}|{{<PAGE>}|*} {link|*} {uri|url|address}}")
+ parser.addMacro("<URL>", "{{uniform|_} resource {locator|identifier}|{{<PAGE>}|_} {link|_} {uri|url|address}}")
parser.addMacro("<METRICS_A>", "{analytics|statistics|measurements|analysis|report|efficiency|performance}")
parser.addMacro("<METRICS_B>", "{metrics|data|info|information|facts}")
parser.addMacro("<METRICS>","{<METRICS_A>|<METRICS_B>|<METRICS_A> <METRICS_B>|<METRICS_B> <METRICS_A>}")
@@ -94,7 +94,7 @@ class NCMacroParserSpec {
val N = 50000
for (_ ← 0 to N)
- parser.expand("a {{{<C>}}|{*}} {c|d|e|f|g|h|j|k|l|n|m|p|r}")
+ parser.expand("a {{{<C>}}|{_}} {c|d|e|f|g|h|j|k|l|n|m|p|r}")
val duration = currentTime - start
@@ -122,12 +122,12 @@ class NCMacroParserSpec {
parser.expand("<METRICS_B>")
parser.expand("<METRICS>")
- testParser("<A> {b|*} c", Seq(
+ testParser("<A> {b|_} c", Seq(
"aaa b c",
"aaa c"
))
- testParser("<B> {b|*} c", Seq(
+ testParser("<B> {b|_} c", Seq(
"aaa bbb b c",
"aaa bbb c"
))
@@ -137,14 +137,14 @@ class NCMacroParserSpec {
"j/k"
))
- testParser("a {b|*}. c", Seq(
+ testParser("a {b|_}. c", Seq(
"a b. c",
"a . c"
))
- testParser("""a {/abc.\*/|\{\*\}} c""", Seq(
+ testParser("""a {/abc.*/|\{\_\}} c""", Seq(
"a /abc.*/ c",
- "a {*} c"
+ "a {_} c"
))
testParser("""{`a`|\`a\`}""", Seq(
@@ -152,49 +152,49 @@ class NCMacroParserSpec {
"\\`a\\`"
))
- testParser("""a {/abc.\{\}\*/|/d/} c""", Seq(
+ testParser("""a {/abc.\{\}*/|/d/} c""", Seq(
"a /abc.{}*/ c",
"a /d/ c"
))
- testParser("a .{b, |*}. c", Seq(
+ testParser("a .{b, |_}. c", Seq(
"a .b, . c",
"a .. c"
))
- testParser("a {{b|c}|*}.", Seq(
+ testParser("a {{b|c}|_}.", Seq(
"a .",
"a b.",
"a c."
))
- testParser("a {{{<C>}}|{*}} c", Seq(
+ testParser("a {{{<C>}}|{_}} c", Seq(
"a aaa bbb z c",
"a aaa bbb w c",
"a c"
))
- testParser("a {b|*}", Seq(
+ testParser("a {b|_}", Seq(
"a b",
"a"
))
- testParser("a {b|*}d", Seq(
+ testParser("a {b|_}d", Seq(
"a bd",
"a d"
))
- testParser("a {b|*} d", Seq(
+ testParser("a {b|_} d", Seq(
"a b d",
"a d"
))
- testParser("a {b|*} d", Seq(
+ testParser("a {b|_} d", Seq(
"a b d",
"a d"
))
- testParser("{{{a}}} {b||*|{{*}}||*}", Seq(
+ testParser("{{{a}}} {b||_|{{_}}||_}", Seq(
"a b",
"a"
))
@@ -203,7 +203,7 @@ class NCMacroParserSpec {
"a b"
))
- testParser("a {b} {c|*}", Seq(
+ testParser("a {b} {c|_}", Seq(
"a b",
"a b c"
))
@@ -214,9 +214,9 @@ class NCMacroParserSpec {
))
ignoreNCE { testParser("a | b", Seq.empty); assertTrue(false) }
- ignoreNCE { testParser("a *", Seq.empty); assertTrue(false) }
+ ignoreNCE { testParser("a _", Seq.empty); assertTrue(false) }
ignoreNCE { testParser("a}}", Seq.empty); assertTrue(false) }
- ignoreNCE { testParser("a {a|b} *", Seq.empty); assertTrue(false) }
+ ignoreNCE { testParser("a {a|b} _", Seq.empty); assertTrue(false) }
}
@Test
@@ -226,8 +226,8 @@ class NCMacroParserSpec {
testGroup("{a}", Seq("a"))
testGroup("{{{a}}}", Seq("{{a}}"))
testGroup("{{{a}}|{b}}", Seq("{{a}}", "{b}"))
- testGroup("{a {c}|b|*}", Seq("a {c}", "b", "*"))
- testGroup("""{/abc.\*/|\{\*\}}""", Seq("/abc.\\*/", "\\{\\*\\}"))
+ testGroup("{a {c}|b|_}", Seq("a {c}", "b", "_"))
+ testGroup("""{/abc.\_/|\{\_\}}""", Seq("/abc.\\_/", "\\{\\_\\}"))
ignoreNCE { parser.parseGroup("a"); assertTrue(false) }
ignoreNCE { parser.parseGroup("{a"); assertTrue(false) }
@@ -236,11 +236,11 @@ class NCMacroParserSpec {
@Test
def testParseTokens() {
- testToken("""a \* b""", """a \* b""", "")
- testToken("""a \\\* b""", """a \\\* b""", "")
- testToken("""a \{\*\*\*\} b""", """a \{\*\*\*\} b""", "")
- testToken("""a{b\|\*\}|c}""", "a", """{b\|\*\}|c}""")
- testToken("""/\|\*\{\}/ a {bc|d}""", """/\|\*\{\}/ a """, """{bc|d}""")
+ testToken("""a \_ b""", """a \_ b""", "")
+ testToken("""a \\\_ b""", """a \\\_ b""", "")
+ testToken("""a \{\_\_\_\} b""", """a \{\_\_\_\} b""", "")
+ testToken("""a{b\|\_\}|c}""", "a", """{b\|\_\}|c}""")
+ testToken("""/\|\_\{\}/ a {bc|d}""", """/\|\_\{\}/ a """, """{bc|d}""")
testToken("{a} b", "{a}", " b")
testToken("{a|{c|d}}", "{a|{c|d}}", "")
testToken("{a {c|d} xxx {f|g}} b", "{a {c|d} xxx {f|g}}", " b")
@@ -250,7 +250,7 @@ class NCMacroParserSpec {
ignoreNCE { parser.nextToken("a } b"); assertTrue(false) }
ignoreNCE { parser.nextToken("{c b"); assertTrue(false) }
ignoreNCE { parser.nextToken("a | b"); assertTrue(false) }
- ignoreNCE { parser.nextToken("a |*"); assertTrue(false) }
+ ignoreNCE { parser.nextToken("a |_"); assertTrue(false) }
assertTrue(parser.nextToken("").isEmpty)
assertTrue(parser.nextToken(" ").isDefined)
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCEnricherNestedModelSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCEnricherNestedModelSpec.scala
index 1d2a473..9290d56 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCEnricherNestedModelSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCEnricherNestedModelSpec.scala
@@ -30,9 +30,9 @@ import java.util
class NCNestedTestModel extends NCDefaultTestModel {
override def getElements: util.Set[NCElement] =
Set(
- NCTestElement("x1", "{test|*} ^^id == 'nlpcraft:date'^^"),
- NCTestElement("x2", "{test1|*} ^^id == 'x1'^^"),
- NCTestElement("x3", "{test2|*} ^^id == 'x2'^^"),
+ NCTestElement("x1", "{test|_} ^^id == 'nlpcraft:date'^^"),
+ NCTestElement("x2", "{test1|_} ^^id == 'x1'^^"),
+ NCTestElement("x3", "{test2|_} ^^id == 'x2'^^"),
NCTestElement("y1", "y"),
NCTestElement("y2", "^^id == 'y1'^^"),
NCTestElement("y3", "^^id == 'y2'^^ ^^id == 'y2'^^")