该包提供了一些 shell 脚本来预处理数据并拟合模型:您必须从 shell 调用它们,即在 Julia 之外。
# Install the package
julia -e 'Pkg.clone("https://github.com/sbos/AdaGram.jl.git")'
julia -e 'Pkg.build("AdaGram")'
# Download some text
wget http://www.gutenberg.org/ebooks/100.txt.utf-8
# Tokenize the text, and count the words
~/.julia/v0.3/AdaGram/utils/tokenize.sh 100.txt.utf-8 text.txt
~/.julia/v0.3/AdaGram/utils/dictionary.sh text.txt dictionary.txt
# Train the model
~/.julia/v0.3/AdaGram/train.sh text.txt dictionary.txt model
然后,您可以使用来自 Julia 的模型:
using AdaGram
vm, dict = load_model("model");
expected_pi(vm, dict.word2id["hamlet"])
nearest_neighbors(vm, dict, "hamlet", 1, 10)