Learn R Programming

sumup (version 1.0.1)

get_polarity: Get Polarity from Grasp

Description

This function computes the polarity score for a given sentence using the Grasp sentiment analysis model. It applies specific logic based on the comment type (e.g., improvement suggestions) and language (Dutch, English, German, or French).

Usage

get_polarity(grasp, sentence, comment_type, language)

Value

A numeric value representing the sentiment polarity of the sentence. Positive values indicate positive sentiment, negative values indicate negative sentiment, and zero indicates neutral sentiment.

Arguments

grasp

The imported Grasp model, which is used to compute sentiment polarity.

sentence

A character string representing the sentence for which sentiment polarity needs to be calculated.

comment_type

A string that indicates the type of feedback (e.g., "verbeter" for improvement). This influences sentiment adjustment in Dutch language.

language

A string indicating the language of the sentence ("nl" for Dutch, "en" for English, "de" for German, "fr" for French).

Details

For Dutch sentences, the function applies specific transformations (such as removing certain words like "naar" and "gemaakt") before calculating sentiment. It also handles feedback sentences marked as "verbeter" (improvement suggestions) by adding the word "suboptimal" to adjust the sentiment analysis for improvement-type feedback.