Metadata-Version: 2.1
Name: ufal.chu-liu-edmonds
Version: 1.0.2
Summary: Bindings to Chu-Liu-Edmonds algorithm from TurboParser
Home-page: https://github.com/ufal/chu_liu_edmonds
Author: Milan Straka
Author-email: straka@ufal.mff.cuni.cz
License: GPLv3
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
License-File: LICENSE

# 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:
```python
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
```

## 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
```
