Improve TypedSimilarity algorithm and update test.
Merge pull request #983 from twitter/klin_typed_sim_imp

Improve TypedSimilarity algorithm and update test.