You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by if...@apache.org on 2020/08/26 03:17:56 UTC
[incubator-nlpcraft] 01/01: NLPCRAFT-50: Initial commit
This is an automated email from the ASF dual-hosted git repository.
ifropc pushed a commit to branch NLPCRAFT-50
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit b07c88df085893d1ef3a8f1574d2ff9ec75a3f46
Author: Ifropc <if...@apache.org>
AuthorDate: Fri May 29 20:55:57 2020 -0700
NLPCRAFT-50: Initial commit
---
.../org/apache/nlpcraft/probe/NCProbeBoot.scala | 5 +--
.../nlp/enrichers/function/NCAverageEnricher.scala | 41 ++++++++++++++++++++++
.../mgrs/nlp/enrichers/limit/NCLimitEnricher.scala | 1 +
.../enrichers/function/NCEnricherAverageSpec.scala | 35 ++++++++++++++++++
4 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
index b583100..9dc017b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
@@ -18,7 +18,6 @@
package org.apache.nlpcraft.probe
import java.util.concurrent.CompletableFuture
-
import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory}
import com.typesafe.scalalogging.LazyLogging
import org.apache.nlpcraft.common.ascii.NCAsciiTable
@@ -40,6 +39,7 @@ import org.apache.nlpcraft.probe.mgrs.lifecycle.NCLifecycleManager
import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnrichmentManager
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.dictionary.NCDictionaryEnricher
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.function.NCAverageEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.limit.NCLimitEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.model.NCModelEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.relation.NCRelationEnricher
@@ -47,7 +47,6 @@ import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.sort.NCSortEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.stopword.NCStopWordEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.suspicious.NCSuspiciousNounsEnricher
import org.apache.nlpcraft.probe.mgrs.nlp.validate.NCValidateManager
-
import scala.collection.JavaConverters._
import scala.compat.Platform.currentTime
import scala.util.control.Exception.{catching, ignoring}
@@ -430,6 +429,7 @@ private [probe] object NCProbeBoot extends LazyLogging with NCOpenCensusTrace {
NCLimitEnricher.start(span)
NCSortEnricher.start(span)
NCRelationEnricher.start(span)
+ NCAverageEnricher.start(span)
NCSuspiciousNounsEnricher.start(span)
NCValidateManager.start(span)
NCDictionaryEnricher.start(span)
@@ -453,6 +453,7 @@ private [probe] object NCProbeBoot extends LazyLogging with NCOpenCensusTrace {
NCDictionaryEnricher.stop(span)
NCValidateManager.stop(span)
NCSuspiciousNounsEnricher.stop(span)
+ NCAverageEnricher.stop(span)
NCRelationEnricher.stop(span)
NCSortEnricher.stop(span)
NCLimitEnricher.stop(span)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCAverageEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCAverageEnricher.scala
new file mode 100644
index 0000000..a570ea0
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCAverageEnricher.scala
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.function
+
+import java.io
+import _root_.io.opencensus.trace.Span
+import org.apache.nlpcraft.common.nlp.NCNlpSentence
+import org.apache.nlpcraft.probe.mgrs.NCModelDecorator
+import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
+
+object NCAverageEnricher extends NCProbeEnricher {
+ /**
+ *
+ * Processes this NLP sentence.
+ *
+ * @param mdl Model decorator.
+ * @param ns NLP sentence to enrich.
+ * @param senMeta Sentence metadata.
+ * @param parent Span parent.
+ */
+ override def enrich(mdl: NCModelDecorator,
+ ns: NCNlpSentence,
+ senMeta: collection.Map[String, io.Serializable],
+ parent: Span): Unit = ???
+}
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 9e4d34f..7b9c053 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
@@ -34,6 +34,7 @@ import scala.collection.{Map, Seq, mutable}
/**
* Limit enricher.
*/
+// TODO: this enricher should (probably) extend function enricher
object NCLimitEnricher extends NCProbeEnricher {
case class Match(
limit: Double,
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCEnricherAverageSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCEnricherAverageSpec.scala
new file mode 100644
index 0000000..fdcd9de
--- /dev/null
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/function/NCEnricherAverageSpec.scala
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.function
+
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.NCEnricherBaseSpec
+import org.junit.jupiter.api.Test
+
+class NCEnricherAverageSpec extends NCEnricherBaseSpec {
+// @Test
+// def test(): Unit = {
+// runBatch(
+// _ ⇒ checkExists(
+// "show me average temperature",
+// avg(text = "average", `type` = "avg", indexes = Seq(4), note = "A", asc = false),
+// usr(text = "A", id = "A")
+// )
+// )
+// }
+}