BramVanroy/spacy_conll
About
Pipeline component for spaCy (and other spaCy-wrapped parsers such as spacy-stanza and spacy-udpipe) that adds CoNLL-U properties to a Doc and its sentences and tokens. Can also be used as a command-line tool.
Machine LearningMeasured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalspacy-conll
spacy-conll is a spaCy pipeline component that formats parsed documents as CoNLL-U. It also reads CoNLL-U into spaCy Doc objects and includes the command line tool parse-as-conll. It works with spaCy models and, as an optional backend, with spacy-udpipe.
The output labels are those of the model that you use. For Universal Dependencies labels, use the UDPipe backend. spacy-stanza is not supported anymore since it has been unmaintained for a while now.
Installation
pip install spacy-conll
pip install "spacy-conll[udpipe]" # adds the UDPipe backend
pip install "spacy-conll[all]" # adds the UDPipe backend and pandas
spacy-conll needs Python 3.11 or newer. Install a spaCy model as well, for example python -m spacy download en_core_web_sm.
Example
import spacy
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("conll_formatter", last=True)
doc = nlp("I like cookies.")
print(doc._.conll_str)
1 I I PRON PRP Case=Nom|Number=Sing|Person=1|PronType=Prs 2 nsubj _ _
2 like like VERB VBP Tense=Pres|VerbForm=Fin 0 ROOT _ _
3 cookies cooky NOUN NNS Number=Plur 2 dobj _ SpaceAfter=No
4 . . PUNCT . PunctType=Peri 2 punct _ _
The same from the command line:
parse-as-conll en_core_web_sm spacy --input-str "I like cookies."
Documentation
The documentation has a usage guide, the API reference and a migration guide for v4 users. See examples/ for runnable scripts and the changelog for the release history.
Contributing
See CONTRIBUTING.md.
Credits
The first version of this library was inspired by the work of rgalhama and has changed a lot since then.
License
BSD 2-Clause. See LICENSE.
Explore related projects
Loading…