From c5dbeb28fa8f772cebf5cf655766aff029d62f92 Mon Sep 17 00:00:00 2001 From: "nikit91@gmail.com" Date: Thu, 18 Oct 2018 13:35:43 +0200 Subject: [PATCH] null check added --- .../aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java index 82a2b23..30bcd8b 100644 --- a/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java +++ b/src/main/java/org/aksw/word2vecrestful/word2vec/W2VNrmlMemModelKMeans.java @@ -181,7 +181,10 @@ 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]); + BitSet tempBs = csBucketContainer[i][indx]; + if(tempBs!=null) { + curBs.or(tempBs); + } int temIndx = indx + 1; if (temIndx < csBucketContainer[i].length && csBucketContainer[i][temIndx] != null) { curBs.or(csBucketContainer[i][temIndx]);