Sentiment#

dacy.sentiment.getters#

Getters extension for extracting sentiment.

dacy.sentiment.getters.da_vader_getter(doc: spacy.tokens.doc.Doc, lemmatization: bool = True) dict[source]#

A getter function for extracting polarity using the Danish implementation of Vader

Parameters
  • doc (Doc) – a SpaCy document

  • lemmatization (bool, optional) – Should it use lemmatization of the document? Defaults to True.

Returns

a dictionary containing positive (pos), negative (neg), neutral (neu) polarity as well as a compound (compound)

Return type

dict

dacy.sentiment.wrapped_models#

Functions for reading in the wrapped version of sentiment models inclduing DaNLP’s sentiment model and Extra Bladet’s senda. This is not meant as a replacement of existing frameworks, but simply as a convenient wrapper around preexisting architecture.

dacy.sentiment.wrapped_models.add_bertemotion_emo(nlp: spacy.language.Language, force_extension: bool = False) spacy.language.Language[source]#

Adds the DaNLP BertEmotion model for emotion classification to the spacy language pipeline.

Parameters
  • nlp (Language) – A spacy text-processing pipeline

  • force_extension (bool, optional) – Set the extension to the doc regardless of whether it already exists. Defaults to False.

Returns

your text processing pipeline with the transformer model included

Return type

Language

dacy.sentiment.wrapped_models.add_bertemotion_laden(nlp: spacy.language.Language, force_extension: bool = False) spacy.language.Language[source]#

Adds the DaNLP BertEmotion model for classifying whether a text is emotionally laden or not.

Parameters
  • nlp (Language) – A spacy text-processing pipeline

  • force_extension (bool, optional) – Set the extension to the doc regardless of whether it already exists. Defaults to False.

Returns

your text processing pipeline with the transformer model included

Return type

Language

dacy.sentiment.wrapped_models.add_berttone_polarity(nlp: spacy.language.Language, force_extension: bool = False) spacy.language.Language[source]#

Adds the DaNLP BertTone model for classification of polarity to the pipeline.

Parameters
  • nlp (Language) – A spacy text-processing pipeline

  • force_extension (bool, optional) – Set the extension to the doc regardless of whether it already exists. Defaults to False.

Returns

your text processing pipeline with the transformer model included

Return type

Language

dacy.sentiment.wrapped_models.add_berttone_subjectivity(nlp: spacy.language.Language, force_extension: bool = False) spacy.language.Language[source]#

Adds the DaNLP BertTone model for detecting whether a statement is subjective to the pipeline.

Parameters
  • nlp (Language) – A spacy text-processing pipeline

  • force_extension (bool, optional) – Set the extension to the doc regardless of whether it already exists. Defaults to False.

Returns

your text processing pipeline with the transformer model included

Return type

Language

dacy.sentiment.wrapped_models.add_senda(nlp: spacy.language.Language, force_extension: bool = False) spacy.language.Language[source]#

Adds the senda tranformer model for classification of polarity to the spacy language pipeline

Parameters
  • nlp (Language) – A spacy text-processing pipeline

  • force_extension (bool, optional) – Set the extension to the doc regardless of whether it already exists. Defaults to False.

Returns

your text processing pipeline with the transformer model included

Return type

Language