Created
February 4, 2016 07:25
-
-
Save pjazdzewski1990/f593d80194e2e665b253 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
def findSimilar(target: String, rdd: RDD[(String, Seq[String])]): RDD[(String, Double, Seq[String])] = { | |
val mapped = rdd.map { | |
case (author, commits) => | |
val words = commits.flatMap(_.split(" ")) | |
(author, words) | |
} | |
countSimilarity(target.split(" "), mapped) | |
} | |
private def findSimilar(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 | |
score = scoreSimilarity(t, w) | |
} yield (score, w)) | |
val score = matching.map(_._1).sum | |
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