@@ -0,0 +1,2049 @@
+package edu.antonym;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport edu.antonym.prototype.VectorEmbedding;%0A%0Apublic class RawPILSAVec implements VectorEmbedding %7B%0A%0A%09List%3CString%3E words;%0A%09Map%3CString, Integer%3E ids;%0A%09Map%3CInteger, float%5B%5D%3E vectors;%0A%09int OOVindex;%0A%09%0A%09static final int dim = 300;%0A%09static final String lsaPath = %22data/PILSA/s03.04b--06.lsa.k300.txt%22;%0A%09static final String s2netPath = %22s03.04b--06.s2net.fromLSA.k300.pickle.r11.txt%22;%0A%09%0A%0A%09public RawPILSAVec(Boolean useS2net) throws IOException %7B%0A%09%09words = new ArrayList%3CString%3E();%0A%09%09ids = new HashMap%3CString, Integer%3E();%0A%09%09vectors = new HashMap%3CInteger, float%5B%5D%3E();%0A%09%09%0A%09%09String line;%0A%09%09BufferedReader br;%0A%09%09if (!useS2net) %7B%0A%09%09%09br = new BufferedReader(new InputStreamReader(new FileInputStream(lsaPath)));%09%09%09%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09br = new BufferedReader(new InputStreamReader(new FileInputStream(s2netPath)));%0A%09%09%7D%0A%09%09int index = 0; // TODO for now create own lookup dictionary%0A%09%09while ((line = br.readLine()) != null) %7B%0A%09%09    int pos = line.indexOf('%5Ct');%0A%09%09    String word = line.substring(0, pos);%0A%09%09    String%5B%5D svec = line.substring(pos+1).split(%22 %22, dim);%0A%09%09    float%5B%5D vec = new float%5B300%5D;%0A%09%09    for (int i = 0; i %3C dim; i++) %7B%0A%09%09    %09vec%5Bi%5D = Float.parseFloat(svec%5Bi%5D);%0A%09%09    %7D%0A%09%09    words.add(word);%0A%09%09    ids.put(word, index);%0A%09%09    index++;%0A%09%09    vectors.put(ids.get(word), vec);%0A%09%09%7D%0A%09%09br.close();%0A%09%7D%0A%0A%0A%09@Override%0A%09public int getDimension() %7B%0A%09%09return dim;%0A%09%7D%0A%09%0A%09public int getVocabSize() %7B%0A%09%09return words.size();%0A%09%7D%0A%0A%0A%09@Override%0A%09public float%5B%5D getVectorRep(int word) %7B%09%09%0A%09%09return vectors.get(word);%0A%09%7D%0A%0A%0A%09@Override%0A%09public int findClosestWord(float%5B%5D vector) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09return 0;%0A%09%7D%09%0A%09%0A%0A%09public static void main(String%5B%5D args) throws IOException %7B%0A%09%09RawPILSAVec word2vec = new RawPILSAVec(false);%0A%09%09System.out.println(word2vec.getVocabSize());%0A%09    System.exit(0);%0A%09%7D%0A%7D%0A

add raw PILSA vectors