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/01 08:29:06 UTC

[incubator-nlpcraft] branch master updated: Minor fixes.

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 e0d36a0  Minor fixes.
e0d36a0 is described below

commit e0d36a0387718cb6e3439a27a7a0dff59479973e
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Tue Mar 1 11:28:56 2022 +0300

    Minor fixes.
---
 .../en/impl/NCQuotesTokenEnricherImpl.scala         | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/enricher/en/impl/NCQuotesTokenEnricherImpl.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/enricher/en/impl/NCQuotesTokenEnricherImpl.scala
index 886e7bb..567000c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/enricher/en/impl/NCQuotesTokenEnricherImpl.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/enricher/en/impl/NCQuotesTokenEnricherImpl.scala
@@ -35,13 +35,14 @@ class NCQuotesTokenEnricherImpl extends NCTokenEnricher with LazyLogging:
         val quotes = toks.filter(isQuote)
 
         // Start and end quote can be different ("a` processed as valid)
-        if quotes.nonEmpty && quotes.size % 2 == 0 then
-            val m = toks.zipWithIndex.toMap
-            val pairs = quotes.zipWithIndex.drop(1).flatMap { (t, idx) =>
-                Option.when(idx % 2 != 0)(m(t) -> m(quotes(idx - 1)))
-            }
-            toks.zipWithIndex.foreach { (tok, idx) =>
-                tok.put("quoted", pairs.exists { (from, to) => from > idx && to < idx })
-            }
-        else
-            logger.warn(s"Detected invalid quotes in: ${req.getText}")
\ No newline at end of file
+        if quotes.nonEmpty then
+            if quotes.size % 2 == 0 then
+                val m = toks.zipWithIndex.toMap
+                val pairs = quotes.zipWithIndex.drop(1).flatMap { (t, idx) =>
+                    Option.when(idx % 2 != 0)(m(t) -> m(quotes(idx - 1)))
+                }
+                toks.zipWithIndex.foreach { (tok, idx) =>
+                    tok.put("quoted", pairs.exists { (from, to) => from > idx && to < idx })
+                }
+            else
+                logger.warn(s"Detected invalid quotes in: ${req.getText}")
\ No newline at end of file