The Algorithm

I ended up with something that produces a reasonable result on the data I have available. There are Python prototypes here along with the implementation in FavoriteAdapter.

Also included is a DatabaseResetter that can be wired up to the "clear" buttons from #11.

(This PR builds on #5 and #9 so should be merged after those.)