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 e6adda7  Minor performance improvements.
e6adda7 is described below

commit e6adda7105b92b1b9c1bafdb8c9cb53cf7241c45
Author: Sergey Kamov <[email protected]>
AuthorDate: Tue Apr 20 16:59:43 2021 +0300

    Minor performance improvements.
---
 .../mgrs/nlp/enrichers/model/NCModelEnricher.scala      | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
index 85faaba..8fae1cf 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
@@ -533,15 +533,19 @@ object NCModelEnricher extends NCProbeEnricher with 
DecorateAsScala {
 
                         // 2. IDL.
                         if (idlEnabled) {
+                            val allSyns = get(mdl.idlSynonyms, eId)
+                            lazy val allCombs = mkCombinations(ch, toks, 
idlCache.toSet)
+
                             // 2.1 Continuous.
+
                             if (!mdl.hasSparseSynonyms) {
                                 var found = false
 
                                 for (
-                                    s ← get(mdl.idlSynonyms, eId);
-                                        comb ← mkCombinations(ch, toks, 
idlCache.toSet);
-                                        data = comb.map(_.data)
-                                        if !found
+                                    s ← allSyns;
+                                    comb ← allCombs
+                                    if !found;
+                                    data = comb.map(_.data)
                                 )
                                     if (s.isMatch(data, req)) {
                                         add("IDL continuous", ns, contCache, 
e, toks, idxs, s, toParts(data, s))
@@ -553,7 +557,10 @@ object NCModelEnricher extends NCProbeEnricher with 
DecorateAsScala {
                             }
                             else
                                 // 2.2 Sparse.
-                                for (s ← get(mdl.idlSynonyms, eId); comb ← 
mkCombinations(ch, toks, idlCache.toSet))
+                                for (
+                                    s ← allSyns;
+                                    comb ← allCombs
+                                )
                                     s.sparseMatch(comb.map(_.data), req) match 
{
                                         case Some(res) ⇒
                                             val typ = if (s.sparse) "IDL 
sparse" else "IDL continuous"

Reply via email to