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 2021/03/19 01:57:57 UTC

[incubator-nlpcraft] 02/27: NLPCRAFT-91: Base stubs for Minecraft example

This is an automated email from the ASF dual-hosted git repository.

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

commit 6b962c1b740ba7db040061a6a80151227a0985f5
Author: Ifropc <if...@apache.org>
AuthorDate: Thu Dec 17 22:35:40 2020 -0800

    NLPCRAFT-91: Base stubs for Minecraft example
---
 .../example/{Example.kt => MinecraftModel.kt}       | 21 ++++++++++++++++++---
 nlpcraft-examples/src/main/resources/minecraft.yaml | 21 +++++++++++++++++++++
 .../org/apache/nlpcraft/example/ExampleTest.kt      |  2 --
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/Example.kt b/nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
similarity index 60%
rename from nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/Example.kt
rename to nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
index 2591725..4f5593f 100644
--- a/nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/Example.kt
+++ b/nlpcraft-examples/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
@@ -18,6 +18,21 @@
 
 package org.apache.nlpcraft.example
 
-fun testExample() {
-    print("Test")
-}
\ No newline at end of file
+import org.apache.nlpcraft.model.*
+
+class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
+
+    @NCIntentRef("intentId")
+    fun onMatch(ctx: NCIntentMatch, @NCIntentTerm("element") tok: NCToken): NCResult {
+        // TODO: add the actual intent logic here.
+
+        // As a placeholder - just return an echo string.
+        return NCResult.text(
+            String.format(
+                "Word `%s` found in text: `%s`",
+                tok.originalText,
+                ctx.context.request.normalizedText
+            )
+        )
+    }
+}
diff --git a/nlpcraft-examples/src/main/resources/minecraft.yaml b/nlpcraft-examples/src/main/resources/minecraft.yaml
new file mode 100644
index 0000000..0306294
--- /dev/null
+++ b/nlpcraft-examples/src/main/resources/minecraft.yaml
@@ -0,0 +1,21 @@
+# Mandatory model configuration.
+id: minecraft
+name: Minecraft Model
+version: '1.0'
+description: Minecraft Model.
+
+# List of macros, if any.
+macros:
+  - name: "<MY_MACRO>"
+    macro: "{word1|word2}"
+
+# List of model elements.
+elements:
+  - id: elementId
+    description: An element.
+    synonyms:
+      - "{some|*} <MY_MACRO>"
+
+# List of model intents.
+intents:
+  - intent=intentId term(element)={id == 'elementId'}
diff --git a/nlpcraft-examples/src/test/kotlin/org/apache/nlpcraft/example/ExampleTest.kt b/nlpcraft-examples/src/test/kotlin/org/apache/nlpcraft/example/ExampleTest.kt
index 6b25e48..e1b4271 100644
--- a/nlpcraft-examples/src/test/kotlin/org/apache/nlpcraft/example/ExampleTest.kt
+++ b/nlpcraft-examples/src/test/kotlin/org/apache/nlpcraft/example/ExampleTest.kt
@@ -24,8 +24,6 @@ import org.junit.jupiter.api.Test
 class ExampleTest {
     @Test
     fun testPass() {
-        testExample()
-
         Assertions.assertTrue(true)
     }
 }