From 36678e6c0aea407d6fac27c24435ae00f447762b Mon Sep 17 00:00:00 2001 From: Peter Karman Date: Wed, 18 Oct 2017 17:05:52 -0500 Subject: [PATCH] check for NaN on score --- lib/fuzzy_tools/tf_idf_index.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fuzzy_tools/tf_idf_index.rb b/lib/fuzzy_tools/tf_idf_index.rb index cb1ede5..b9a8ddb 100644 --- a/lib/fuzzy_tools/tf_idf_index.rb +++ b/lib/fuzzy_tools/tf_idf_index.rb @@ -37,7 +37,7 @@ def unsorted_scored_results(query) score = self.score(query_weighted_tokens, candidate_tokens) - [candidate, score] + [candidate, (score.nan? ? 0.0 : score)] end end @@ -103,4 +103,4 @@ def weight_function end end end -end \ No newline at end of file +end