You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2022/07/07 07:46:15 UTC

[incubator-nlpcraft] branch NLPCRAFT-504 updated (ab461767 -> ec1a6286)

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

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


    from ab461767 Minor fixes.
     new 638f3705 NCStanfordNLPEntityParser fixes.
     new ec1a6286 NCStanfordNLPEntityParser fixes.

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:
 .../nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


[incubator-nlpcraft] 02/02: NCStanfordNLPEntityParser fixes.

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

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

commit ec1a628603cd4eceae1a04e807ac36fc9fe94521
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Thu Jul 7 10:46:08 2022 +0300

    NCStanfordNLPEntityParser fixes.
---
 .../nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala       | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
index a684efab..1677c6dd 100644
--- a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
+++ b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
@@ -21,7 +21,6 @@ import edu.stanford.nlp.ling.CoreAnnotations.NormalizedNamedEntityTagAnnotation
 import edu.stanford.nlp.pipeline.*
 import org.apache.nlpcraft.*
 
-import java.util.Objects
 import scala.collection.mutable
 import scala.jdk.CollectionConverters.*
 
@@ -34,6 +33,8 @@ class NCStanfordNLPEntityParser(stanford: StanfordCoreNLP, supported: Set[String
     require(stanford != null, "Stanford instance cannot be null.")
     require(supported != null && supported.nonEmpty, "Supported elements set cannot be null or empty.")
 
+    private val supportedLc = supported.map(_.toLowerCase)
+
     override def parse(req: NCRequest, cfg: NCModelConfig, toks: List[NCToken]): List[NCEntity] =
         val doc = new CoreDocument(req.getText)
         stanford.annotate(doc)
@@ -43,7 +44,7 @@ class NCStanfordNLPEntityParser(stanford: StanfordCoreNLP, supported: Set[String
         for (e <- doc.entityMentions().asScala)
             val typ = e.entityType().toLowerCase
 
-            if supported.contains(typ) then
+            if supportedLc.contains(typ) then
                 val offsets = e.charOffsets()
                 val t1 = toks.find(_.getStartCharIndex == offsets.first)
                 lazy val t2 = toks.find(_.getEndCharIndex == offsets.second)


[incubator-nlpcraft] 01/02: NCStanfordNLPEntityParser fixes.

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

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

commit 638f37055f464d472c1b3f7f1daed2e8bb0b7194
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Thu Jul 7 10:41:47 2022 +0300

    NCStanfordNLPEntityParser fixes.
---
 .../nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
index d17e3c04..a684efab 100644
--- a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
+++ b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParser.scala
@@ -31,8 +31,8 @@ import scala.jdk.CollectionConverters.*
   * @param supported
   */
 class NCStanfordNLPEntityParser(stanford: StanfordCoreNLP, supported: Set[String]) extends NCEntityParser:
-    require(stanford != null, "Stanford instance cannot be null.");
-    require(supported != null && supported.nonEmpty, "Supported elements set cannot be null or empty.");
+    require(stanford != null, "Stanford instance cannot be null.")
+    require(supported != null && supported.nonEmpty, "Supported elements set cannot be null or empty.")
 
     override def parse(req: NCRequest, cfg: NCModelConfig, toks: List[NCToken]): List[NCEntity] =
         val doc = new CoreDocument(req.getText)