From: <dfl...@us...> - 2013-10-24 13:47:17
|
Revision: 4128 http://sourceforge.net/p/dl-learner/code/4128 Author: dfleischhacker Date: 2013-10-24 13:47:14 +0000 (Thu, 24 Oct 2013) Log Message: ----------- Fix NPE in VSMCosineDocumentSimilarity by returning empty set if unable to produce a vector Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/VSMCosineDocumentSimilarity.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/VSMCosineDocumentSimilarity.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/VSMCosineDocumentSimilarity.java 2013-10-24 13:40:06 UTC (rev 4127) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/VSMCosineDocumentSimilarity.java 2013-10-24 13:47:14 UTC (rev 4128) @@ -182,6 +182,10 @@ private Map<String, Double> getTermWeights(IndexReader reader, int docId) throws IOException { Terms vector = reader.getTermVector(docId, CONTENT); + //TODO: not sure if this is reasonable but it prevents NPEs + if (vector == null) { + return new HashMap<String, Double>(); + } TermsEnum termsEnum = vector.iterator(null); Map<String, Double> weights = new HashMap<String, Double>(); BytesRef text = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |