text similarity function in the spacy package python code example
Example: sentence similarity spacy
# credit to spacy documentation
import spacy
# replace your_language_model with:
# en_core_web_sm(_md, _lg for different size) for english
# it_core_news_sm for italian
# etc. see spacy docs
nlp = spacy.load('your_language_model')
# it works with single words too
sent1 = nlp('Your first sentence')
sent2 = nlp('Your second sentence')
# similarity ranges from 0 (totally dissimilar) to 1 (identical)
sent1.similarity(sent2)