Skip to content

OPENNLP-1975: Regex removal (9/10): Correct the output of TokenSampleStream, ParserTool, ConlluStream, DownloadUtil and FeatureGeneratorUtil - #1314

Draft
rzo1 wants to merge 1 commit into
mainfrom
OPENNLP-1975-regex-removal-output-fixes
Draft

rzo1 wants to merge 1 commit into
mainfrom
OPENNLP-1975-regex-removal-output-fixes

Conversation

@rzo1

@rzo1 rzo1 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Part 9 of the regex removal (OPENNLP-1926). Split out of #1275. Based on main; part 1 (#1311, OPENNLP-1928) is merged.

These sites lose their regular expressions like the rest of the epic, but the scans follow what the code was meant to do instead of copying the regex quirks, so the output changes. Each corrected case is pinned by a test.

Behavior changes

TokenSampleStream (English). Tokens are split on runs of Unicode White_Space (StringUtil.splitOnUnicodeWhitespace), independent of the whitespace mode; before, split("\\s+") split on ASCII whitespace only. A leading space no longer yields an empty first token with the span (0,0). A line without a token resets the open-quote state. A token holding a letter or digit of any script is a word; before, [A-Za-z0-9] made non-ASCII words attach to the previous token as punctuation.

ParserTool. Brackets that follow each other are each separated: a))b gives a ) ) b, before a ) )b. A line without a bracket is returned unchanged. Whitespace follows the toolkit whitespace mode. Documented in the parser chapter.

ConlluStream. A multiword token id must be two runs of ASCII digits without a leading zero, joined by one hyphen, with the end not smaller than the start. Any other id fails with an InvalidFormatException naming the id. Before, 3- threw ArrayIndexOutOfBoundsException, -4 and 3--4 threw NumberFormatException, and 4-3 and 1-2-3 were read without an error. The text_xx language code is read with a scan, same output. New CoNLL-U section in the corpora chapter.

DownloadUtil. A blank checksum file is an IOException saying so; before, the model was rejected with "Expected: null". The index page links are read with a scan, same output.

FeatureGeneratorUtil. The cp class needs one capital and one period and no other character. A.\n was cp and is ic now. No other token changes class.

Before merge

  • Tokenizer eval build that reads through TokenSampleStream.

Commits by @krickert from #1275, regrouped.

@rzo1 rzo1 self-assigned this Sep 18, 2026
@rzo1
rzo1 marked this pull request as draft September 18, 2026 10:12
@rzo1
rzo1 force-pushed the OPENNLP-1975-regex-removal-output-fixes branch from a6fd65a to 596cf58 Compare September 18, 2026 11:17
@rzo1
rzo1 force-pushed the OPENNLP-1928-regex-removal-scans branch from 1d1b66a to 33581d0 Compare September 18, 2026 11:17
@rzo1
rzo1 force-pushed the OPENNLP-1975-regex-removal-output-fixes branch 2 times, most recently from 4b26964 to 6297884 Compare September 18, 2026 13:29
Base automatically changed from OPENNLP-1928-regex-removal-scans to main September 18, 2026 17:04
TokenSampleStream splits tokens on Unicode whitespace and treats letters
and digits of any script as words, ParserTool separates brackets that
follow each other, ConlluStream rejects malformed multiword ids with an
InvalidFormatException, DownloadUtil reports a blank checksum file and
FeatureGeneratorUtil's cp class requires one capital and one period.
Each corrected case is pinned by a test and documented in the manual.
@rzo1
rzo1 force-pushed the OPENNLP-1975-regex-removal-output-fixes branch from 6297884 to bbcce4a Compare September 18, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants