dweiss commented on code in PR #11857: URL: https://github.com/apache/lucene/pull/11857#discussion_r997417873
########## lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java: ########## @@ -614,11 +617,27 @@ private void doSuggest( Runnable checkCanceled) { Hunspell suggestionSpeller = new Hunspell(dictionary, policy, checkCanceled) { + final Map<String, Optional<Root<CharsRef>>> compoundCache = new HashMap<>(); + @Override boolean acceptsStem(int formID) { return !dictionary.hasFlag(formID, dictionary.noSuggest) && !dictionary.hasFlag(formID, dictionary.subStandard); } + + @Override + Root<CharsRef> findStem( + char[] chars, int offset, int length, WordCase originalCase, WordContext context) { + if (context == COMPOUND_BEGIN && originalCase == null) { + return compoundCache + .computeIfAbsent( + new String(chars, offset, length), + __ -> + Optional.ofNullable(super.findStem(chars, offset, length, null, context))) Review Comment: Had to look it up to believe it: "If the specified key is not already associated with a value (or is mapped to null)". Damn, that's a non-intuitive spec... I've always had a clear perception that it's only the key association (key presence) that is validated here... and it's just been ruined. Sorry for the noise, @donnerpeter, LGTM. -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org 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