From 7dcfff3c1f20a4644f9ae6c9579267fd784bad13 Mon Sep 17 00:00:00 2001 From: "nikit91@gmail.com" Date: Thu, 18 Oct 2018 14:07:19 +0200 Subject: [PATCH] config change --- .../word2vecrestful/word2vec/W2VNrmlMemModelBinSrch.java | 8 ++++++-- .../word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelBinSrch.java b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelBinSrch.java index 32aec58..c3344d6 100644 --- a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelBinSrch.java +++ b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelBinSrch.java @@ -27,7 +27,7 @@ public class W2VNrmlMemModelBinSrch implements GenWord2VecModel { private float[][] vecArr; private int[] indxArr; private double[] simValArr; - private int compareVecCount = 100; + private int compareVecCount = 150; private int bucketCount = 10; private BitSet[][] csBucketContainer; // TODO : Remove this @@ -176,7 +176,9 @@ private String getClosestEntry(float[] vector, String subKey) { double cosSimVal = Word2VecMath.cosineSimilarityNormalizedVecs(curCompVec, vector); int indx = getBucketIndex(cosSimVal); BitSet curBs = new BitSet(word2vec.size()); - curBs.or(csBucketContainer[i][indx]); + if(csBucketContainer[i][indx]!=null) { + curBs.or(csBucketContainer[i][indx]); + } int temIndx = indx + 1; if (temIndx < csBucketContainer[i].length && csBucketContainer[i][temIndx] != null) { curBs.or(csBucketContainer[i][temIndx]); @@ -209,8 +211,10 @@ private String getClosestEntry(float[] vector, String subKey) { closestWord = findClosestWord(nearbyIndexes, vector); tl.printTime(1, "finding closest word"); } catch (Exception e) { + LOG.error("Exception has occured while finding closest word."); e.printStackTrace(); } + LOG.info("Closest word found is: "+closestWord); return closestWord; } diff --git a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java index b7c6a69..30bcd8b 100644 --- a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java +++ b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java @@ -38,7 +38,7 @@ public class W2VNrmlMemModelKMeans implements GenWord2VecModel { private String[] wordArr; private float[][] vecArr; private int compareVecCount = 100; - private int bucketCount = 20; + private int bucketCount = 10; private int kMeansMaxItr = 5; private BitSet[][] csBucketContainer; private String vecFilePath = "data/kmeans/comparison-vecs.csv";