Skip to main content

Bindings to Chu-Liu-Edmonds algorithm from TurboParser

Project description

Chu-Liu-Edmonds Algorithm from TurpoParser.

This package wraps the Chu-Liu-Edmonds maximum spanning algorithm from TurboParser for use within Python.

The original package was made by .


The package provides a function chu_liu_edmonds which accepts a N×N score matrix as argument, where N is the sentence length, including the artificial root node. The (i,j)-th cell is the score for the edge j→i. In other words, a row gives the scores for the different heads of a dependent.

A np.nan cell value informs the algorithm to skip the edge.

Example usage:

import numpy as np
from ufal.chu_liu_edmonds import chu_liu_edmonds

score_matrix = np.random.rand(3, 4)
heads, tree_score = chu_liu_edmonds(score_matrix)
print(heads, tree_score)


Binary wheels of the package are provided, just run

pip install ufal.chu_liu_edmonds

Updating the Cython-generated Module

To update the Cython-generated module, run

cython --module-name ufal.chu_liu_edmonds._chu_liu_edmonds chu_liu_edmonds.pyx -o chu_liu_edmonds.cpp

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

ufal.chu_liu_edmonds-1.0.2.tar.gz (121.4 kB view hashes)

Uploaded source

Built Distributions

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page