handle_negation {text2emotion}R Documentation

Handle Negation in Token List

Description

This function processes a character vector of tokens and handles negations by combining the word "not" with the immediately following word (e.g., "not happy" becomes "not_happy"). This technique helps to better preserve sentiment polarity during text analysis.

Usage

handle_negation(tokens)

Arguments

tokens

A character vector of tokens (individual words).

Details

The negation handling procedure follows these steps:

This method is especially useful in sentiment analysis tasks where the presence of negations can invert the sentiment polarity of words.

Value

A character vector of tokens with negations handled by combining "not" with the next word.

Examples

handle_negation(c("i", "am", "not", "happy"))
# Returns: c("i", "am", "not_happy")

handle_negation(c("this", "is", "not", "good", "but", "not", "terrible"))
# Returns: c("this", "is", "not_good", "but", "not_terrible")

handle_negation(c("nothing", "to", "worry", "about"))
# Returns: c("nothing", "to", "worry", "about")


[Package text2emotion version 0.1.0 Index]