- 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 - Token.similarity Method
This method is used to compute a semantic similarity estimate. The default is cosine over 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 1
An example of Token.similarity method is given below −
import spacy nlp_model = spacy.load("en_core_web_sm") apples, _, bananas = nlp_model("apples and bananas") apples_bananas = apples.similarity(bananas) bananas_apples = bananas.similarity(apples) apples_bananas
Output
0.5698063
Example 2
An another example of Token.similarity method is given below −
bananas_apples
Output
The output is mentioned below −
0.5698063
spacy_container_token_class.htm
Advertisements
To Continue Learning Please Login
Login with Google