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/02/09 03:30:16 UTC

[incubator-nlpcraft] branch NLPCRAFT-91 updated (e669c79 -> f019be3)

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

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


 discard e669c79  NLPCRAFT-91: fill command draft
     new f019be3  NLPCRAFT-91: fill command draft

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e669c79)
            \
             N -- N -- N   refs/heads/NLPCRAFT-91 (f019be3)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


[incubator-nlpcraft] 01/01: NLPCRAFT-91: fill command draft

Posted by if...@apache.org.
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 f019be34bfff5658e460488468e8bfa2b9450e5f
Author: Ifropc <if...@apache.org>
AuthorDate: Mon Feb 8 19:27:52 2021 -0800

    NLPCRAFT-91: fill command draft
---
 .../org/apache/nlpcraft/example/MinecraftModel.kt  | 15 ++++-
 .../org/apache/nlpcraft/example/ValueLoaders.kt    |  2 +-
 .../src/main/resources/{blocks.json => block.json} |  0
 .../src/main/resources/minecraft.yaml              | 66 +++++++++++++++++++---
 4 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
index 9e476d2..73456f6 100644
--- a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
+++ b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
@@ -23,9 +23,9 @@ import org.apache.nlpcraft.example.MinecraftObjectValueLoader.Companion.dumps
 import org.apache.nlpcraft.model.*
 import java.util.*
 
+@Suppress("unused")
 class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     @NCIntentRef("weatherIntent")
-    @Suppress("unused")
     fun onWeatherMatch(ctx: NCIntentMatch, @NCIntentTerm("arg") tok: NCToken): NCResult {
         if (ctx.isAmbiguous) {
             throw NCRejection("Ambiguous request")
@@ -35,7 +35,6 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     }
 
     @NCIntentRef("timeIntent")
-    @Suppress("unused")
     fun onTimeMatch(ctx: NCIntentMatch, @NCIntentTerm("arg") tok: NCToken): NCResult {
         if (ctx.isAmbiguous) {
             throw NCRejection("Ambiguous request")
@@ -55,7 +54,6 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     }
 
     @NCIntentRef("giveIntent")
-    @Suppress("unused")
     fun onGiveMatch(
         ctx: NCIntentMatch,
         @NCIntentTerm("item") item: NCToken,
@@ -77,6 +75,17 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
         return NCResult.text("give $player $itemRegistry $itemQuantity")
     }
 
+    @NCIntentRef("fillIntent")
+    fun onFillMatch(
+        ctx: NCIntentMatch,
+        @NCIntentTerm("shape") shape: NCToken,
+        @NCIntentTerm("block") block: NCToken,
+        @NCIntentTerm("len") length: NCToken,
+        @NCIntentTerm("position") position: NCToken,
+    ): NCResult {
+        TODO()
+    }
+
     private fun NCToken.normText(): String {
         return this.meta("nlpcraft:nlp:normtext")
     }
diff --git a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/ValueLoaders.kt b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/ValueLoaders.kt
index 989371e..e664afb 100644
--- a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/ValueLoaders.kt
+++ b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/ValueLoaders.kt
@@ -13,7 +13,7 @@ class MinecraftObjectValueLoader : NCValueLoader {
     }
 
     override fun load(owner: NCElement?): MutableSet<NCValue> {
-        val type = owner!!.metax<String>("minecraft:type")
+        val type = owner!!.metax<String>("mc:type")
 
         val inputStream = NCModelFileAdapter::class.java.classLoader.getResourceAsStream("${type}.json")
             ?: throw NCException("Minecraft object dump not found: ${type}.json")
diff --git a/nlpcraft-examples/minecraft-model/src/main/resources/blocks.json b/nlpcraft-examples/minecraft-model/src/main/resources/block.json
similarity index 100%
rename from nlpcraft-examples/minecraft-model/src/main/resources/blocks.json
rename to nlpcraft-examples/minecraft-model/src/main/resources/block.json
diff --git a/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml b/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
index d56e05a..708f67d 100644
--- a/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
+++ b/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
@@ -20,7 +20,27 @@ name: Minecraft Model
 version: '1.0'
 description: Minecraft Model.
 
+macros:
+# Doesn't work with fill
+#  - name: "<PLAYER_NAME>"
+#    macro: "{me|I|my|//[a-zA-Z0-9]+//}"
+  - name: "<PLAYER_NAME>"
+    macro: "{me|I|my}"
+
 elements:
+  # General synonyms
+  - id: mc:player
+    synonyms:
+      - "<PLAYER_NAME>"
+  - id: mc:item
+    metadata:
+      mc:type: item
+    valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
+  - id: mc:block
+    metadata:
+      mc:type: block
+    valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
+
   # Weather intent
   - id: rain
     description: Set rain weather
@@ -77,20 +97,52 @@ elements:
   - id: give:action
     synonyms:
       - "{give}"
-  - id: give:target
+
+  # Fill intent
+  - id: fill:action
     synonyms:
-      - "{me|//[a-zA-Z0-9]+//}"
-  - id: give:item
-    metadata:
-      minecraft:type: item
-    valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
+      - "{fill|make|create}"
+  - id: cube
+    groups:
+      - fill:shape
+  - id: sphere
+    groups:
+      - fill:shape
+  - id: square
+    groups:
+      - fill:shape
+    synonyms:
+      - "{box|rectangle}"
+  - id: line
+    groups:
+      - fill:shape
+    synonyms:
+      - "wall"
+  - id: fill:length
+    synonyms:
+      - "{size of?|length of?|diameter of?}"
+  - id: position:player
+    groups:
+      - fill:position
+    synonyms:
+      - "{{at|near} <PLAYER_NAME> position?|where <PLAYER_NAME>}"
+  - id: position:front
+    groups:
+      - fill:position
+    synonyms:
+      - "{{^^[distance](id == 'nlpcraft:num')^^ m|meter|meters|ft|feet}? in? front of? <PLAYER_NAME>}"
+
+
 
 
 # List of model intents.
 intents:
   - intent=weatherIntent term(arg)={groups @@ 'weather'}
   - intent=timeIntent term(arg)={groups @@ 'time'}
-  - intent=giveIntent term(action)={id == 'give:action'} term(target)={id == 'give:target'} term(quantity)={id == 'nlpcraft:num'}? term(item)={id == 'give:item'}
+  - "intent=giveIntent term(action)={id == 'give:action'} term(target)={id == 'mc:player'}
+  term(quantity)={id == 'nlpcraft:num'}? term(item)={id == 'mc:item'}"
+  - "intent=fillIntent term={id == 'fill:action'} term(shape)={groups @@ 'fill:shape'} term(block)={id == 'mc:block'}
+  term={id == 'fill:length'}? term(len)={id == 'nlpcraft:num'} term(position)={groups @@ 'fill:position'}"
 
 # give me sand
 swearWordsAllowed: true