This block is more readable if 

~~~
val r = if (x.rating > 1.0) 1.0 else if (x.rating < 0.0) 0.0 else x.rating
((x.user, x.product), r)
~~~