krickert opened a new pull request, #1163:
URL: https://github.com/apache/opennlp/pull/1163

   Thank you for contributing to Apache OpenNLP.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced in 
the commit message?
   - [x] Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA 
number you are trying to resolve?
   - [x] Has your PR been rebased against the latest commit within the target 
branch (typically main)?
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] Have you ensured that the full suite of tests is executed via mvn 
clean install at the root opennlp folder?
   - [x] Have you written or updated unit tests to verify your changes?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under ASF 2.0?
   - [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file in opennlp folder?
   - [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found in opennlp folder?
   
   ### For documentation related changes:
   - [x] Have you ensured that format looks appropriate for the output in which 
it is rendered?
   
   ## What is this PR for?
   
   **Draft: stacked on #1162 (OPENNLP-1882); the first commit belongs to that 
PR and will drop out once it merges.**
   
   `SnowballStemmer` holds mutable per-call buffers in the generated engine, so 
sharing an instance across threads silently corrupts results — no exception, 
just wrong stems. With 3.0.0 unreleased, this aligns stemmers with the 
thread-safe `*ME` components (OPENNLP-1816).
   
   ## Changes
   
   - `SnowballStemmer` routes each call to a per-thread generated engine via 
`OwnerOrPerThreadState` (same pattern as the `*ME` classes); the generated 
Snowball code is untouched. One instance is now safe to share and is annotated 
`@ThreadSafe`.
   - New `StemmerFactory` (opennlp-api): an immutable, thread-safe capture of 
stemmer configuration, with `SnowballStemmerFactory` and `PorterStemmerFactory` 
implementations and a `SharingStemmer` adapter for engines that are not 
thread-safe themselves (e.g. `PorterStemmer`).
   - New `CachingStemmer`: bounded per-thread LRU memoization of word-to-stem 
mappings. Natural text is Zipf-distributed, so most tokens are repeats; JMH 
shows ~34x throughput on a Zipf workload and break-even on a cache-hostile one. 
`TermAnalyzer.Builder.stem(StemmerFactory)` and 
`NormalizationProfile.matchingAnalyzer()` use it, so profile analyzers are 
shareable and cached by default.
   - Tests: concurrency unit tests for all 21 Snowball algorithms (fixed pools, 
owner-thread transition, virtual threads), `MultiThreadedStemmerEval` mirroring 
`MultiThreadedToolsEval`, and JMH benchmarks (`SnowballStemmerBenchmark`, 
`CachingStemmerBenchmark`) with results and run instructions in BENCHMARKS.md.
   
   ## Test plan
   
   - `mvn test` on opennlp-runtime: 1,363 tests pass (includes the 38 stemmer 
and 32 analyzer tests)
   - `mvn test -Peval-tests -Dtest=MultiThreadedStemmerEval` on 
opennlp-eval-tests: 3/3
   - Full reactor `mvn clean test verify -Pjacoco -Pci`: green


-- 
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]

Reply via email to