An implementation of the Chinese Whispers clustering algorithm.
Project description
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.
Installation
Usage
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\t
target\t
weight).
# 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/.
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},
}
Copyright
Copyright (c) 2018–2024 Dmitry Ustalov. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chinese_whispers-0.9.0rc2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f7755bccbdda9f51398c38e0ea4b78651427620a43737a495db10a45f88689a |
|
MD5 | 4ba2b1c63140fb9087a7d52df21c8b19 |
|
BLAKE2b-256 | 1820cd3aac0cbd242c14bde0823d3e35cc5728345dbff5c6a40bc1b635431626 |
Hashes for chinese_whispers-0.9.0rc2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0273987c96411c3097f29ce7a5fadb493af042736d4c2fcfa0a9dab8c9150afd |
|
MD5 | efa50137c69bcfa4a41f00059896f5c3 |
|
BLAKE2b-256 | b4f76c6b79a75cf3bed514326921f29c68e06aac39adab48b8d980db2b7e1de9 |