Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python sets 
Python :: use django taggit in template 
Python :: How to develop a UDP echo server in python? 
Python :: append to list py 
Python :: bar plot bokeh 
Python :: pandas isin 
Python :: replace list python 
Python :: how append a directory based on current directory python 
Python :: get tweet by its id 
Python :: flatten list python 
Python :: infinite while python 
Python :: python nominatim get latitude from address 
Python :: transpose of list in python 
Python :: generate random integers python 
Python :: python convert to hmac sha256 
Python :: print with no newline 
Python :: prime number using python 
Python :: method for detect that a float number is integer in python 
Python :: circle circumference python 
Python :: python try except continue loop 
Python :: how to exit program in python 
Python :: open word document python 
Python :: python3 lowercase 
Python :: python regex get word after string 
Python :: crop black border python 
Python :: python string trim 
Python :: how to run fastapi with code python 
Python :: how to get the parent class using super python 
Python :: what is a framework 
Python :: python yeild 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =