- spaCy Tutorial
- spaCy - Home
- spaCy - Introduction
- spaCy - Getting Started
- spaCy - Models and Languages
- spaCy - Architecture
- spaCy - Command Line Helpers
- spaCy - Top-level Functions
- spaCy - Visualization Function
- spaCy - Utility Functions
- spaCy - Compatibility Functions
- spaCy - Containers
- Doc Class ContextManager and Property
- spaCy - Container Token Class
- spaCy - Token Properties
- spaCy - Container Span Class
- spaCy - Span Class Properties
- spaCy - Container Lexeme Class
- Training Neural Network Model
- Updating Neural Network Model
- spaCy Useful Resources
- spaCy - Quick Guide
- spaCy - Useful Resources
- spaCy - Discussion
spaCy - Span.similarity Method
This method is used to make a semantic similarity estimate. The default is cosine similarity using an average of word vectors.
Argument
The table below explains its argument −
NAME | TYPE | DESCRIPTION |
---|---|---|
other | - | It is the object with which the comparison will be done. By default, it will accept Doc, Span, Token, and Lexeme objects. |
Example
An example of Span.similarity method is as follows −
import spacy nlp_model = spacy.load("en_core_web_sm") doc = nlp_model("red car and black bike") red_car = doc[:2] black_bike = doc[3:] car_bike = red_car.similarity(black_bike) bike_car = black_bike.similarity(red_car) car_bike == bike_car
Output
When you run the code, you will see the following output −
True
spacy_container_span_class.htm
Advertisements
To Continue Learning Please Login
Login with Google