nick-boss-tech opened a new pull request, #5070:
URL: https://github.com/apache/solr/pull/5070

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-4841
   
   ## What happens today
   
   **A language identifier outside the processor package cannot build the 
results it must return.**
   
   `DetectedLanguage` has a package-private constructor 
([DetectedLanguage.java](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java#L24)).
 `LanguageIdentifierUpdateProcessor` declares `protected abstract 
List<DetectedLanguage> detectLanguage(Reader)` 
([LanguageIdentifierUpdateProcessor.java](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/java/org/apache/solr/update/processor/LanguageIdentifierUpdateProcessor.java#L345)).
 A subclass in another package can override that method, but it cannot create 
the `DetectedLanguage` values it returns. Both in-tree subclasses sit in the 
processor package 
([LangDetect](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/java/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessor.java#L40),
 [Open
 
NLP](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/java/org/apache/solr/update/processor/OpenNLPLangDetectUpdateProcessor.java#L41)).
   
   ## What this change does
   
   **The `DetectedLanguage` constructor becomes public. Nothing else changes.**
   
   The constructor is now `public DetectedLanguage(String lang, Double 
certainty)` 
([DetectedLanguage.java](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java#L24)).
 The class, its fields, and its getters stay as they are. Access is only 
widened, so no existing caller changes.
   
   ## Proof
   
   **The gate passed at head `f8850ffd421`, and the pre-fix proof is grounded 
by a run on base.**
   
   - Verified 2026-10-07 at head `f8850ffd421`: `CustomLanguageIdentifierTest` 
1/1. Neighbors `LangDetectLanguageIdentifierUpdateProcessorFactoryTest` 13/13, 
`OpenNLPLangDetectUpdateProcessorFactoryTest` 13/13, 
`SolrInputDocumentReaderTest` 4/4. Module check passed.
   - Pre-fix proof: with production reverted to base, the new test fails. A 
protected-constructor run is also recorded.
   
   The new test 
[CustomLanguageIdentifierTest](https://github.com/nick-boss-tech/solr/blob/e4c878627108ee2347cb1d5ee915e3e953c4249f/solr/modules/langid/src/test/org/apache/solr/update/processor/custom/CustomLanguageIdentifierTest.java#L29-L48)
 builds a `DetectedLanguage` from another package.
   
   The live tip `e4c878627108` is one commit past this head. It changes the 
changelog type from fixed to added and nothing else. No re-gate was run.
   
   ## A choice to check
   
   **The open question is the access level of the constructor.**
   
   Options considered:
   
   - Keep it package-private. A custom processor outside the package stays 
unable to build results.
   - Make it `protected`. Only the same package and `DetectedLanguage` 
subclasses reach it, so a custom processor still cannot.
   - Make it `public`, as implemented. This adds public API.
   
   Was a public constructor the right call for this API?
   
   ## Limits
   
   **The new test checks little beyond compiling.**
   
   Its one assertion checks the two getters. It does not run language 
detection. The in-tree identifiers and their tests are unchanged.
   
   Changelog: 
`changelog/unreleased/SOLR-4841-detectedlanguage-public-constructor.yml` (type: 
added, since outside code gains a new capability).
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. Nick 
Shanin directed the work and takes responsibility for this contribution.
   


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

Reply via email to