open-city/dedupe — pull request #105 by markhuberty (2013-03-22 13:44:06+00:00)
Title: Add tfidf cosine similarity and update patent example to use it appropriately

Per Forest's [comment](https://github.com/open-city/dedupe/pull/94#issuecomment-15194459) on issue 94, code is attached for the following:

1. Provides a tfidf-weighted cosine similarity function
2. Incorporates that similarity for use in the class comparisons in the patent file
3. Provides passing tests

The cosine.pyx file provides both a pure closure version of the cosine similarity function and a Class version. The class version will serialize properly at this step:

``` python
deduper.writeSettings(settings_file)
```

Whereas the closure file will not. `%timeit` shows that the closure function is slightly faster (~800ns vs 1.16us).