Advertisement
iGrind

Untitled

Jan 26th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.80 KB | None | 0 0
  1. scoredItems map { case (scoredItemId, scoredPaths) =>
  2.       val initialGroup = ScoredItemGroup(0, 0)
  3.       val finalGroup = queryOnts.foldLeft(initialGroup) { case (currentGroup, (queryOnt, queryOntWeight)) =>
  4.         scoredPaths.get(queryOnt.id) match {
  5.           case Some(value) if value.signum == queryOntWeight.signum =>
  6.             ScoredItemGroup(currentGroup.positive + 1, currentGroup.negative)
  7.           case Some(value) if value.signum != queryOntWeight.signum =>
  8.             ScoredItemGroup(currentGroup.positive, currentGroup.negative + 1)
  9.           case _ =>
  10.             currentGroup
  11.         }
  12.       }
  13.  
  14.       //Adding scored item to group
  15.       val ontsInGroup = scoredGroups.getOrElse(finalGroup, List.empty[ObjectId])
  16.       scoredGroups.update(finalGroup, ontsInGroup :+ scoredItemId)
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement