Similarity of sentences in python

Rashid
Rashid
Sep 3, 2018 · 1 min read

For a human it’s quite easy to check if two words or sentences are about the same, for a python script, there are some nice tools out there:

Fuzzywuzzy can be installed over pip:

pip install fuzzywuzzy
pip install python-Levenshtein

To compare two strings, you can use

from fuzzywuzzy import fuzzfuzz.token_set_ratio("My App is about dogs","Here is my app,its about dogs")

[out]:100


Another tool is spacy, it also can be installed over pip:

pip install spacy 
python -m spacy download en

Here’s a shortcut how to use it:

import spacynlp= spacy.load('en')nlp("My App is about dogs").similarity(nlp("Here is my app,its about dogs"))

[out]:0.6773311570561785

For more details on usage, you can also check my project on finding matching apps by app-names and publisher-names in ios and googlestore:

https://github.com/miliar/App_name_matching/blob/master/PD.ipynb

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade