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/03/17 07:36:40 UTC

[incubator-nlpcraft] branch master updated: Stanford tests fixed.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 88f2d6f  Stanford tests fixed.
88f2d6f is described below

commit 88f2d6f081b9cfea2c8cf8280fdd6210c29a4dd1
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Thu Mar 17 10:36:33 2022 +0300

    Stanford tests fixed.
---
 .../stanford/NCStanfordLemmaPosTokenEnricher.java  | 35 ----------------------
 .../impl/NCStanfordLemmaPosTokenEnricherImpl.scala | 27 -----------------
 .../impl/NCStanfordNLPTokenParserImpl.scala        |  6 ++--
 .../stanford/NCStanfordNLPTokenParserSpec.scala    |  5 ++--
 4 files changed, 4 insertions(+), 69 deletions(-)

diff --git a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/NCStanfordLemmaPosTokenEnricher.java b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/NCStanfordLemmaPosTokenEnricher.java
deleted file mode 100644
index 2f003dc..0000000
--- a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/NCStanfordLemmaPosTokenEnricher.java
+++ /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.nlp.token.enricher.stanford;
-
-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 class NCStanfordLemmaPosTokenEnricher implements NCTokenEnricher {
-    @Override
-    public void enrich(NCRequest req, NCModelConfig cfg, List<NCToken> toks) {
-        // TODO:
-    }
-}
diff --git a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/impl/NCStanfordLemmaPosTokenEnricherImpl.scala b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/impl/NCStanfordLemmaPosTokenEnricherImpl.scala
deleted file mode 100644
index 147cf1b..0000000
--- a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/enricher/stanford/impl/NCStanfordLemmaPosTokenEnricherImpl.scala
+++ /dev/null
@@ -1,27 +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.nlp.token.enricher.stanford.impl
-
-import org.apache.nlpcraft.*
-
-import java.util
-
-class NCStanfordLemmaPosTokenEnricherImpl extends NCTokenEnricher:
-    // TODO:
-
-    override def enrich(req: NCRequest, cfg: NCModelConfig, toks: util.List[NCToken]): Unit = ???
diff --git a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNLPTokenParserImpl.scala b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNLPTokenParserImpl.scala
index c8baa05..c9cec5d 100644
--- a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNLPTokenParserImpl.scala
+++ b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNLPTokenParserImpl.scala
@@ -49,12 +49,10 @@ class NCStanfordNLPTokenParserImpl(stanford: StanfordCoreNLP) extends NCTokenPar
             zipWithIndex.map { (t, idx) =>
                 val txt = t.originalText()
 
-                // TODO:
                 new NCPropertyMapAdapter with NCToken:
+                    put("pos", nvl(t.tag(), ""))
+                    put("lemma", nvl(t.lemma(), ""))
                     override val getText: String = txt
-                    // TODO: move it into special component?
-//                    override val getLemma: String = nvl(t.lemma(), txt)
-//                    override val getPos: String = nvl(t.tag(), "")
                     override val getIndex: Int = idx
                     override val getStartCharIndex: Int = t.beginPosition()
                     override val getEndCharIndex: Int = t.endPosition()
diff --git a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
index d2ebfd3..204e0c5 100644
--- a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
+++ b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
@@ -38,6 +38,5 @@ class NCStanfordNLPTokenParserSpec:
         NCTestUtils.printTokens(toks)
 
         val words = toks.map(_.getText)
-        // TODO: fix after main code fix.
-//        require(toks.map(_.getPos).distinct.sizeIs > 1)
-//        require(toks.map(_.getLemma).zip(words).exists {_ != _})
+        require(toks.map(_.get["String"]("pos")).filter(_ != null).distinct.sizeIs > 1)
+        require(toks.map(_.get[String]("lemma")).filter(_ != null).zip(words).exists {_ != _})