donnerpeter commented on a change in pull request #4:
URL: https://github.com/apache/lucene/pull/4#discussion_r591653279



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/GeneratingSuggester.java
##########
@@ -75,25 +84,29 @@
             return;
           }
 
-          String root = rootChars.toString();
-          filterSuitableEntries(root, forms, entries);
-          if (entries.isEmpty()) return;
+          int suitable = filter.findSuitableFormIndex(forms, 0);
+          if (suitable < 0) return;
 
-          if (ignoreTitleCaseRoots && WordCase.caseOf(rootChars) == 
WordCase.TITLE) {
+          if (ignoreTitleCaseRoots
+              && Character.isUpperCase(rootChars.charAt(0))
+              && WordCase.caseOf(rootChars) == WordCase.TITLE) {
             return;
           }
 
-          String lower = dictionary.toLowerCase(root);
           int sc =
-              automaton.ngramScore(lower)
-                  - longerWorsePenalty(word, lower)
-                  + commonPrefix(word, root);
+              automaton.ngramScore(rootChars)
+                  - longerWorsePenalty(word.length(), rootChars.length)
+                  + commonPrefix(word, rootChars);
 
           if (roots.size() == MAX_ROOTS && sc < roots.peek().score) {
             return;
           }
 
-          entries.forEach(e -> roots.add(new Weighted<>(e, sc)));
+          String root = rootChars.toString();

Review comment:
       Only after all checks do we allocate the string and `Root` objects




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to