Kristian Rickert created OPENNLP-1986:
-----------------------------------------

             Summary: MorfologikTagDictionary throws NullPointerException for 
tagless entries
                 Key: OPENNLP-1986
                 URL: https://issues.apache.org/jira/browse/OPENNLP-1986
             Project: OpenNLP
          Issue Type: Bug
            Reporter: Kristian Rickert
            Assignee: Kristian Rickert
             Fix For: 2.5.13, 3.0.0


h2. Problem

A valid Morfologik dictionary may contain lemma/inflected-form entries without
a POS tag. \{{MorfologikTagDictionary.getTags}} calls \{{getTag().toString()}}
without checking for a null tag.

h2. Reproduction

Compile a two-column dictionary containing \{{carro,carro}}, with comma as its
separator, UTF-8 encoding and the prefix encoder. Load it through
{\{MorfologikTagDictionary}} and call \{{getTags("carro")}}.

Expected: \{{null}}, matching the TagDictionary contract when no tag information
is available.

Actual: \{{NullPointerException}} from dereferencing \{{WordData.getTag()}}.

The affected lookup implementation is present on both branches checked on
2026-09-19:
* \{{opennlp-2.x}} at \{{26f394a6ab01bf757334ba88f03bc9e2a42f6c27}}.
* \{{main}} at \{{f2ab1ccd435c20e910008511a37467131683e9c7}}.

The exception was reproduced against the exact 2.x source with Morfologik 2.2.0.
These branch checks do not establish the earliest affected released version.

h2. Proposed fix and validation

Skip entries without tags and return \{{null}} when no tagged analyses remain.
Keep valid tags and their existing order. Add a regression using a real compiled
tagless dictionary, plus checks for normal tagged entries and an unknown word.

Keep concurrency and case-folding changes outside this issue. Prepare focused
fixes for main and opennlp-2.x under this issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to