You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/03/05 14:21:03 UTC

[GitHub] [lucene-solr] donnerpeter commented on pull request #2457: LUCENE-9824: Hunspell suggestions: speed up ngram score calculation for each dictionary entry

donnerpeter commented on pull request #2457:
URL: https://github.com/apache/lucene-solr/pull/2457#issuecomment-791448721


   The latter is ~10% faster, so there's some difference. `RunAutomaton.step`
   has a constant-time array access branch, and it's taken quite often, it
   seems.
   
   On Fri, 5 Mar 2021 at 15:03, Robert Muir <no...@github.com> wrote:
   
   > *@rmuir* commented on this pull request.
   > ------------------------------
   >
   > In
   > lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/TrigramAutomaton.java
   > <https://github.com/apache/lucene-solr/pull/2457#discussion_r588317811>:
   >
   > > +    for (int start = 0; start < s1.length(); start++) {
   > +      int limit = Math.min(s1.length(), start + N);
   > +      for (int end = start + 1; end <= limit; end++) {
   > +        substringCounts.merge(s1.substring(start, end), 1, Integer::sum);
   > +      }
   > +
   > +      int state = initialState;
   > +      for (int i = start; i < limit; i++) {
   > +        int next = builder.createState();
   > +        builder.addTransition(state, next, s1.charAt(i));
   > +        state = next;
   > +      }
   > +    }
   > +
   > +    automaton =
   > +        new CharacterRunAutomaton(
   >
   > Both Automaton.step and CharacterRunAutomaton.step are binary search
   > (transition labels vs character classes, which probably isn't very
   > different here)
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/lucene-solr/pull/2457#discussion_r588317811>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AAA5ZGNURLRJ3Y5KTE5YSHDTCDQEZANCNFSM4YUX3ODA>
   > .
   >
   


----------------------------------------------------------------
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:
users@infra.apache.org



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