You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/04/27 07:54:17 UTC

[incubator-nlpcraft] branch master updated (4e7131a -> 1be41b4)

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

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


    from 4e7131a  Configuration processing fixed.
     new 4a3f316  WIP.
     new e8e463a  Merge branch 'master' of https://github.com/apache/incubator-nlpcraft
     new 1be41b4  WIP.

The 3 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:
 ...Processor.kt => MinecraftFIllMatchProcessor.kt} | 23 ++++++++++++----------
 .../nlpcraft/example/minecraft/MinecraftModel.kt   | 20 ++++++++++++++++---
 .../minecraft/{Utils.kt => MinecraftUtils.kt}      | 15 +++++++++-----
 .../{ValueLoaders.kt => MinecraftValueLoader.kt}   |  2 +-
 .../minecraft/src/main/resources/minecraft.yaml    |  6 +++---
 5 files changed, 44 insertions(+), 22 deletions(-)
 rename nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/{FIllMatchProcessor.kt => MinecraftFIllMatchProcessor.kt} (86%)
 rename nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/{Utils.kt => MinecraftUtils.kt} (88%)
 rename nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/{ValueLoaders.kt => MinecraftValueLoader.kt} (98%)

[incubator-nlpcraft] 02/03: Merge branch 'master' of https://github.com/apache/incubator-nlpcraft

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e8e463ab6150932fe07a7f729e4f6e08977f83c2
Merge: 4a3f316 4e7131a
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Tue Apr 27 10:42:23 2021 +0300

    Merge branch 'master' of https://github.com/apache/incubator-nlpcraft

 .../nlpcraft/common/config/NCConfigurable.scala    | 59 ++++++++++++----------
 .../org/apache/nlpcraft/common/util/NCUtils.scala  | 26 ++++++++++
 .../org/apache/nlpcraft/probe/NCProbeBoot.scala    | 13 ++---
 .../org/apache/nlpcraft/server/NCServer.scala      | 10 ++--
 4 files changed, 66 insertions(+), 42 deletions(-)

[incubator-nlpcraft] 03/03: WIP.

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1be41b43a913c1301eea99576d7ffc1d0f37df2b
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Tue Apr 27 10:53:17 2021 +0300

    WIP.
---
 ...hProcessor.kt => MinecraftFIllMatchProcessor.kt} | 21 ++++++++++++---------
 .../nlpcraft/example/minecraft/MinecraftModel.kt    | 18 ++++++++++++++++--
 .../minecraft/{Utils.kt => MinecraftUtils.kt}       |  9 +++++++++
 ...craftValueLoaders.kt => MinecraftValueLoader.kt} |  0
 .../minecraft/src/main/resources/minecraft.yaml     |  6 +++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftFIllMatchProcessor.kt
similarity index 88%
rename from nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt
rename to nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftFIllMatchProcessor.kt
index 376d554..1890fea 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftFIllMatchProcessor.kt
@@ -22,10 +22,12 @@ import org.apache.nlpcraft.example.minecraft.MinecraftValueLoader.Companion.dump
 import org.apache.nlpcraft.model.*
 import java.util.*
 
-class FIllMatchProcessor {
+/**
+ * Utility fill processor.
+ */
+class MinecraftFIllMatchProcessor {
     companion object {
         fun process(
-            ctx: NCIntentMatch,
             @NCIntentTerm("shape") shape: NCToken,
             @NCIntentTerm("block") blockToken: NCToken,
             @NCIntentTerm("len") length: Optional<NCToken>,
@@ -50,15 +52,15 @@ class FIllMatchProcessor {
                     Coordinate((length - 1) / 2, 0, (length - 1) / 2)
                 "cube" -> Coordinate(-length / 2, -length / 2, -length / 2) to
                     Coordinate((length - 1) / 2, (length - 1) / 2, (length - 1) / 2)
-                else -> throw NCRejection("Unsupported shape")
+                else -> throw NCRejection("Unsupported shape: $shape")
             }
         }
 
-        private fun positionCoordinate(position: NCToken): Coordinate {
-            return when (position.id) {
+        private fun positionCoordinate(pos: NCToken): Coordinate {
+            return when (pos.id) {
                 "position:player" -> Coordinate()
-                "position:front" -> Coordinate(0, 0, transformLength(Optional.of(position), 10))
-                else -> throw NCRejection("Unsupported position")
+                "position:front" -> Coordinate(0, 0, transformLength(Optional.of(pos), 10))
+                else -> throw NCRejection("Unsupported position: ${pos.id}")
             }
         }
 
@@ -68,14 +70,15 @@ class FIllMatchProcessor {
                     .filter { it.id == "nlpcraft:num" }
                     .findAny()
                     .map { it.toInt() }
-            }.orElse(default)
+            }
+            .orElse(default)
         }
 
         private fun findPlayer(position: NCToken): String {
             return position.partTokens.stream()
                 .filter { it.id == "mc:player" }
                 .findAny()
-                .orElseThrow { AssertionError("Player wasn't found") }
+                .orElseThrow { AssertionError("Player wasn't found.") }
                 .player()
         }
     }
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
index fd1abe5..ae218fe 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
@@ -23,8 +23,14 @@ import org.apache.nlpcraft.example.minecraft.MinecraftValueLoader.Companion.dump
 import org.apache.nlpcraft.model.*
 import java.util.*
 
+/**
+ * Minecraft example model.
+ */
 @Suppress("unused")
 class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
+    /**
+     * Weather intent callback.
+     */
     @NCIntentRef("weatherIntent")
     @NCIntentSample(
         "make it rain",
@@ -40,6 +46,9 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
         return NCResult.text("weather ${tok.id}")
     }
 
+    /**
+     * Time intent callback.
+     */
     @NCIntentRef("timeIntent")
     @NCIntentSample(
         "set time to evening",
@@ -65,6 +74,9 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
         return NCResult.text("time set $time")
     }
 
+    /**
+     * Give intent callback.
+     */
     @NCIntentRef("giveIntent")
     @NCIntentSample(
         "give me iron sword",
@@ -90,12 +102,14 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
         return NCResult.text("give $player $itemRegistry $itemQuantity")
     }
 
+    /**
+     * Fill intent callback.
+     */
     @NCIntentRef("fillIntent")
     @NCIntentSample(
         "make a box of sand in front of me",
         "make a cube of gold near me",
         "make a line of grass with length of 2 near me",
-
         "create a rectangle of dirt in front of #PlayerName",
         "make a box of sand with the size of 2 10 meters in front of me"
     )
@@ -106,6 +120,6 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
         @NCIntentTerm("len") length: Optional<NCToken>,
         @NCIntentTerm("position") position: NCToken,
     ): NCResult {
-        return FIllMatchProcessor.process(ctx, shape, block, length, position)
+        return MinecraftFIllMatchProcessor.process(shape, block, length, position)
     }
 }
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftUtils.kt
similarity index 97%
rename from nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt
rename to nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftUtils.kt
index e469f74..8fab25e 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftUtils.kt
@@ -22,14 +22,23 @@ import org.apache.nlpcraft.model.NCToken
 
 private var firstPersonWords = setOf("me", "my", "i")
 
+/**
+ *
+ */
 internal fun NCToken.toInt(): Int {
     return this.meta<Double>("nlpcraft:num:from").toInt()
 }
 
+/**
+ *
+ */
 internal fun NCToken.player(): String {
     return if (firstPersonWords.contains(this.normalizedText)) "@p" else this.originalText ?: "@p"
 }
 
