7 releases

Uses old Rust 2015

0.3.3 Nov 4, 2019
0.3.2 Feb 9, 2019
0.3.1 Dec 23, 2018
0.3.0 Sep 9, 2017
0.1.0 Feb 3, 2016

#158 in Machine learning

Download history 18/week @ 2023-02-05 26/week @ 2023-02-12 29/week @ 2023-02-19 16/week @ 2023-02-26 26/week @ 2023-03-05 17/week @ 2023-03-12 12/week @ 2023-03-19 6/week @ 2023-03-26 9/week @ 2023-04-02 17/week @ 2023-04-09 16/week @ 2023-04-16 6/week @ 2023-04-23 24/week @ 2023-04-30 25/week @ 2023-05-07 13/week @ 2023-05-14 8/week @ 2023-05-21

71 downloads per month
Used in rsnltk

MIT license

14KB
298 lines

word2vec Build Status

Rust interface to word2vec word vectors.

This crate provides a way to read a trained word vector file from word2vec. It doesn't provide model training and hence requires a already trained model.

Documentation

Documentation is available at https://github.com/DimaKudosh/word2vec/wiki

Example

Add this to your cargo.toml:

[dependencies]
# …
word2vec = "0.3.3"

Example for word similarity and word clusters:

extern crate word2vec;

fn main(){
	let model = word2vec::wordvectors::WordVector::load_from_binary(
		"vectors.bin").expect("Unable to load word vector model");
	println!("{:?}", model.cosine("snow", 10));
	let positive = vec!["woman", "king"];
	let negative = vec!["man"];
	println!("{:?}", model.analogy(positive, negative, 10));
	
	let clusters = word2vec::wordclusters::WordClusters::load_from_file(
		"classes.txt").expect("Unable to load word clusters");
	println!("{:?}", clusters.get_cluster("belarus"));
	println!("{:?}", clusters.get_words_on_cluster(6));
}

Dependencies

~120KB