dep2con
dep2con converts Universal Dependencies (UD) parses into constituency
representations. It accepts either a CoNLL-U format or text for the
Stanza dependency parser.
Requirements
- Python 3.14 or newer
pyconll4.0 or newer for CoNLL-U inputstanzawhen parsing raw text
Installation
Install the published package:
python -m pip install dep2con
Usage
from dep2con import make_const
Simple usage (for string parsing):
t_s = make_const("I saw a UFO in the backyard.", lang = 'en', use_parser = True)
for dep2con in t_s:
print(dep2con.sent_parse)
for i in dep2con.x_phrases:
print(i)
[VP [NP I] saw [NP a UFO] [PP in [NP the backyard]]] .
...
NPs:
I
a UFO
the backyard
VPs:
I saw a UFO in the backyard
PPs:
in the backyard
More on usage (for a CoNLL-U format):
t_s = make_const("conllu")
for dep2con in t_s:
print(dep2con.sent_parse)
print(dep2con.x_phrases)
print(dep2con.sentence_index)
...
Output attributes:
make_const() returns a list with one Dep2Con object per input sentence.
Each result has these attributes:
sent_parse- a constituency tree for the sentencex_phrases- constituents for the specified phrasessent_dict- a dictionary format for a sentence UD{1: {'idw': 1, 'wf': 'I', 'nf': 'I', 'pos': 'PRON', 'xpos': '_', 'tags': 'Case=Nom|Number=Sing|Person=1|PronType=Prs', 'head_id': 2, 'rel': 'nsubj', 'deps': '_', 'misc': '_'},...sent_text- sentence textsent_len- sentence lengthsentence_index- an index of a sentence in a textsource- sentence source if mentioned in a CoNLL-U file
Input arguments:
input: str, obligatory. Is string ifuse_parser = True, otherwise input in conllu formatlang: str, the language parameter ('en',...) in case of text parsinguse_parser: bool, True - the Stanza parser is at work; False - input in the conllu format,default = Falsedelete_orth: bool, delete orthography from the final tree,default = Falsexps: bool, return specific phrases separately,default = Trueemb: bool, returns subconstituents, not only maximal projection, if True,default = Trueh_terminals: List[str], terminals to be put in brackets w/out dependents,default = ['NOUN', 'PRON', 'PROPN', 'ADV']selected_cons: List[str], when we want some specific constituents only,default = ['NP', 'VP', 'PP', 'AP', 'AdvP', 'NumP', 'PartP', 'CCONJP', 'INTJP', 'Particle', 'SCONJP', 'SYMP', 'XP']
Metadata
Release files for dep2con 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dep2con-0.2.2.tar.gz | 8.5 kB | Without provenance | Details for dep2con-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dep2con-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for dep2con-0.2.2-py3-none-any.whl |
Total release size: 16.8 kB
Release files / dep2con-0.2.2.tar.gz
| Download URL | dep2con-0.2.2.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5617dd68844a7092237fbf0b9241fc65cb52d611dcf73289bd9370e0029ceab8
|
|
BLAKE2b-256 checksum How to use checksums |
71fab6eb323d1bb204834e553f548bbc44094aeb4ca481a3d8153a014a80b6be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / dep2con-0.2.2-py3-none-any.whl
| Download URL | dep2con-0.2.2-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c73c20aa7784253e96b3d031ae542eadc116e3b28f9e27de22440473ac2c5bc0
|
|
BLAKE2b-256 checksum How to use checksums |
a7f4088a52aead52a1453ca8d8a244af8e295e9e65323bce210cb617d999d88a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for dep2con 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.