Last active
April 16, 2018 08:46
-
-
Save tondrej/14fb685f2dd1a730f3ede80bd0c1bc80 to your computer and use it in GitHub Desktop.
FastText library JavaScript usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = "C:\\Data\\fasttext\\wiki\\enwik9.bin"; | |
console.log("Loading file \"%s\"...", model); | |
fasttext.loadModel(model); | |
console.log("done."); | |
console.log("Computing vectors..."); | |
vectors = fasttext.precomputeVectors(); | |
try { | |
console.log("done."); | |
while (true) { | |
positive = prompt('positive words:'); | |
if (positive == undefined) | |
break; | |
negative = prompt("negative words:"); | |
fasttext.nn2(vectors, positive, negative, 5, (word, score) => { | |
console.log("\"%s\": %s", word, score); | |
}); | |
} | |
} finally { | |
fasttext.releaseVectors(vectors); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment