Reputation: 142
Is there a way to use spaCy's rule-based pattern matcher (or a similar library) on dependency sequences such as the list of tokens returned by token.ancestors
?
For example, I have pluralized a noun and now I need to check for dependent verbs to fix any errors in verb agreement.
So one pattern (of many) would be to match an 'auxpass' verb belonging to a parent verb which is a relative clause of the noun.
Upvotes: 3
Views: 2728
Reputation: 11484
I kind of hesitate to recommend something that doesn't have any documentation yet, but if you're adventurous, you could try out the relatively new DependencyMatcher. Check out the examples in the test suite to get an idea of how it works:
The operators are similar to:
https://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/semgraph/semgrex/SemgrexPattern.html
From looking at the relevant issues in github, it might not be very efficient yet and I wouldn't be surprised if you ran into a bug or two, so test things carefully before relying on it for anything crucial.
Upvotes: 6