Skip to main content

Convert Universal Dependencies parses into constituency representations.

Project description

dep2con

dep2con converts Universal Dependencies (UD) parses into constituency representations. It accepts either a CoNLL-U file or text processed with the Stanza dependency parser.

Requirements

  • Python 3.14 or newer
  • pyconll 4.0 or newer for CoNLL-U input
  • stanza when parsing raw text

Installation

Install the published package:

python -m pip install dep2con

For development from a clone:

python -m pip install -e ".[dev]"

Usage

from dep2con import make_const

results = make_const("input.conllu")

for dep2con in results:
    print(dep2con.sent_parse)
    print(dep2con.sent_text)
    print(dep2con.x_phrases)

make_const() returns a list with one Dep2Con object per input sentence. Each result has these attributes:

  • sent_parse
  • x_phrases
  • sent_dict
  • sent_text
  • sent_len
  • sentence_index
  • source

To parse raw text instead of loading CoNLL-U:

results = make_const("Cats sleep.", lang="en", use_parser=True)

Development

Run the test suite:

python -m pytest

Build distributable files:

python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dep2con-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dep2con-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file dep2con-0.1.0.tar.gz.

File metadata

  • Download URL: dep2con-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for dep2con-0.1.0.tar.gz
Algorithm Hash digest
SHA256 67955b10211fd1abd8bfabee77faf5a070727e15833f4ce666f3f3084e8aa742
MD5 f7e8e99340577a6b201d65f74ac78c66
BLAKE2b-256 86dc2820430c16232605a7a8fb53ee95604fc988106e1171f2b8ffc61920e0de

See more details on using hashes here.

File details

Details for the file dep2con-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dep2con-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for dep2con-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93327f218aa4deb6d2e58e13ca7a895fb765badef8ae10e47dfaa62c6c64f441
MD5 73157c5fc01fbbb64555e8a1709ee082
BLAKE2b-256 6ffb2f210f76e4ad26bb929f98188dca266aa64040fefc7f12bd37c702591e85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page