Created
February 4, 2016 07:27
-
-
Save pjazdzewski1990/fdf1983346141132427c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def countSimilarity(target: Array[String], rdd: RDD[(String, Seq[String])]): RDD[(String, Double, Seq[String])] = { | |
rdd.map { | |
case (author, words) => | |
val matching = (for { | |
w <- words | |
t <- target | |
if t.length > 3 && w.length > 3 //remove short words | |
score = scoreSimilarity(t, w) | |
if score > 0.65d //remove accidental, short matches | |
} yield (score, w)).distinct //remove duplicated results | |
val score = Math.min(matching.map(_._1).sum, target.length) | |
val wordsMatched = matching.map(_._2) | |
(author, score, wordsMatched) | |
}.sortBy(_._2, false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment