Skip to content

OPENNLP-53: Add Parse.createFromTokens() for convenient tokenized input#1012

Merged
mawiesne merged 2 commits intomainfrom
OPENNLP-53
Apr 7, 2026
Merged

OPENNLP-53: Add Parse.createFromTokens() for convenient tokenized input#1012
mawiesne merged 2 commits intomainfrom
OPENNLP-53

Conversation

@mawiesne
Copy link
Copy Markdown
Contributor

@mawiesne mawiesne commented Apr 2, 2026

What does this PR do?

  • Adds a static factory method to Parse that creates a parse structure directly from a String[] of tokens, avoiding the need to manually join tokens, compute character offsets, and build the initial parse tree.
  • Adds a ParserTool.parseLine(String[], Parser, int) overload and refactor existing code to use the new method.

Tasks

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:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • 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:

  • Have you ensured that the full suite of tests is executed via mvn clean install at the root opennlp folder?
  • 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:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions for build issues and submit an update to your PR as soon as possible.

  Add a static factory method to Parse that creates a parse structure
  directly from a String[] of tokens, avoiding the need to manually
  join tokens, compute character offsets, and build the initial parse
  tree. Also add a ParserTool.parseLine(String[], Parser, int) overload
  and refactor existing code to use the new method.
@mawiesne mawiesne requested review from atarora and jzonthemtn April 2, 2026 14:43
@mawiesne mawiesne added the java Pull requests that update Java code label Apr 2, 2026
Copy link
Copy Markdown
Contributor Author

@mawiesne mawiesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @rzo1 for the PR. We need some slight adjustments/enhancements, see my four minor comments.

Comment thread opennlp-api/src/main/java/opennlp/tools/parser/Parse.java Outdated
Comment thread opennlp-api/src/main/java/opennlp/tools/parser/Parse.java Outdated
Comment thread opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/parser/ParseTest.java Outdated
@mawiesne mawiesne merged commit 35227c7 into main Apr 7, 2026
9 checks passed
@mawiesne mawiesne deleted the OPENNLP-53 branch April 7, 2026 05:33
@rzo1 rzo1 restored the OPENNLP-53 branch April 7, 2026 05:34
@rzo1 rzo1 deleted the OPENNLP-53 branch April 7, 2026 05:34
mawiesne added a commit that referenced this pull request Apr 7, 2026
…ut (#1012)

OPENNLP-53: Add Parse.createFromTokens() for convenient tokenized input

Add a static factory method to Parse that creates a parse structure directly from a String[] of tokens, avoiding the need to manually join tokens, compute character offsets, and build the initial parse tree.
Adds a ParserTool.parseLine(String[], Parser, int) overload and refactors existing code to use the new method.

---------

Co-authored-by: Richard Zowalla <rzo1@apache.org>
(cherry picked from commit 35227c7)
@mawiesne
Copy link
Copy Markdown
Contributor Author

mawiesne commented Apr 7, 2026

🍒ed to maintenance branch 2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants