explosion / explosion/spacy-stanza
Add stanza constituency output
- Dominant language
- Python
- Stars
- 748
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Description
Since [release v1.3.0](https://github.com/stanfordnlp/stanza/releases/tag/v1.3.0), stanza has a constituency parser for English. Support for more languages will follow. It would be great if we could access the constituency parse from within the spaCy wrapper too.
At first I thought I'd create a separate package for this that uses spacy_stanza under the hood and then registers a custom component that adds the constituency parse. However, that implies _either_ copying most of `spacy_stanza`, subclassing `StanzaTokenizer`, and writing to Underscore objects in `__call__`. _Or_ only creating a custom component and after receiving a Doc, parsing its text again with stanza to get the constituency parse. Neither of these are ideal, so I would hope that you are open to incorporating such functionality in spacy_stanza directly.
The [stanza constituency parser](https://stanfordnlp.github.io/stanza/constituency.html) adds a `constituency` object (a [`Tree`](https://github.com/stanfordnlp/stanza/blob/f91ca215e175d4f7b202259fe789374db7829395/stanza/models/constituency/parse_tree.py#L20)) to every sentence. Things that may be considered
- Subclassing the stanza constituency Tree so that we can use spaCy Tokens as node labels. This would allow us to navigate the spaCy sentence Span object via the tree
- Register `._.constituency` for every sentence span and every span that is a constituent (a sub-classed stanza Tree)
- Register `._.constituency` for every Token, which would be its subtree in the full tree with itself as the node (a sub-classed stanza Tree)
If you agree I can work on this from time to time.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.