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 <[email protected]> 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)
