Skip to content

Instantly share code, notes, and snippets.

@marcovivero
Created September 16, 2015 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcovivero/85d75c8312ce76dfb7f3 to your computer and use it in GitHub Desktop.
Save marcovivero/85d75c8312ce76dfb7f3 to your computer and use it in GitHub Desktop.
private def getScores(doc: String): Array[Double] = {
// Helper function used to normalize probability scores.
// Returns an object of type Array[Double]
// Vectorize query,
val x: Vector = pd.transform(doc)
val z = scoreArray
.map(e => innerProduct(e._2, x.toArray) + e._1)
normalize((0 until z.size).map(k => exp(abs(z.max) + z(k))).toArray)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment