This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new cd6788f Renaming.
cd6788f is described below
commit cd6788f728560803446a356784042c553db9d8ec
Author: Aaron Radzinski <[email protected]>
AuthorDate: Fri Mar 18 08:14:42 2022 -0700
Renaming.
---
.../examples/lightswitch/LightSwitchRuModel.scala | 12 +-----------
.../examples/lightswitch/LightSwitchGroovyModel.groovy | 4 ++--
.../examples/lightswitch/LightSwitchJavaModel.java | 2 +-
.../examples/lightswitch/LightSwitchKotlinModel.kt | 2 +-
.../examples/lightswitch/LightSwitchScalaModel.scala | 2 +-
.../org/apache/nlpcraft/examples/time/TimeModel.java | 2 +-
.../org/apache/nlpcraft/NCModelPipelineBuilder.java | 8 ++++----
.../nlpcraft/internal/impl/NCModelPipelineManager.scala | 17 +++++++++--------
...chmark.java => NCEnOpenNLPTokenParserBenchmark.java} | 4 ++--
9 files changed, 22 insertions(+), 31 deletions(-)
diff --git
a/nlpcraft-examples/lightswitch-ru/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
b/nlpcraft-examples/lightswitch-ru/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
index c735c2c..d4736c6 100644
---
a/nlpcraft-examples/lightswitch-ru/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
+++
b/nlpcraft-examples/lightswitch-ru/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
@@ -31,15 +31,7 @@ import java.util
import scala.jdk.CollectionConverters.*
/**
- * This example provides very simple implementation for NLI-powered light
switch.
- * You can say something like this:
- * <ul>
- * <li>"Turn the lights off in the entire house."</li>
- * <li>"Switch on the illumination in the master bedroom closet."</li>
- * </ul>
- * You can easily modify intent callbacks to perform the actual light
switching using
- * HomeKit or Arduino-based controllers.
- * <p>
+ *
* See 'README.md' file in the same folder for running and testing
instructions.
*/
class LightSwitchRuModel extends NCModelAdapter(
@@ -82,9 +74,7 @@ class LightSwitchRuModel extends NCModelAdapter(
val locations = if locEnts.isEmpty then "весь дом" else
locEnts.map(_.mkText()).mkString(", ")
// Add HomeKit, Arduino or other integration here.
-
// By default - just return a descriptive action string.
-
new NCResult(
new Gson().toJson(Map("locations" -> locations, "action" ->
action).asJava),
NCResultType.ASK_RESULT
diff --git
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
index 722d2c1..7beb104 100644
---
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
+++
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
@@ -35,7 +35,7 @@ class LightSwitchGroovyModel extends NCModelAdapter {
LightSwitchGroovyModel() {
super(
new NCModelConfig("nlpcraft.lightswitch.java.ex", "LightSwitch
Example Model", "1.0"),
- new NCModelPipelineBuilder().withSemantic("EN",
"lightswitch_model.yaml").build()
+ new NCModelPipelineBuilder().withSemantic("en",
"lightswitch_model.yaml").build()
)
}
@@ -71,7 +71,7 @@ class LightSwitchGroovyModel extends NCModelAdapter {
"Light up the garage, please!",
"Kill the illumination now!"
])
- NCResult onMatch(
+ static NCResult onMatch(
@NCIntentTerm("act") NCEntity actEnt,
@NCIntentTerm("loc") List<NCEntity> locEnts) {
String status = actEnt.id == "ls:on" ? "on" : "off"
diff --git
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
index eb050a8..d09eb95 100644
---
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
+++
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
@@ -38,7 +38,7 @@ public class LightSwitchJavaModel extends NCModelAdapter {
public LightSwitchJavaModel() {
super(
new NCModelConfig("nlpcraft.lightswitch.java.ex", "LightSwitch
Example Model", "1.0"),
- new NCModelPipelineBuilder().withSemantic("EN",
"lightswitch_model.yaml").build()
+ new NCModelPipelineBuilder().withSemantic("en",
"lightswitch_model.yaml").build()
);
}
diff --git
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
index 0082944..26a500f 100644
---
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
+++
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
@@ -37,7 +37,7 @@ import java.util.stream.Collectors
*/
class LightSwitchKotlinModel : NCModelAdapter(
NCModelConfig("nlpcraft.lightswitch.kotlin.ex", "LightSwitch Example
Model", "1.0"),
- NCModelPipelineBuilder().withSemantic("EN",
"lightswitch_model.yaml").build()
+ NCModelPipelineBuilder().withSemantic("en",
"lightswitch_model.yaml").build()
) {
/**
* Intent and its on-match callback.
diff --git
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
index 0852975..8f39229 100644
---
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
+++
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
@@ -40,7 +40,7 @@ import
org.apache.nlpcraft.nlp.token.parser.NCOpenNLPTokenParser
class LightSwitchScalaModel extends NCModelAdapter(
new NCModelConfig("nlpcraft.lightswitch.java.ex", "LightSwitch Example
Model", "1.0"),
- new NCModelPipelineBuilder().withSemantic("EN",
"lightswitch_model.yaml").build()
+ new NCModelPipelineBuilder().withSemantic("en",
"lightswitch_model.yaml").build()
):
/**
* Intent and its on-match callback.
diff --git
a/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
b/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
index 723825b..b03e952 100644
---
a/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
+++
b/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
@@ -78,7 +78,7 @@ public class TimeModel extends NCModelAdapter {
super(
new NCModelConfig("nlpcraft.time.ex", "Time Example Model", "1.0"),
new NCModelPipelineBuilder().
- withSemantic("EN", "time_model.yaml").
+ withSemantic("en", "time_model.yaml").
withEntityParser(new
NCOpenNLPEntityParser(NCResourceReader.getPath("opennlp/en-ner-location.bin"))).
build()
);
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
index 2efb746..4049bb6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
@@ -67,7 +67,7 @@ public class NCModelPipelineBuilder {
*
* @return
*/
- private NCOpenNLPTokenParser mkEnOpenNlpTokenParser() {
+ private NCOpenNLPTokenParser mkEnOpenNLPTokenParser() {
return new
NCOpenNLPTokenParser(NCResourceReader.getPath("opennlp/en-token.bin"));
}
@@ -224,7 +224,7 @@ public class NCModelPipelineBuilder {
*
*/
private void setEnComponents() {
- tokParser = mkEnOpenNlpTokenParser();
+ tokParser = mkEnOpenNLPTokenParser();
tokEnrichers.add(new NCOpenNLPLemmaPosTokenEnricher(
NCResourceReader.getPath("opennlp/en-pos-maxent.bin"),
@@ -255,7 +255,7 @@ public class NCModelPipelineBuilder {
case "EN":
setEnComponents();
- this.entParsers.add(new NCSemanticEntityParser(mkEnStemmer(),
mkEnOpenNlpTokenParser(), macros, elms));
+ this.entParsers.add(new NCSemanticEntityParser(mkEnStemmer(),
mkEnOpenNLPTokenParser(), macros, elms));
break;
@@ -290,7 +290,7 @@ public class NCModelPipelineBuilder {
case "EN":
setEnComponents();
- this.entParsers.add(new NCSemanticEntityParser(mkEnStemmer(),
mkEnOpenNlpTokenParser(), src));
+ this.entParsers.add(new NCSemanticEntityParser(mkEnStemmer(),
mkEnOpenNLPTokenParser(), src));
break;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
index 35a02ac..2b0dc51 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
@@ -59,19 +59,20 @@ class NCModelPipelineManager(cfg: NCModelConfig, pipeline:
NCModelPipeline) exte
private val entVals = nvl(pipeline.getEntityValidators)
private val varFilterOpt = pipeline.getVariantFilter.toScala
- private val allSrvs: Seq[NCLifecycle] =
+ private val allComps: Seq[NCLifecycle] =
tokEnrichers ++ entEnrichers ++ entParsers ++ tokVals ++ entVals ++
varFilterOpt.toSeq
/**
+ * Processes pipeline components.
*
- * @param act
- * @param actVerb
+ * @param act Action to process.
+ * @param actVerb Action descriptor.
*/
- private def processServices(act: NCLifecycle => Unit, actVerb: String):
Unit =
- NCUtils.execPar(allSrvs.map(p =>
+ private def processComponents(act: NCLifecycle => Unit, actVerb: String):
Unit =
+ NCUtils.execPar(allComps.map(p =>
() => {
act(p)
- logger.info(s"Service $actVerb: '${p.getClass.getName}'")
+ logger.info(s"Component $actVerb: '${p.getClass.getName}'")
}
)*)(ExecutionContext.Implicits.global)
@@ -187,10 +188,10 @@ class NCModelPipelineManager(cfg: NCModelConfig,
pipeline: NCModelPipeline) exte
NCPipelineData(req, vrnts, toks)
- def start(): Unit = processServices(_.onStart(cfg), "started")
+ def start(): Unit = processComponents(_.onStart(cfg), "started")
/**
*
*/
def close(): Unit =
- processServices(_.onStop(cfg), "stopped")
+ processComponents(_.onStop(cfg), "stopped")
NCUtils.shutdownPool(pool)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNlpTokenParserBenchmark.java
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNLPTokenParserBenchmark.java
similarity index 96%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNlpTokenParserBenchmark.java
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNLPTokenParserBenchmark.java
index d9dae4e..33581d1 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNlpTokenParserBenchmark.java
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/benchmark/token/parser/opennlp/NCEnOpenNLPTokenParserBenchmark.java
@@ -47,7 +47,7 @@ import java.util.concurrent.TimeUnit;
@Fork(value = 1, jvmArgs = {"-Xms2G", "-Xmx2G"})
@Warmup(iterations = 5, time = 10)
@Measurement(iterations = 5, time = 5)
-public class NCEnOpenNlpTokenParserBenchmark {
+public class NCEnOpenNLPTokenParserBenchmark {
@State(Scope.Thread)
public static class NCBenchmarkAdapterState {
final NCRequest request = NCTestRequest.apply(
@@ -68,6 +68,6 @@ public class NCEnOpenNlpTokenParserBenchmark {
}
public static void main(String[] args) throws RunnerException {
- new Runner(new
OptionsBuilder().include(NCEnOpenNlpTokenParserBenchmark.class.getSimpleName()).shouldFailOnError(true).build()).run();
+ new Runner(new
OptionsBuilder().include(NCEnOpenNLPTokenParserBenchmark.class.getSimpleName()).shouldFailOnError(true).build()).run();
}
}