Skip to main content

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.

Unit Tests Read the Docs PyPI Version Conda Version

Installation

  • pip: pip install chinese-whispers
  • Anaconda: conda install -c conda-forge chinese-whispers
  • Mamba: mamba install -c conda-forge chinese-whispers

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\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

@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 (c) 2018–2023 Dmitry Ustalov. See LICENSE for details.

Metadata

Release files for chinese-whispers 0.8.2.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chinese-whispers 0.8.2.post1
File Size Uploaded Provenance Actions
chinese_whispers-0.8.2.post1.tar.gz 7.8 kB Without provenance Details for chinese_whispers-0.8.2.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chinese-whispers 0.8.2.post1
File Interpreter ABI Platform Actions
chinese_whispers-0.8.2.post1-py3-none-any.whl Python 3 none any Details for chinese_whispers-0.8.2.post1-py3-none-any.whl

Total release size: 16.7 kB

Release files / chinese_whispers-0.8.2.post1.tar.gz

Download URL chinese_whispers-0.8.2.post1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ed4a5bc364ff44dc176be2616ed1f90acd4a2997df360b398751b08b8c948acf
BLAKE2b-256 checksum
How to use checksums
d04944f83767a74a5f3306f8f0b8dd106fbbd5e98ceda0fd3823dd06e25ba671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / chinese_whispers-0.8.2.post1-py3-none-any.whl

Download URL chinese_whispers-0.8.2.post1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
014084d6c1c2d8a7f7a57acfbaf933e1b463bfd1a525b33d4affe6df8a9a2a79
BLAKE2b-256 checksum
How to use checksums
332a5fe894a13efb2d690570e069a1ce0370efc4e37e9e3f317186ee45d18ef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Security for chinese-whispers 0.8.2.post1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page