spaCy - Doc.vector_norm Property



This doc property represents the L2 norm of the document’s vector representation.

Example 1

Refer the example of Doc.vector_norm property given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
doc1 = nlp_model("The website is Tutorialspoint.com.")
doc2 = nlp_model("It is having best technical tutorials.")
doc1.vector_norm

Output

11.126218933074995

Example 2

Given below is an example of Doc.vector_norm property −

doc2.vector_norm

Output

9.99526963324649

Example 3

Here is another example of Doc.vector_norm property.

doc1.vector_norm != doc2.vector_norm

Output

True
spacy_doc_class_contextmanager_and_property.htm
Advertisements