Articles → NLP → Similarity Function In Spacy
Similarity Function In Spacy
Purpose
Example
import spacy
nlp = spacy.load("en_core_web_md")
word1 = nlp("king")
word2 = nlp("queen")
word3 = nlp("apple")
print("The similarity between king and queen is:", word1.similarity(word2)) # high
print("The similarity between king and apple is:", word1.similarity(word3)) # low
Output
| Posted By - | Karan Gupta |
| |
| Posted On - | Wednesday, January 21, 2026 |