How to match dependency patterns with spaCy?

心不动则不痛 提交于 2020-05-15 09:57:11

问题


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.


回答1:


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:

https://github.com/explosion/spaCy/blob/bae0455f91c375681868f3f21a9de84136f9a561/spacy/tests/matcher/test_matcher_api.py#L271-L346

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.



来源:https://stackoverflow.com/questions/57664264/how-to-match-dependency-patterns-with-spacy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!