Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve tokens on the path to a matching #5

Open
mpomarlan opened this issue Jul 26, 2019 · 1 comment
Open

Retrieve tokens on the path to a matching #5

mpomarlan opened this issue Jul 26, 2019 · 1 comment

Comments

@mpomarlan
Copy link

It's often interesting to know not only the leaf token as selected by a pattern, but also some of the intermediate steps. Python's re package even provides functionality-- named groups-- to identify particular parts of a matching that may be interesting separately.

An example of how this might look like for grammaregex would be:

example sentence: "Mrs. Robinson graduated from the Wharton School of the University of Pennsylvania in 1980."
pattern: ?PVBD/prep/?PIN/pobj/?P*
matchings: [{"root": "graduated", "prep": "from", "where": "School"}, {"root": "graduated", "prep": "in", "where": "1980"}]

An example implementation of such behavior (with backwards compatibility: if no ?P<> appears in the pattern to match, just return tokens as before) can be found at this branch.

@mpomarlan
Copy link
Author

meant to say,

pattern: ?P<root>VBD/prep/?P<prep>IN/pobj/?P<where>*

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

No branches or pull requests

1 participant