Skip to content

Commit

Permalink
Return 0 count for frequency query when term is not matched in SPARQL…
Browse files Browse the repository at this point in the history
… query. Fixes #191.
  • Loading branch information
balhoff committed Mar 26, 2020
1 parent 6924182 commit 2543398
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/scala/org/phenoscape/kb/Similarity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 2543398

Please sign in to comment.