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

Denominator for "proportionalPol" sentiment computation #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

odelmarcelle
Copy link
Contributor

It always tickles me that compute_sentiment can yield values outside the [-1;1] range when using the "proportionalPol" method.

library(sentometrics)
sample_text <- setNames(nm = c("C'est un abandon", "C'est un vaste abandon"))
compute_sentiment(
  sample_text,
  lexicons = sentometrics::sento_lexicons(list(LM_sample = head(sentometrics::list_lexicons$LM_fr_tr, 5)),
                                          list_valence_shifters$fr),
  how = "proportionalPol"
)
#>                        id word_count LM_sample
#> 1:       C'est un abandon          3      -1.0
#> 2: C'est un vaste abandon          4      -1.8

Created on 2021-12-03 by the reprex package (v2.0.0)

With this change, I adjusted the denominator so that it takes into account sentiment words that have been amplified-deamplified. Thus, the sentiment will always lie down within the [-1;1] interval.
The same example after the change:

library(sentometrics)
sample_text <- setNames(nm = c("C'est un abandon", "C'est un vaste abandon"))
compute_sentiment(
  sample_text,
  lexicons = sentometrics::sento_lexicons(list(LM_sample = head(sentometrics::list_lexicons$LM_fr_tr, 5)),
                                          list_valence_shifters$fr),
  how = "proportionalPol"
)
#>                        id word_count LM_sample
#> 1:       C'est un abandon          3        -1
#> 2: C'est un vaste abandon          4        -1

Created on 2021-12-03 by the reprex package (v2.0.0)

@sborms
Copy link
Collaborator

sborms commented Jan 1, 2022

I think it's better to add a new weighting option than to change one which has been around for many versions and is implemented correctly. In the end it's just a choice and a matter of preference.

I would thus add a new weighting scheme, for instance called proportionalPolNorm, and clearly document it. It should also be added to the get_hows() function.

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

Successfully merging this pull request may close these issues.

2 participants