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 https://github.com/andersjo/dependency_decoding .
Documentation
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
np.random.seed(42)
score_matrix = np.random.rand(3, 4)
heads, tree_score = chu_liu_edmonds(score_matrix)
print(heads, tree_score)
Install
Binary wheels of the package are provided, just run
pip install ufal.chu_liu_edmonds
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
Hashes for ufal.chu_liu_edmonds-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b14eb6fdffdb335b62416f26a24f108ec00b71e1852f63842568e164cc8e9c84 |
|
MD5 | 14de45e8a335f043c5ec8516519af7d2 |
|
BLAKE2b-256 | 5f0bf750bcc91540d192eb77f04a34d6d3329df2955d87f6c5a9ea62ddd3d5b8 |