spaCy - Token.check_flag Method



This method is used to check the value of a Boolean flag.

Argument

The table below explains its argument −

NAME TYPE DESCRIPTION
flag_id Int It represents the attribute ID of the flag which is to be checked.

Example 1

An example of Token.check_flag method is given below −

import spacy
nlp_model = spacy.load("en_core_web_sm")
from spacy.attrs import IS_TITLE
doc = nlp_model("This is TutorialsPoint.com.")
token = doc[0]
token.check_flag(IS_TITLE)

Output

The output is mentioned below −

True

Example 2

An another example of Token.check_flag method is given below −

token = doc[1]
token.check_flag(IS_TITLE)

Output

False
spacy_container_token_class.htm
Advertisements