Similarity of sentences in python
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-LevenshteinTo 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 enHere’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
