API Reference

To make the usage simpler spacy provides custom extensions which a library can use. This makes it easier for the user to get the desired data. The below tables summaries the extensions.

spacy.Doc extensions

ExtensionTypeDescriptionDefault
doc._.polarityFloatThe polarity of the document. The polarity score is a float within the range [-1.0, 1.0].None
doc._.subjectivityFloatThe subjectivity of the document. The subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.None
doc._.assessmentstupleReturn a tuple of form (polarity, subjectivity, assessments ) where polarity is a float within the range [-1.0, 1.0], subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective, and assessments is a list of polarity and subjectivity scores for the assessed tokens.None

spacy.Span extensions

ExtensionTypeDescriptionDefault
span._.polarityFloatThe polarity of the span. The polarity score is a float within the range [-1.0, 1.0].None
span._.subjectivityFloatThe subjectivity of the span. The subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.None
span._.assessmentstupleReturn a tuple of form (polarity, subjectivity, assessments ) where polarity is a float within the range [-1.0, 1.0], subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective, and assessments is a list of polarity and subjectivity scores for the assessed tokens.None

spacy.Token extensions

ExtensionTypeDescriptionDefault
token._.polarityFloatThe polarity of the token. The polarity score is a float within the range [-1.0, 1.0].None
token._.subjectivityFloatThe subjectivity of the token. The subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.None
token._.assessmentstupleReturn a tuple of form (polarity, subjectivity, assessments ) where polarity is a float within the range [-1.0, 1.0], subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective, and assessments is a list of polarity and subjectivity scores for the assessed tokens.None