sentence similarity spacy

Solutions on MaxInterview for sentence similarity spacy by the best coders in the world

showing results for - "sentence similarity spacy"
Gaëlle
01 Jan 2018
1# credit to spacy documentation
2
3import spacy
4
5# replace your_language_model with:
6# en_core_web_sm(_md, _lg for different size) for english
7# it_core_news_sm for italian 
8# etc. see spacy docs
9
10nlp = spacy.load('your_language_model') 
11
12# it works with single words too
13sent1 = nlp('Your first sentence')
14sent2 = nlp('Your second sentence')
15
16# similarity ranges from 0 (totally dissimilar) to 1 (identical)
17
18sent1.similarity(sent2)