Chinese Whispers for Python
This is an implementation of the Chinese Whispers clustering algorithm in Python. Since this library is based on NetworkX, it is simple to use.
Given a NetworkX graph G, this library can cluster it using the following code:
from chinese_whispers import chinese_whispers
chinese_whispers(G, weighting='top', iterations=20)
As the result, each node of the input graph is provided with the label attribute that stores the cluster label.
The library also offers a convenient command-line interface (CLI) for clustering graphs represented in the ABC tab-separated format (source\ttarget\tweight).
# Write karate_club.tsv (just as example)
python3 -c 'import networkx as nx; nx.write_weighted_edgelist(nx.karate_club_graph(), "karate_club.tsv", delimiter="\t")'
# Using as CLI
chinese-whispers karate_club.tsv
# Using as module (same CLI as above)
python3 -mchinese_whispers karate_club.tsv
A more complete usage example is available in the example notebook and at https://nlpub.github.io/chinese-whispers-python/.
In case you require higher performance, please consider our Java implementation that also includes other graph clustering algorithms: https://github.com/nlpub/watset-java.
Citation
- Ustalov, D., Panchenko, A., Biemann, C., Ponzetto, S.P.: Watset: Local-Global Graph Clustering with Applications in Sense and Frame Induction. Computational Linguistics 45(3), 423–479 (2019)
@article{Ustalov:19:cl,
author = {Ustalov, Dmitry and Panchenko, Alexander and Biemann, Chris and Ponzetto, Simone Paolo},
title = {{Watset: Local-Global Graph Clustering with Applications in Sense and Frame Induction}},
journal = {Computational Linguistics},
year = {2019},
volume = {45},
number = {3},
pages = {423--479},
doi = {10.1162/COLI_a_00354},
publisher = {MIT Press},
issn = {0891-2017},
language = {english},
}
Metadata
Release files for chinese-whispers 0.7.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chinese-whispers-0.7.3.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chinese_whispers-0.7.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / chinese-whispers-0.7.3.tar.gz
| Download URL | chinese-whispers-0.7.3.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ef6a2df2bf5f88d9a6b5b7a67844c60223f669352aa3a266763b43aa8cda856
|
|
BLAKE2b-256 checksum How to use checksums |
a69e372e3c15a82bd49faedccd4c2b35ecddf9ce24b8dbc6fb244ccb00e50361
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
|
Release files / chinese_whispers-0.7.3-py3-none-any.whl
| Download URL | chinese_whispers-0.7.3-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c11e6ce7e7559fea275cb1c6ea80ae8b36f1058cd2b0af97d57ae35328a20ef
|
|
BLAKE2b-256 checksum How to use checksums |
b81786fc9c1b5bdb2686ce0aa83044d8692d0e7361b8791802d7bef2cc0ef01f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
|