This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-70_NEW
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-70_NEW by this push:
new 8af290b WIP.
8af290b is described below
commit 8af290bc2f5f7ad8093f6a7fc39095f35bbf7020
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Jul 8 12:21:41 2021 +0300
WIP.
---
nlpcraft/pom.xml | 1 +
.../nlp/enrichers/NCServerEnrichmentManager.scala | 44 +++++++++++-----------
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/nlpcraft/pom.xml b/nlpcraft/pom.xml
index 62d3683..46dc73a 100644
--- a/nlpcraft/pom.xml
+++ b/nlpcraft/pom.xml
@@ -232,6 +232,7 @@
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
</dependency>
+ <!-- TODO: add this library licence description. -->
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-tools</artifactId>
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
index 4094eab..dc15caf 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
@@ -92,7 +92,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
* @param srvReqId Server request ID.
* @param normTxt Normalized text.
* @param enabledBuiltInToks Enabled built-in tokens.
- * @param mlConf Machine learning configuration.
+ * @param ctxWordCatConf Machine learning configuration.
* @param parent Optional parent span.
* @return
*/
@@ -100,11 +100,11 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
srvReqId: String,
normTxt: String,
enabledBuiltInToks: Set[String],
- mlConf: Option[NCCtxWordCategoriesConfigMdo],
+ ctxWordCatConf: Option[NCCtxWordCategoriesConfigMdo],
parent: Span = null
): NCNlpSentence =
startScopedSpan("process", parent, "srvReqId" -> srvReqId, "txt" ->
normTxt) { span =>
- val s = new NCNlpSentence(srvReqId, normTxt, enabledBuiltInToks,
mlConf)
+ val s = new NCNlpSentence(srvReqId, normTxt, enabledBuiltInToks,
ctxWordCatConf)
// Server-side enrichment pipeline.
// NOTE: order of enrichers is IMPORTANT.
@@ -141,7 +141,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
* @param srvReqId Server request ID.
* @param txt Input text.
* @param enabledBuiltInToks Set of enabled built-in token IDs.
- * @param mlConf Machine learning configuration.
+ * @param ctxWordCatConf Machine learning configuration.
* @param parent Optional parent span.
*/
@throws[NCE]
@@ -149,7 +149,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
srvReqId: String,
txt: String,
enabledBuiltInToks: Set[String],
- mlConf: Option[NCCtxWordCategoriesConfigMdo],
+ ctxWordCatConf: Option[NCCtxWordCategoriesConfigMdo],
parent: Span = null
): NCNlpSentence = {
startScopedSpan("enrichPipeline", parent, "srvReqId" -> srvReqId,
"txt" -> txt) { span =>
@@ -158,23 +158,25 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
if (normTxt != txt)
logger.info(s"Sentence normalized: $normTxt")
- val normEnabledBuiltInToks = enabledBuiltInToks.map(_.toLowerCase)
-
- catching(wrapIE) {
- cache(normTxt) match {
- case Some(h) =>
- // TODO: remove
-// if (h.enabledBuiltInTokens ==
normEnabledBuiltInToks) {
-// prepareAsciiTable(h.sentence).info(logger,
Some(s"Sentence enriched (from cache): '$normTxt'"))
-//
-// h.sentence
-// }
-// else
- process(srvReqId, normTxt, enabledBuiltInToks,
mlConf, span)
- case None =>
- process(srvReqId, normTxt, enabledBuiltInToks, mlConf,
span)
+ def execute(): NCNlpSentence = process(srvReqId, normTxt,
enabledBuiltInToks, ctxWordCatConf, span)
+
+ if (U.isSysEnvSet("NLPCRAFT_DISABLE_SENTENCE_CACHE"))
+ execute()
+ else
+ catching(wrapIE) {
+ cache(normTxt) match {
+ case Some(h) =>
+ if (h.enabledBuiltInTokens ==
enabledBuiltInToks.map(_.toLowerCase)) {
+ prepareAsciiTable(h.sentence).info(logger,
Some(s"Sentence enriched (from cache): '$normTxt'"))
+
+ h.sentence
+ }
+ else
+ execute()
+ case None =>
+ execute()
+ }
}
- }
}
}