Created
May 9, 2016 19:56
-
-
Save tmsimont/2cbdaef344c402c3d26934243efa323c to your computer and use it in GitHub Desktop.
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
import org.deeplearning4j.models.embeddings.loader.WordVectorSerializer; | |
import org.deeplearning4j.models.embeddings.wordvectors.WordVectors; | |
import org.nd4j.linalg.factory.Nd4j; | |
import java.io.FileNotFoundException; | |
import java.util.*; | |
import java.io.File; | |
public class TestWord2Vec { | |
private WordVectors wordVectors; | |
public static void main(String[] args) throws Exception { | |
TestWord2Vec t = new TestWord2Vec(); | |
t.test(); | |
} | |
public void test() throws FileNotFoundException { | |
double foo[] = {0.07662966102361679,-0.15683715045452118,-0.09958696365356445,-0.5582161545753479,0.13371440768241882,0.145623579621315,0.21786752343177795,0.037577372044324875,0.010457501746714115,-0.01822548173367977,0.07133414596319199,0.10989873111248016,-0.004703379701822996,0.24611054360866547,0.1842348575592041,-0.03501710295677185,-0.28120318055152893,0.3167855143547058,-0.021439414471387863,-0.10285429656505585,0.31841185688972473,-0.047598835080862045,-0.4360429048538208,0.19820629060268402,0.02021874487400055,-0.3637917637825012,-0.19628046452999115,0.15301348268985748,-0.001860927906818688,-0.28961265087127686,-0.04005725681781769,-0.28192153573036194,0.12212064117193222,0.21076101064682007,0.006745698396116495,0.09953082352876663,-0.13900607824325562,-0.034233808517456055,0.10835923999547958,0.06281674653291702,0.04705433174967766,0.02800493873655796,-0.03654691204428673,0.0717429369688034,0.21126438677310944,0.061982423067092896,0.015610983595252037,0.18408675491809845,-0.020207442343235016,-0.27804282307624817,0.11301705986261368,0.08801347017288208,0.03192387521266937,-0.1792324334383011,0.04980972781777382,0.22482949495315552,-0.06346631050109863,-0.10168977081775665,-0.019589971750974655,-0.012582260183990002,0.33665329217910767,0.0025205675046890974,-0.009461941197514534,0.3833000659942627,-0.01715477555990219,-0.06369662284851074,0.01154022105038166,0.007030464708805084,-0.0708678588271141,-0.017094450071454048,0.12688760459423065,0.5028663277626038,-0.1583442986011505,-0.28018856048583984,0.1671013981103897,-0.0893111377954483,-0.04531631991267204,0.0687960684299469,0.34074172377586365,-0.09085529297590256,6.943101761862636E-4,0.30315786600112915,0.09421809762716293,-0.2649470269680023,-0.3064609467983246,0.2695615589618683,-0.11702729016542435,-0.3704732060432434,-0.20678825676441193,0.31280359625816345,0.25116559863090515,-0.1313193440437317,-0.11854994297027588,0.17942380905151367,-0.2513428032398224,0.2257017344236374,-0.1161293312907219,0.010692618787288666,-0.09326448291540146,-0.08194870501756668}; | |
wordVectors = WordVectorSerializer.loadTxtVectors(new File("word-vectors.txt")); | |
Collection<String> lst = wordVectors.wordsNearest(Nd4j.create(foo), 10); | |
System.out.println(lst); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment