Skip to content

Instantly share code, notes, and snippets.

@grampelberg
Created January 13, 2014 19:45
Show Gist options
  • Save grampelberg/8406646 to your computer and use it in GitHub Desktop.
Save grampelberg/8406646 to your computer and use it in GitHub Desktop.
def getAverageSentiment(responses: Seq[Response], label: String): Double = responses.map { response =>
(response.json \\ label).head.as[Double]
}.sum / responses.length.max(1) // avoid division by zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment