This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master_test
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master_test by this push:
new dc2f82d WIP.
dc2f82d is described below
commit dc2f82dc9ba16d6fc76c7a74395494aef789e4f3
Author: Sergey Kamov <[email protected]>
AuthorDate: Mon Dec 13 15:17:13 2021 +0300
WIP.
---
.../org/apache/nlpcraft/NCEntityEnricher.java | 2 +-
.../scala/org/apache/nlpcraft/NCEntityParser.java | 2 +-
.../{NCLIfecycle.java => NCLifecycle.java} | 2 +-
.../scala/org/apache/nlpcraft/NCModelClient.java | 2 +-
.../scala/org/apache/nlpcraft/NCTokenEnricher.java | 2 +-
.../scala/org/apache/nlpcraft/NCTokenParser.java | 2 +-
.../entity/opennlp/NCOpenNlpEntityParser.scala | 29 ---------
.../entity/user/NCFileUserEntityParser.scala | 32 ----------
.../enrichers/entity/user/NCUserEntityParser.scala | 28 ---------
.../token/NCEnDictionaryTokenEnricher.scala | 25 --------
.../enrichers/token/NCEnQuotesTokenEnricher.scala | 25 --------
.../token/NCEnSwearWordsTokenEnricher.scala | 25 --------
.../nlpcraft/impl/tokenizers/NCEnTokenParser.scala | 35 -----------
.../nlp/entity/parser/custom}/NCElement.java | 36 +++++++++++-
.../entity/parser/custom}/NCElementBuilder.java | 45 +++++++++++++-
.../nlp/entity/parser/custom/NCEntityParser.java} | 65 +++++++++++----------
.../entity/parser/custom/NCFileEntityParser.java} | 68 ++++++++++++----------
.../nlp/entity/parser/custom}/NCMacro.java | 24 ++++++--
.../nlp/entity/parser/custom}/NCValue.java | 7 ++-
.../nlp/entity/parser/custom}/NCValueLoader.java | 6 +-
.../parser/opennlp/NCOpenNlpEntityParser.java} | 26 ++++++---
.../nlp/entity/parser}/opennlp/NCOpenNlpModel.java | 18 +++++-
.../enricher/NCEnDictionaryTokenEnricher.java} | 23 ++++----
.../token/enricher/NCEnQuotesTokenEnricher.java} | 21 +++----
.../enricher/NCEnSwearWordsTokenEnricher.java} | 21 +++----
.../parser/opennlp/NCOpenNlpTokenParser.java} | 36 ++++++++----
.../apache/nlpcraft/alarm/LightSwitchModel.java | 14 ++++-
.../nlpcraft/alarm/LightSwitchModelTest.java | 34 +++++------
28 files changed, 305 insertions(+), 350 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityEnricher.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityEnricher.java
index 5fff3b8..06a8d64 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityEnricher.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityEnricher.java
@@ -22,7 +22,7 @@ import java.util.*;
/**
*
*/
-public interface NCEntityEnricher extends NCLIfecycle {
+public interface NCEntityEnricher extends NCLifecycle {
/**
*
* @param req
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityParser.java
index c66f3c5..ce4d7e7 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityParser.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityParser.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
*
*/
-public interface NCEntityParser extends NCLIfecycle {
+public interface NCEntityParser extends NCLifecycle {
/**
*
* @param req
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLIfecycle.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
similarity index 96%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/NCLIfecycle.java
rename to nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
index b55df55..8593fe5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLIfecycle.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
@@ -20,7 +20,7 @@ package org.apache.nlpcraft;
/**
*
*/
-public interface NCLIfecycle {
+public interface NCLifecycle {
/**
*
*/
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
index dad31c6..ca0909c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
@@ -23,7 +23,7 @@ import java.util.concurrent.*;
/**
*
*/
-public class NCModelClient implements NCLIfecycle {
+public class NCModelClient implements NCLifecycle {
private NCModel mdl;
/**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenEnricher.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenEnricher.java
index 5837109..ab78f76 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenEnricher.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenEnricher.java
@@ -22,7 +22,7 @@ import java.util.*;
/**
*
*/
-public interface NCTokenEnricher extends NCLIfecycle {
+public interface NCTokenEnricher extends NCLifecycle {
/**
*
* @param req
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
index 236c3a7..867eecf 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
*
*/
-public interface NCTokenParser extends NCLIfecycle {
+public interface NCTokenParser extends NCLifecycle {
/**
*
* @param req
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpEntityParser.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpEntityParser.scala
deleted file mode 100644
index 73ab6cf..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpEntityParser.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.entity.opennlp
-
-import org.apache.nlpcraft.{NCEntity, NCEntityParser, NCModelConfig,
NCRequest, NCToken}
-
-import org.apache.nlpcraft.internal.extcfg.NCExternalConfigManager
-import java.util
-
-class NCOpenNlpEntityParse(models: util.List[NCOpenNlpModel], extCfgMgr:
NCExternalConfigManager) extends NCEntityParser {
- def start(): Unit = {
- }
-
- override def parse(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): util.List[NCEntity] = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCFileUserEntityParser.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCFileUserEntityParser.scala
deleted file mode 100644
index f091823..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCFileUserEntityParser.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.entity.user
-
-import org.apache.nlpcraft.*
-
-import java.io.File
-import java.util
-
-class NCFileUserEntityParser(
- file: File,
- // Element ID / Values loader.
- loaders: util.Map[String, NCValueLoader]
-) extends NCEntityParser {
- def this (file: File) = this (file, null)
-
- override def parse(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): util.List[NCEntity] = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCUserEntityParser.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCUserEntityParser.scala
deleted file mode 100644
index 542b89d..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCUserEntityParser.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.entity.user
-
-import org.apache.nlpcraft.*
-
-import java.util
-
-class NCUserEntityParser(
- macros: util.List[NCMacro],
- elements: util.List[NCElement]
-) extends NCEntityParser {
- override def parse(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): util.List[NCEntity] = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnDictionaryTokenEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnDictionaryTokenEnricher.scala
deleted file mode 100644
index 53849a5..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnDictionaryTokenEnricher.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.token
-
-import org.apache.nlpcraft.{NCModelConfig, NCRequest, NCToken, NCTokenEnricher}
-
-import java.util
-
-class NCEnDictionaryTokenEnricher extends NCTokenEnricher {
- override def enrich(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): Unit = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnQuotesTokenEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnQuotesTokenEnricher.scala
deleted file mode 100644
index 671de22..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnQuotesTokenEnricher.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.token
-
-import org.apache.nlpcraft.{NCModelConfig, NCRequest, NCToken, NCTokenEnricher}
-
-import java.util
-
-class NCEnQuotesTokenEnricher extends NCTokenEnricher {
- override def enrich(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): Unit = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnSwearWordsTokenEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnSwearWordsTokenEnricher.scala
deleted file mode 100644
index 834d6fb..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/token/NCEnSwearWordsTokenEnricher.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.enrichers.token
-
-import org.apache.nlpcraft.{NCModelConfig, NCRequest, NCToken, NCTokenEnricher}
-
-import java.util
-
-class NCEnSwearWordsTokenEnricher extends NCTokenEnricher {
- override def enrich(req: NCRequest, cfg: NCModelConfig, toks:
util.List[NCToken]): Unit = ???
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/tokenizers/NCEnTokenParser.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/tokenizers/NCEnTokenParser.scala
deleted file mode 100644
index acadbf6..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/tokenizers/NCEnTokenParser.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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
- *
- * https://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.impl.tokenizers
-
-import org.apache.nlpcraft.internal.extcfg.NCExternalConfigManager
-import org.apache.nlpcraft.{NCRequest, NCToken, NCTokenParser}
-
-import java.io.File
-import java.util;
-
-class NCEnTokenParser(
- extCfgMgr: NCExternalConfigManager,
- tagger: File,
- lemmatizer: File
-) extends NCTokenParser {
- override def parse(req: NCRequest): util.List[NCToken] = ???
-
- def start(): Unit = {
-
- }
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElement.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElement.java
similarity index 78%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElement.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElement.java
index 66f6812..eb476d3 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElement.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElement.java
@@ -14,17 +14,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
+
+
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
import java.util.Optional;
import java.util.Set;
import org.apache.nlpcraft.NCParameterized;
+/**
+ *
+ */
public interface NCElement extends NCParameterized {
+ /**
+ *
+ * @return
+ */
String getId();
+
+ /**
+ *
+ * @return
+ */
String getDescription();
+
+ /**
+ *
+ * @return
+ */
Optional<String> getParentId();
+
+ /**
+ *
+ * @return
+ */
Set<String> getGroups();
+
+ /**
+ *
+ * @return
+ */
Set<NCValue> getValues();
+
+ /**
+ *
+ * @return
+ */
Optional<NCValueLoader> getValuesLoader();
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElementBuilder.java
similarity index 74%
copy from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElementBuilder.java
index 5ceb36a..f928919 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCElementBuilder.java
@@ -14,41 +14,84 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
+
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
import java.util.List;
import java.util.Set;
import java.util.Map;
+/**
+ *
+ */
public class NCElementBuilder {
+ /**
+ *
+ * @param id
+ * @param desc
+ */
public NCElementBuilder(String id, String desc) {
}
+ /**
+ *
+ * @param parentId
+ * @return
+ */
public NCElementBuilder withParentId(String parentId) {
return this;
}
+ /**
+ *
+ * @param groups
+ * @return
+ */
public NCElementBuilder withGroups(Set<String> groups) {
return this;
}
+ /**
+ *
+ * @param values
+ * @return
+ */
public NCElementBuilder withValues(Set<NCValue> values) {
return this;
}
+ /**
+ *
+ * @param loader
+ * @return
+ */
public NCElementBuilder withValuesLoader(NCValueLoader loader) {
return this;
}
+ /**
+ *
+ * @param props
+ * @return
+ */
public NCElementBuilder withProperties(Map<String, String> props) {
return this;
}
+ /**
+ *
+ * @param syns
+ * @return
+ */
public NCElementBuilder withSynonyms(List<String> syns) {
return this;
}
+ /**
+ *
+ * @return
+ */
public NCElement make() {
return null;
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCEntityParser.java
similarity index 51%
copy from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCEntityParser.java
index 5ceb36a..da94fc3 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCEntityParser.java
@@ -14,42 +14,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
-import java.util.List;
-import java.util.Set;
-import java.util.Map;
-
-public class NCElementBuilder {
- public NCElementBuilder(String id, String desc) {
-
- }
-
- public NCElementBuilder withParentId(String parentId) {
- return this;
- }
-
- public NCElementBuilder withGroups(Set<String> groups) {
- return this;
- }
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
- public NCElementBuilder withValues(Set<NCValue> values) {
- return this;
- }
-
- public NCElementBuilder withValuesLoader(NCValueLoader loader) {
- return this;
- }
-
- public NCElementBuilder withProperties(Map<String, String> props) {
- return this;
- }
+import org.apache.nlpcraft.NCEntity;
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
- public NCElementBuilder withSynonyms(List<String> syns) {
- return this;
- }
+import java.util.List;
- public NCElement make() {
+/**
+ *
+ */
+public class NCEntityParser implements org.apache.nlpcraft.NCEntityParser {
+ private final List<NCMacro> macros;
+ private final List<NCElement> elements;
+
+ /**
+ *
+ * @param macros
+ * @param elements
+ */
+ public NCEntityParser(List<NCMacro> macros, List<NCElement> elements) {
+ this.macros = macros;
+ this.elements = elements;
+ }
+
+ /**
+ *
+ * @param elements
+ */
+ public NCEntityParser(List<NCElement> elements) {
+ this(null, elements);
+ }
+
+ @Override
+ public List<NCEntity> parse(NCRequest req, NCModelConfig cfg,
List<NCToken> toks) {
return null;
}
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCFileEntityParser.java
similarity index 51%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCFileEntityParser.java
index 5ceb36a..3e11057 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCElementBuilder.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCFileEntityParser.java
@@ -14,42 +14,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
-import java.util.List;
-import java.util.Set;
-import java.util.Map;
-
-public class NCElementBuilder {
- public NCElementBuilder(String id, String desc) {
-
- }
-
- public NCElementBuilder withParentId(String parentId) {
- return this;
- }
-
- public NCElementBuilder withGroups(Set<String> groups) {
- return this;
- }
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
- public NCElementBuilder withValues(Set<NCValue> values) {
- return this;
- }
-
- public NCElementBuilder withValuesLoader(NCValueLoader loader) {
- return this;
- }
-
- public NCElementBuilder withProperties(Map<String, String> props) {
- return this;
- }
+import org.apache.nlpcraft.NCEntity;
+import org.apache.nlpcraft.NCEntityParser;
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
- public NCElementBuilder withSynonyms(List<String> syns) {
- return this;
- }
+import java.util.List;
+import java.util.Map;
+import java.io.File;
- public NCElement make() {
+/**
+ *
+ */
+public class NCFileEntityParser implements NCEntityParser {
+ private final File file;
+ private final Map<String, NCValueLoader> loaders;
+
+ /**
+ *
+ * @param file
+ * @param loaders
+ */
+ public NCFileEntityParser(File file, Map<String, NCValueLoader> loaders) {
+ this.file = file;
+ this.loaders = loaders;
+ }
+
+ /**
+ *
+ * @param file
+ */
+ public NCFileEntityParser(File file) {
+ this(file, null);
+ }
+
+ @Override
+ public List<NCEntity> parse(NCRequest req, NCModelConfig cfg,
List<NCToken> toks) {
return null;
}
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCMacro.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCMacro.java
similarity index 79%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCMacro.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCMacro.java
index 945bec3..428df40 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCMacro.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCMacro.java
@@ -6,7 +6,7 @@
* (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
+ * https://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,
@@ -15,25 +15,37 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
-import java.io.Serializable;
-import java.util.List;
-
-// TODO: Do we nneed it? maybe map is better?
+/**
+ *
+ */
public class NCMacro {
private final String id;
private final String macro;
+ /**
+ *
+ * @param id
+ * @param macro
+ */
public NCMacro(String id, String macro) {
this.id = id;
this.macro = macro;
}
+ /**
+ *
+ * @return
+ */
public String getId() {
return id;
}
+ /**
+ *
+ * @return
+ */
public String getMacro() {
return macro;
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValue.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValue.java
similarity index 91%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValue.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValue.java
index e55d4e9..0d0acb6 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValue.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValue.java
@@ -6,7 +6,7 @@
* (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
+ * https://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,
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
-import java.io.Serializable;
import java.util.List;
/**
+ * TODO: fix javadoc
+ *
* Model element's value.
* <p>
* Each model element can generally be recognized either by one of its
synonyms or values. Elements and their values
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValueLoader.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValueLoader.java
similarity index 95%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValueLoader.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValueLoader.java
index bf48408..090dc2d 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/user/NCValueLoader.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/custom/NCValueLoader.java
@@ -6,7 +6,7 @@
* (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
+ * https://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,
@@ -15,11 +15,13 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.user;
+package org.apache.nlpcraft.internal.nlp.entity.parser.custom;
import java.util.Set;
/**
+ * TODO: fix javadoc
+ *
* Dynamic value loader that can be used by model elements to dynamically load
or create their values. Note that
* the primary use case for this interface is the dynamic value loading for
the models defines in JSON/YAML
* presentation. However, it's not technically limited to that use case only,
and this interface can be
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
similarity index 58%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
index 236c3a7..3993fe6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
@@ -15,20 +15,32 @@
* limitations under the License.
*/
-package org.apache.nlpcraft;
+package org.apache.nlpcraft.internal.nlp.entity.parser.opennlp;
+
+import org.apache.nlpcraft.NCEntity;
+import org.apache.nlpcraft.NCEntityParser;
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
import java.util.List;
/**
*
*/
-public interface NCTokenParser extends NCLIfecycle {
+public class NCOpenNlpEntityParser implements NCEntityParser {
+ private final List<NCOpenNlpModel> models;
+
/**
*
- * @param req
- * @return
- * @throws
- * @throws NCException
+ * @param models
*/
- List<NCToken> parse(NCRequest req);
+ public NCOpenNlpEntityParser(List<NCOpenNlpModel> models) {
+ this.models = models;
+ }
+
+ @Override
+ public List<NCEntity> parse(NCRequest req, NCModelConfig cfg,
List<NCToken> toks) {
+ return null;
+ }
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpModel.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpModel.java
similarity index 84%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpModel.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpModel.java
index 4d5c3b3..056ab49 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/impl/enrichers/entity/opennlp/NCOpenNlpModel.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpModel.java
@@ -14,24 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.impl.enrichers.entity.opennlp;
+package org.apache.nlpcraft.internal.nlp.entity.parser.opennlp;
import java.io.File;
+/**
+ *
+ */
public class NCOpenNlpModel {
private String elementId;
private File path;
+ /**
+ *
+ * @param elementId
+ * @param path
+ */
public NCOpenNlpModel(String elementId, File path) {
this.elementId = elementId;
this.path = path;
}
+ /**
+ *
+ * @return
+ */
public String getElementId() {
return elementId;
}
+ /**
+ *
+ * @return
+ */
public File getPath() {
return path;
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnDictionaryTokenEnricher.java
similarity index 68%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnDictionaryTokenEnricher.java
index 236c3a7..c9895e6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnDictionaryTokenEnricher.java
@@ -15,20 +15,21 @@
* limitations under the License.
*/
-package org.apache.nlpcraft;
+package org.apache.nlpcraft.internal.nlp.token.enricher;
+
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
+import org.apache.nlpcraft.NCTokenEnricher;
import java.util.List;
/**
- *
+ *
*/
-public interface NCTokenParser extends NCLIfecycle {
- /**
- *
- * @param req
- * @return
- * @throws
- * @throws NCException
- */
- List<NCToken> parse(NCRequest req);
+public class NCEnDictionaryTokenEnricher implements NCTokenEnricher {
+ @Override
+ public void enrich(NCRequest req, NCModelConfig cfg, List<NCToken> toks) {
+
+ }
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnQuotesTokenEnricher.java
similarity index 68%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnQuotesTokenEnricher.java
index 236c3a7..14243a7 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnQuotesTokenEnricher.java
@@ -15,20 +15,21 @@
* limitations under the License.
*/
-package org.apache.nlpcraft;
+package org.apache.nlpcraft.internal.nlp.token.enricher;
+
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
+import org.apache.nlpcraft.NCTokenEnricher;
import java.util.List;
/**
*
*/
-public interface NCTokenParser extends NCLIfecycle {
- /**
- *
- * @param req
- * @return
- * @throws
- * @throws NCException
- */
- List<NCToken> parse(NCRequest req);
+public class NCEnQuotesTokenEnricher implements NCTokenEnricher {
+ @Override
+ public void enrich(NCRequest req, NCModelConfig cfg, List<NCToken> toks) {
+
+ }
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnSwearWordsTokenEnricher.java
similarity index 68%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
copy to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnSwearWordsTokenEnricher.java
index 236c3a7..ed61cdb 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/enricher/NCEnSwearWordsTokenEnricher.java
@@ -15,20 +15,21 @@
* limitations under the License.
*/
-package org.apache.nlpcraft;
+package org.apache.nlpcraft.internal.nlp.token.enricher;
+
+import org.apache.nlpcraft.NCModelConfig;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
+import org.apache.nlpcraft.NCTokenEnricher;
import java.util.List;
/**
*
*/
-public interface NCTokenParser extends NCLIfecycle {
- /**
- *
- * @param req
- * @return
- * @throws
- * @throws NCException
- */
- List<NCToken> parse(NCRequest req);
+public class NCEnSwearWordsTokenEnricher implements NCTokenEnricher {
+ @Override
+ public void enrich(NCRequest req, NCModelConfig cfg, List<NCToken> toks) {
+
+ }
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/extcfg/NCExternalConfigManager.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/parser/opennlp/NCOpenNlpTokenParser.java
similarity index 55%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/extcfg/NCExternalConfigManager.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/parser/opennlp/NCOpenNlpTokenParser.java
index 930fad3..9792c51 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/extcfg/NCExternalConfigManager.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/token/parser/opennlp/NCOpenNlpTokenParser.java
@@ -14,22 +14,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.nlpcraft.internal.extcfg;
+
+package org.apache.nlpcraft.internal.nlp.token.parser.opennlp;
+
+import org.apache.nlpcraft.NCLifecycle;
+import org.apache.nlpcraft.NCRequest;
+import org.apache.nlpcraft.NCToken;
+import org.apache.nlpcraft.NCTokenParser;
import java.io.File;
+import java.util.List;
-public class NCExternalConfigManager {
- private final String url;
- private final boolean checkMd5;
- private final File localDir;
+/**
+ *
+ */
+public class NCOpenNlpTokenParser implements NCTokenParser {
+ private final File tagger;
+ private final File lemmatizer;
- public NCExternalConfigManager(String url, boolean checkMd5, File
localDir) {
- this.url = url;
- this.checkMd5 = checkMd5;
- this.localDir = localDir;
+ /**
+ *
+ * @param tagger
+ * @param lemmatizer
+ */
+ public NCOpenNlpTokenParser(File tagger, File lemmatizer) {
+ this.tagger = tagger;
+ this.lemmatizer = lemmatizer;
}
- public void start() {
-
+ @Override
+ public List<NCToken> parse(NCRequest req) {
+ return null;
}
}
diff --git
a/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModel.java
b/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModel.java
index 632bc52..efb94b2 100644
--- a/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModel.java
+++ b/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModel.java
@@ -24,12 +24,24 @@ import org.apache.nlpcraft.NCModelConfig;
import java.util.List;
import java.util.stream.Collectors;
+/**
+ *
+ */
public class LightSwitchModel extends NCModelAdapter {
+ /**
+ *
+ * @param cfg
+ */
public LightSwitchModel(NCModelConfig cfg) {
super(cfg);
}
- // TODO: groups ?
+ /**
+ *
+ * @param actTok
+ * @param locToks
+ * @return
+ */
@NCIntent("intent=ls term(act)={has(tok_groups, 'act')} term(loc)={# ==
'ls:loc'}*")
@NCIntentSample({
"Turn the lights off in the entire house.",
diff --git
a/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModelTest.java
b/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModelTest.java
index c99d5ab..8c7db06 100644
--- a/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModelTest.java
+++ b/nlpcraft/src/test/java/org/apache/nlpcraft/alarm/LightSwitchModelTest.java
@@ -19,18 +19,17 @@ package org.apache.nlpcraft.alarm;
import org.apache.nlpcraft.NCModelClient;
import org.apache.nlpcraft.NCModelConfigAdapter;
-import org.apache.nlpcraft.impl.enrichers.entity.user.NCElement;
-import org.apache.nlpcraft.impl.enrichers.entity.user.NCElementBuilder;
-import org.apache.nlpcraft.impl.enrichers.entity.user.NCMacro;
-import org.apache.nlpcraft.impl.enrichers.entity.user.NCUserEntityParser;
-import org.apache.nlpcraft.impl.tokenizers.NCEnTokenParser;
-import org.apache.nlpcraft.internal.extcfg.NCExternalConfigManager;
+import org.apache.nlpcraft.internal.nlp.entity.parser.custom.NCElement;
+import org.apache.nlpcraft.internal.nlp.entity.parser.custom.NCElementBuilder;
+import org.apache.nlpcraft.internal.nlp.entity.parser.custom.NCMacro;
+import org.apache.nlpcraft.internal.nlp.entity.parser.custom.NCEntityParser;
+import
org.apache.nlpcraft.internal.nlp.token.parser.opennlp.NCOpenNlpTokenParser;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import java.io.File;
import java.util.HashSet;
import java.util.List;
+import java.io.File;
import static java.util.Arrays.asList;
@@ -39,9 +38,17 @@ public class LightSwitchModelTest {
public void test() {
NCModelClient client = new NCModelClient(new
LightSwitchModel(mkConfigManual()));
+ client.start();
+
Assertions.assertNotNull(client.askSync("Hi!", null, null).getBody());
+
+ client.stop();
}
+ /**
+ *
+ * @return
+ */
private static NCModelConfigAdapter mkConfigManual() {
List<NCMacro> macros = List.of(
new NCMacro("<ACTION>", "{turn|switch|dial|let|set|get|put}"),
@@ -88,20 +95,13 @@ public class LightSwitchModelTest {
).make()
);
- NCExternalConfigManager extCfg = new
NCExternalConfigManager("nlpcraft.org", true, new File("~"));
-
- extCfg.start();
-
- NCEnTokenParser tokParser = new NCEnTokenParser(extCfg, new
File("open_tagger.dic"), new File("open_lemmatizer.dic"));
-
- tokParser.start();
-
NCModelConfigAdapter cfg =
new NCModelConfigAdapter(
"nlpcraft.lightswitch.ex",
"Light Switch Example Model",
"1.0",
- tokParser
+ new NCOpenNlpTokenParser(new File("tagger.txt"), new
File("lemmatizer.txt"))
+
);
// Order is important.
@@ -113,7 +113,7 @@ public class LightSwitchModelTest {
// )
// )
- cfg.setEntityParsers(asList(new NCUserEntityParser(macros, elements)));
+ cfg.setEntityParsers(asList(new NCEntityParser(macros, elements)));
// // Don't need any entity enrichers.
// cfg.setEntityEnrichers(null)