grouplens/lenskit — pull request #365 by elehack (2013-09-24 01:44:42+00:00)
Title: Fix scorer NPEs

This addresses #363, making scorers (particularly the item-item scorer, but it affects many of them) properly deal with missing users.

I made the following decisions:

1. Preserve current behavior of DAOs returning `null` for nonexistent users/items
2. Retain requirement that the history provided to a summarizer be non-`null`
3. Make each scorer handle null profiles properly

(1) is basically forced by our compatibility policies, at least in the short term. Deciding (2) the other way would decrease code duplication, but decrease generality: it means the history summarizer cannot depend on the user/item ID in the case of a nonexistent user.

The approach I have taken maximizes information potential: the DAO can distinguish between nonexistent users and users with no history, and the summarizer gets the user ID even when the user doesn't exist or has an empty history (although it cannot distinguish these two cases).

An alternative, arguably better mechanism would be to change both the summarizer and DAO interface to keep user IDs and histories separate. But that will be API-breaking.