dweiss commented on code in PR #11857:
URL: https://github.com/apache/lucene/pull/11857#discussion_r997341034
##########
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:
Sorry for being dim but what's the point of storing those Optionals in the
map? Is storing just null values somehow out of fashion? :)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]