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:28:08 UTC
[incubator-nlpcraft] branch NLPCRAFT-91 updated (91fb357 -> e669c79)
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.
from 91fb357 NLPCRAFT-91: "Give" supports player target and quantity
new 523cbb2 Update README
new e669c79 NLPCRAFT-91: fill command draft
The 2 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/README.md | 1 +
.../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 | 64 +++++++++++++++++++---
5 files changed, 71 insertions(+), 11 deletions(-)
rename nlpcraft-examples/minecraft-model/src/main/resources/{blocks.json => block.json} (100%)
[incubator-nlpcraft] 02/02: 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 e669c79365fbaa36ac944ef2d8cb74021aecb106
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 | 64 +++++++++++++++++++---
4 files changed, 70 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..d642feb 100644
--- a/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
+++ b/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
@@ -20,7 +20,25 @@ name: Minecraft Model
version: '1.0'
description: Minecraft Model.
+macros:
+ - name: "<PLAYER_NAME>"
+ macro: "{me|//[a-zA-Z0-9]+//}"
+# TODO: support player name
+
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 +95,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
[incubator-nlpcraft] 01/02: Update README
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 523cbb278e28256dc2ff6aeeadbed56c3c290ef4
Author: Ifropc <if...@apache.org>
AuthorDate: Mon Feb 8 17:32:53 2021 -0800
Update README
---
nlpcraft-examples/minecraft-model/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/nlpcraft-examples/minecraft-model/README.md b/nlpcraft-examples/minecraft-model/README.md
index 67b5002..348cd79 100644
--- a/nlpcraft-examples/minecraft-model/README.md
+++ b/nlpcraft-examples/minecraft-model/README.md
@@ -49,6 +49,7 @@ on client side, prefixed with slash (`/make it sunny`)
| :---: |:---:|
`/weather` | Make it rain |
`/time` | Set current time to evening |
+`/give` | Give me iron sword |
### Copyright
Copyright (C) 2020 Apache Software Foundation