Skip to content

Instantly share code, notes, and snippets.

@colinpollock
Created October 5, 2019 23:54
Show Gist options
  • Save colinpollock/c555ea2b88866e0187b94c3d9e542cba to your computer and use it in GitHub Desktop.
Save colinpollock/c555ea2b88866e0187b94c3d9e542cba to your computer and use it in GitHub Desktop.
import spacy
nlp = spacy.load('en_vectors_web_lg')
text1 = 'The medical field is moving forward rapidly.'
text2 = 'Medicine is vital to the industry.'
text3 = 'Reggie Miller is a basketball player.'
doc1 = nlp(text1)
doc2 = nlp(text2)
doc3 = nlp(text3)
for doc in (doc2, doc3):
print(doc1.similarity(doc))
# Prints out:
# 0.8917278032126783
# .616120289899652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment