Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two positives net off (?) #101

Closed
ghost opened this issue Mar 5, 2019 · 2 comments
Closed

two positives net off (?) #101

ghost opened this issue Mar 5, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 5, 2019

Am I missing something fundamental or is it a design?

A reproducible example below indicates netting-off that might need to be flagged to unsuspected users or fixed.

Example:
words "x" and "y" are positive.
same with phrases "x y" and "y z".
a phrase "x y z" ends up neutral, although one would hope it's positive as both words and phrases are positive! Interestingly "z x y" are positive and so is "x z y". The latter is actually the most positive :)


library(sentimentr)
mykey <- data.frame(
words = c("x", "y", "x y", "y z"),
polarity = c(1,1,1,1),
stringsAsFactors = FALSE
)
mytext<-c("x", "y", "z", "x z", "y z", "x y", "x y z", "z x y", "x z y")
sentiment("x", polarity_dt = as_key(mykey))
sentiment("y", polarity_dt = as_key(mykey))
sentiment("z", polarity_dt = as_key(mykey))
sentiment("x y", polarity_dt = as_key(mykey))
sentiment("y z", polarity_dt = as_key(mykey))
sentiment("x y z", polarity_dt = as_key(mykey))
sentiment("z x y", polarity_dt = as_key(mykey))
sentiment("x z y", polarity_dt = as_key(mykey))


sentiment("x", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 1 1
sentiment("y", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 1 1
sentiment("z", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 1 0
sentiment("x y", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 2 0.7071068
sentiment("y z", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 2 0.7071068
sentiment("x y z", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 3 0
sentiment("z x y", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 3 0.5773503
sentiment("x z y", polarity_dt = as_key(mykey))
element_id sentence_id word_count sentiment
1: 1 1 3 1.154701

@ghost ghost changed the title two positives net off two positives net off (?) Mar 5, 2019
@ghost
Copy link
Author

ghost commented Mar 6, 2019

Interestingly using only words = c("x", "y", "y z") or words = c("x", "y", "x y") does give the expected correct results, it's only when "x", "y" and "x y" and "y z" are in the lexicon then "x y z" is netted of to zero somehow. I'd appreciate any thoughts

@trinker
Copy link
Owner

trinker commented Mar 8, 2019

Is this the same as: #102? If so why open 2 separate issues for the same issue?

@ghost ghost closed this as completed Mar 8, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant