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

Semgrex contains #1484

Merged
merged 3 commits into from
Mar 6, 2025
Merged

Semgrex contains #1484

merged 3 commits into from
Mar 6, 2025

Conversation

AngledLuffa
Copy link
Contributor

Add functionality to semgrex to search for/against key/value pairs in fields on words which are maps. Currently the one thing which this really applies to is morphofeatures. When searching on morphofeatures, it matches a key string, then checks that the value does or doesn't match.

Current syntax:

{morphofeatures:{k1:/v1/;k2!:/v2/}}

represents a morphofeatures that must have k1=v1, but k2 != v2. /.../ represents regex, whereas not having /.../ would force an exact match.

…s which are Maps.

Currently the syntax is @, subject to change

eg,

morphofeatures@foo=bar

In this expression, bar can be a regex, but foo and morphofeatures cannot.
It might be worth adding regex capabilities for both of those,
Also, !@ would be a useful addition.

This checks at Semgrex compile time (not Java compile time) that
the annotation used for key/value is actually a Map

Has a test that the error checking and a simple search both work.
Need to negate the = in the NodePattern output
This map allow repeated elements inside the same brackets
@AngledLuffa
Copy link
Contributor Author

Discussed syntax with @manning , happy with current status

@AngledLuffa AngledLuffa merged commit 3c30b3b into dev Mar 6, 2025
1 check passed
@AngledLuffa AngledLuffa deleted the semgrex_contains branch March 6, 2025 22:59
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.

1 participant