mjockers / syuzhet

An R package for the extraction of sentiment and sentiment-based plot arcs from text
334 stars 72 forks source link

mixed message function error #45

Closed vbomiv closed 1 year ago

vbomiv commented 1 year ago

Whenever I try to use the function for prose texts, the same error pops up as below. (I used the same code from "Introduction to the Syuzhet Package"):

path_to_a_text_file <- "CMS_02.txt" sample <- get_text_as_string(path_to_a_text_file) sample_sents <- get_sentences(sample) test <- lapply(sample_sents, mixed_messages) Error in sign(get_sentiment(tokens)) : non-numeric argument to mathematical function

Can anyone help me solve this issue?

mjockers commented 1 year ago

Seems this might be a problem with your input text. What happens if you just try this: sample <- "This is a test. In the event of a real emergency, you would be notified who to love and who to hate." sample_sents <- get_sentences(sample) test <- lapply(sample_sents, mixed_messages)

mjockers commented 1 year ago

test [[1]] entropy metric_entropy 0 0

[[2]] entropy metric_entropy 1.00000000 0.05555556

vbomiv commented 1 year ago

Thank you! You were right. it was my input text that had an issue. I had to remove some punctuation marks that were placed in a row.