Learn R Programming

sumup (version 1.0.1)

sentiment_analysis_grasp: Sentiment Analysis using Grasp

Description

This function performs sentiment analysis on a collection of sentences using the Grasp sentiment analysis model. It computes the polarity of each sentence and returns a table with sentiment scores.

Usage

sentiment_analysis_grasp(documents, sentences, language, grasp_folder)

Value

A data table with the following columns:

  • sentenceid: The ID of the sentence.

  • sentence: The sentence being analyzed.

  • polarity: The sentiment polarity score for the sentence.

  • document: The document identifier to which the sentence belongs.

Arguments

documents

A character vector of document identifiers for which sentiment analysis needs to be performed.

sentences

A data frame containing sentence-level data. This should include columns like sentenceid, sentence, document, submissionid, competencyid, and type (which indicates the type of feedback).

language

A string indicating the language of the sentences to analyze. Supported languages include "nl" (Dutch), "de" (German), and "fr" (French).

grasp_folder

The folder path where the Grasp Python module is located. This is required to run the Grasp sentiment analysis.

Details

The function loads the Grasp sentiment analysis model via reticulate and computes sentiment polarity for each sentence. It performs a special handling for Dutch language sentences that start with certain keywords to prepend "suboptimal" to improve sentiment accuracy. The sentiment is calculated using the pov function from the Grasp model. To use the sentiment setting for Dutch medical education, copy file nl_pov.json, included in this package, and paste it in grasp_folder/lm.