Skip to content

Commit

Permalink
logging comparison vec size
Browse files Browse the repository at this point in the history
  • Loading branch information
nikit-srivastava committed Oct 10, 2018
1 parent 5e04aac commit 30fe9a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ private String getClosestEntry(float[] vector, String subKey) {
}
tl.printTime(1, "Setting Bits");
tl.logTime(1);
int[] nearbyIndexes = new int[finBitSet.cardinality()];
int nearbyWordsCount = finBitSet.cardinality();
LOG.info("Number of nearby words: "+nearbyWordsCount);
int[] nearbyIndexes = new int[nearbyWordsCount];
int j = 0;
for (int i = finBitSet.nextSetBit(0); i >= 0; i = finBitSet.nextSetBit(i + 1), j++) {
// operate on index i here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ private String getClosestEntry(float[] vector, String subKey) {
}
tl.printTime(1, "Setting Bits");
tl.logTime(1);
int[] nearbyIndexes = new int[finBitSet.cardinality()];
int nearbyWordsCount = finBitSet.cardinality();
LOG.info("Number of nearby words: "+nearbyWordsCount);
int[] nearbyIndexes = new int[nearbyWordsCount];
int j = 0;
for (int i = finBitSet.nextSetBit(0); i >= 0; i = finBitSet.nextSetBit(i + 1), j++) {
// operate on index i here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import org.aksw.word2vecrestful.utils.Cfg;
import org.aksw.word2vecrestful.utils.Word2VecMath;
import org.aksw.word2vecrestful.word2vec.W2VNrmlMemModelKMeans;
import org.aksw.word2vecrestful.word2vec.Word2VecFactory;
import org.aksw.word2vecrestful.word2vec.Word2VecModel;
Expand Down Expand Up @@ -81,12 +82,18 @@ public void testNbmTime() throws IOException {
totTime += diff;
LOG.info("Query time recorded for Centroid " + (i + 1) + " is " + diff + " milliseconds.");
}
LOG.info(
"Average query time for W2VNrmlMemModelKMeans is : " + (totTime / centroids.length) + " milliseconds");
LOG.info("Average query time for W2VNrmlMemModelKMeans is : " + (totTime / centroids.length) + " milliseconds");
LOG.info("Predicted Words are :" + lrModelWords);
float percVal = NrmlzdMdlPrfmncTester.calcPercScore(correctWords, lrModelWords);
LOG.info("Score for Test is : " + percVal + "%");
lrModelWords.clear();

String word1 = "By_Jonas_Elmerraji";
String word2 = "%_#F########_3v.jsn";
float[] word1Vec = nbm.word2vec.get("By_Jonas_Elmerraji");
float[] word2Vec = nbm.word2vec.get("%_#F########_3v.jsn");
LOG.info("Cosine Similarity between " + word1 + " & " + word2 + " is : "
+ Word2VecMath.cosineSimilarity(word1Vec, word2Vec));
}

private static float[][] fetchWordsVec(String[] words, Word2VecModel nbm) {
Expand Down

0 comments on commit 30fe9a0

Please sign in to comment.