predict_emotion_with_emoji: Predict Emotion with Emoji Representation

View source: R/Main.R

predict_emotion_with_emojiR Documentation

Predict Emotion with Emoji Representation

Description

This function takes input text, preprocesses it, extracts TF-IDF features using a pre-trained model, predicts the emotion using a trained classifier, and returns the result with optional emoji representation.

Usage

predict_emotion_with_emoji(text, output_type = "textemoji")

Arguments

text

Character string containing the text to analyze.

output_type

Type of output to return. Must be one of:

  • "emotion" - returns only the predicted emotion label

  • "emoji" - returns only the corresponding emoji

  • "textemoji" - returns original text appended with predicted emoji (default)

Value

Depending on output_type:

  • For "emotion": character string of predicted emotion

  • For "emoji": character string of corresponding emoji

  • For "textemoji": original text with appended emoji

The function also prints the result to console.

Examples

## Not run: 
# This example is not run because it requires manually downloading
# a large external model (~30MB), which cannot be retrieved automatically
# and may fail in offline environments.
predict_emotion_with_emoji("I'm so happy today!")
predict_emotion_with_emoji("This makes me angry", "emoji")
predict_emotion_with_emoji("I feel scared", "emotion")

## End(Not run)


text2emotion documentation built on June 8, 2025, 1:04 p.m.