+/**
+ *
+ */
 internal data class Coordinate(val x: Int = 0, val y: Int = 0, val z: Int = 0) {
     override fun toString(): String {
         return "$x $y $z"
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoaders.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoader.kt
similarity index 100%
rename from nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoaders.kt
rename to nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoader.kt
diff --git a/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml b/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
index 57eed4e..5d0a844 100644
--- a/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
+++ b/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
@@ -25,7 +25,7 @@ description: Minecraft Model.
 
 macros:
   - name: "<PLAYER_NICKNAME>"
-    macro: "//[a-zA-Z0-9]+//"
+    macro: "{//[a-zA-Z0-9]+//}"
 
 elements:
   # General synonyms
@@ -35,11 +35,11 @@ elements:
   - id: mc:item
     metadata:
       mc:type: item
-    valueLoader: org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader
+    valueLoader: org.apache.nlpcraft.example.minecraft.MinecraftValueLoader
   - id: mc:block
     metadata:
       mc:type: block
-    valueLoader: org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader
+    valueLoader: org.apache.nlpcraft.example.minecraft.MinecraftValueLoader
 
   # Weather intent
   - id: weather:action

[incubator-nlpcraft] 01/03: WIP.

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4a3f316c4aa83cf5fea4740282c9ce9adddcc149
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Tue Apr 27 10:42:10 2021 +0300

    WIP.
---
 .../org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt     | 2 +-
 .../kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt  | 2 +-
 .../example/minecraft/{ValueLoaders.kt => MinecraftValueLoaders.kt} | 2 +-
 .../src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt  | 6 +-----
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt
index f576a52..376d554 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/FIllMatchProcessor.kt
@@ -18,7 +18,7 @@
 
 package org.apache.nlpcraft.example.minecraft
 
-import org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader.Companion.dumps
+import org.apache.nlpcraft.example.minecraft.MinecraftValueLoader.Companion.dumps
 import org.apache.nlpcraft.model.*
 import java.util.*
 
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
index 58dfe74..fd1abe5 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftModel.kt
@@ -19,7 +19,7 @@
 package org.apache.nlpcraft.example.minecraft
 
 import org.apache.nlpcraft.common.NCException
-import org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader.Companion.dumps
+import org.apache.nlpcraft.example.minecraft.MinecraftValueLoader.Companion.dumps
 import org.apache.nlpcraft.model.*
 import java.util.*
 
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/ValueLoaders.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoaders.kt
similarity index 98%
rename from nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/ValueLoaders.kt
rename to nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoaders.kt
index 89b44e3..4191bfe 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/ValueLoaders.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/MinecraftValueLoaders.kt
@@ -26,7 +26,7 @@ import org.apache.nlpcraft.model.NCModelFileAdapter
 import org.apache.nlpcraft.model.NCValue
 import org.apache.nlpcraft.model.NCValueLoader
 
-class MinecraftObjectValueLoader : NCValueLoader {
+class MinecraftValueLoader : NCValueLoader {
     private data class Dump(val version: String, val data: Map<String, String>)
 
     private class NCMinecraftValue(private var name: String, private var registry: String) : NCValue {
diff --git a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt
index 31fdf47..e469f74 100644
--- a/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt
+++ b/nlpcraft-examples/minecraft/src/main/kotlin/org/apache/nlpcraft/example/minecraft/Utils.kt
@@ -22,16 +22,12 @@ import org.apache.nlpcraft.model.NCToken
 
 private var firstPersonWords = setOf("me", "my", "i")
 
-internal fun NCToken.normText(): String {
-    return this.meta("nlpcraft:nlp:normtext")
-}
-
 internal fun NCToken.toInt(): Int {
     return this.meta<Double>("nlpcraft:num:from").toInt()
 }
 
 internal fun NCToken.player(): String {
-    return if (firstPersonWords.contains(this.normText())) "@p" else this.originalText ?: "@p"
+    return if (firstPersonWords.contains(this.normalizedText)) "@p" else this.originalText ?: "@p"
 }
 
 internal data class Coordinate(val x: Int = 0, val y: Int = 0, val z: Int = 0) {