Giter Club home page Giter Club logo

chinese-whispers's Introduction

Build Status Release

Chinese Whispers

This is an implementation of the Chinese Whispers (CW) graph clustering algorithm. For an introduction or if you need to reference the algorithm, use this paper: http://wortschatz.uni-leipzig.de/~cbiemann/pub/2006/BiemannTextGraph06.pdf.

This project contains implementation of the CW algorithm. You can run it for each ego network of the graph (e.g. to perform word sense induction or for segmenting a social ego network) or perform global clustering of the graph. In the first case, you will obtain one clustering for each node, in the latter case you will obtain one set of clusters per graph.

Running from the command line

Compile and run the algorithm in the ego network mode:

git clone https://github.com/tudarmstadt-lt/chinese-whispers.git
cd chinese-whispers && mvn package
java -cp target/chinese-whispers.jar de.tudarmstadt.lt.wsi.WSI

Run the algorithm in the ego network mode with the default parameters for word sense induction

run.sh <distributional-thesaurus.csv>

For an example of how to use the CW clustering algorithm for word sense induction, compile the code as shown above and download example data, like this word similarity graph extracted from a 120-million-lines English news corpus taken from the JoBimText project: http://sourceforge.net/projects/jobimtext/files/data/models/en_news120M_stanford_lemma/LMI_p1000_l200.gz.

The data is formatted in ABC format, meaning that each row contains an edge of the graph, and each row contains three columns separated by a whitespace: from, to, and the edge weight. The provided data should be sorted using, for instance, sort -u. Please note that for undirected graphs each edge should be provided with two rows: from, to, weight and to, from, weight.

Then run the WSI algorithm on the data (making sure you assign enough memory to the VM):

java -Xms4G -Xmx4G -cp target/chinese-whispers.jar de.tudarmstadt.lt.wsi.WSI \
     -in /path/to/LMI_p1000_l200.gz -clustering cw -n 100 -N 100 -out test-output.txt

The output (in our case test-output.txt) is then formatted as follows:

word <TAB> cluster-id <TAB> cluster-label <TAB> cluster-node1 cluster-node2 ...
word <TAB> cluster-id <TAB> cluster-label <TAB> cluster-node1 cluster-node2 ...
...

In addition, a default implementation of chinese-whispers for global clustering is available:

java -Xms4G -Xmx4G -cp target/chinese-whispers.jar de.tudarmstadt.lt.cw.global.CWGlobal \
     -in /path/to/edges.gz -N 1000 -out clusters.csv.gz

N limits how many edges are maximum added per node when building the graph

Using the library from Java code

You may use the CW algorithm directly from your code.

  • add the jitpack Maven dependency
	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
  • add the chinese-whispers dependency
	<dependency>
	    <groupId>com.github.uhh-lt</groupId>
	    <artifactId>chinese-whispers</artifactId>
	    <version>-SNAPSHOT</version>
	</dependency>
  • use the de.tudarmstadt.lt.cw.global.CWGlobal class for global clustering mode and de.tudarmstadt.lt.wsi.WSI for the ego network clustering mode.

chinese-whispers's People

Contributors

alexanderpanchenko avatar dustalov avatar nicolaierbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.