diff --git a/src/main/scala/org/phenoscape/kb/Similarity.scala b/src/main/scala/org/phenoscape/kb/Similarity.scala index e03b8272..4bc79b99 100644 --- a/src/main/scala/org/phenoscape/kb/Similarity.scala +++ b/src/main/scala/org/phenoscape/kb/Similarity.scala @@ -303,7 +303,11 @@ object Similarity { } App.executeSPARQLQueryString(query.text, qs => IRI.create(qs.getResource("term").getURI) -> - qs.getLiteral("count").getInt).map(_.toMap) + qs.getLiteral("count").getInt).map(_.toMap).map { result => + val foundTerms = result.keySet + // add in 0 counts for terms not returned by the query + result ++ (terms -- foundTerms).map(_ -> 0) + } } type TermFrequencyTable = Map[IRI, Int]