nlpcraft-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sergeyka...@apache.org
Subject [incubator-nlpcraft] branch NLPCRAFT-383 updated: WIP.
Date Wed, 08 Sep 2021 06:16:48 GMT
This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-383
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-383 by this push:
     new 7562377  WIP.
7562377 is described below

commit 756237772ed62b852ce3faf2485053ac73031451
Author: Sergey Kamov <skhdlemail@gmail.com>
AuthorDate: Wed Sep 8 09:16:10 2021 +0300

    WIP.
---
 .../intents/SolarSystemNumConditions.scala         | 45 ++++++++++++++++++++++
 .../src/main/resources/solarsystem_model.yaml      | 12 +++++-
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/intents/SolarSystemNumConditions.scala
b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/intents/SolarSystemNumConditions.scala
new file mode 100644
index 0000000..9ea6cf5
--- /dev/null
+++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/intents/SolarSystemNumConditions.scala
@@ -0,0 +1,45 @@
+/*
+ * 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.examples.solarsystem.intents
+
+import org.apache.nlpcraft.examples.solarsystem.api.SolarSystemOpenApiService
+import org.apache.nlpcraft.model.{NCIntent, NCIntentSample, NCIntentTerm, NCResult, NCToken}
+
+class SolarSystemNumConditions {
+    @NCIntentSample(
+        Array(
+            "Planets with mass more 10",
+        )
+    )
+    @NCIntent(
+        "intent=aggregate " +
+        "    term(condition)={^^{tok_group == 'propNum'}^^ ^^{# == 'nlpcraft:num' &&
meta_tok('nlpcraft:num:unit') == null}^^}"
+    )
+    def discoverer(@NCIntentTerm("condition") cond: NCToken): NCResult = {
+        val s: String = cond.getMetadata.get("").asInstanceOf[String]
+
+        NCResult.text(
+            SolarSystemOpenApiService.
+                getInstance().
+                bodyRequest().
+                withFilter(s, "cs", cond.getNormalizedText).
+                execute().
+                toString()
+        )
+    }
+}
\ No newline at end of file
diff --git a/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml b/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml
index 996070c..e47e9f8 100644
--- a/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml
+++ b/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml
@@ -43,21 +43,29 @@ elements:
   - id: "prop:mass"
     groups:
       - "prop"
+      - "propNum"
     description: "..."
+    metadata:
+      filterName: "mass"
     synonyms:
       - "mass"
 
   - id: "prop:radius"
     groups:
       - "prop"
+      - "propNum"
     description: "..."
+    metadata:
+      filterName: "meanRadius"
     synonyms:
-      - "mass"
+      - "radius"
 
   - id: "prop:temperature"
     groups:
-      - "prop"
+      - "propNum"
     description: "..."
+    metadata:
+      filterName: "avgTemp"
     synonyms:
       - "{temperature|average temperature}"
 

Mime
View raw message