Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Metric for comparing text

Project description

Text Comparer

Uses cosine similarity to give a numerical evaluation of the similarity of two
texts (0 to 1).

This code has a companion blog-post here:

Sample Usage
In [1]: from vectorizer import compare_texts

In [2]: compare_texts('Mary had a little shotgun.', 'Mary loves her shotgun')
Out[2]: 0.66666666666666663

In [3]: compare_texts('John loves Mary.', 'But Mary has a shotgun.')
Out[3]: 0.33333333333333331

The higher score in `2` implies that the first two sentences are more similar
than the second two. A classic tale of the love-linked-list.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for text_comparer, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size text_comparer-0.0.2.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page