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

Sentiment Analysis | set_names-Workflow won't work if context of query word extends into next date #15

Open
ChristophLeonhardt opened this issue Oct 20, 2020 · 0 comments

Comments

@ChristophLeonhardt
Copy link
Collaborator

In lesson 7, "Diktionäre und Sentiment-Analysen" (https://polmine.github.io/UCSSR/sentiments.html#8), you propose a workflow in which context() and partition_bundle() are deployed to identify hits and their surrounding words. The proposed workflow doesn't work if one of the query term's context extends into the next date (or whatever struc is used for grouping the sentiment).

If I see this correctly, the partition_bundle method here splits the context object into partitions, omitting the node (i.e. the query) itself. This doesn't regard boundaries which is why later, when set_names() is called, the s_attributes() methods returns more individual dates than there are partitions in the partition bundle.

Here is a reproducible example to see the error:

library(polmineR)
library(data.table)
 
gist_url <- "https://gist.githubusercontent.com/PolMine/70eeb095328070c18bd00ee087272adf/raw/c2eee2f48b11e6d893c19089b444f25b452d2adb/sentiws.R"
devtools::source_url(gist_url)
SentiWS <- get_sentiws()
 
vocab <- c(
  positive = nrow(SentiWS[base == TRUE][weight > 0]),
  negative = nrow(SentiWS[base == TRUE][weight < 0])
)
 
options("polmineR.left" = 10L)
options("polmineR.right" = 10L)

df <- context("GERMAPARLMINI", query = 'Präsidiums', p_attribute = "word") %>%
  partition_bundle(node = FALSE) %>%
  set_names(s_attributes(., s_attribute = "date")) %>%
  weigh(with = SentiWS) %>% 
  summary()

After writing this, I remembered that there is a boundary argument for context(). If the general behavior of this workflow is okay, then adding a reasonable boundary (probably speech, which isn't annotated in all corpora or speaker, but there certainly are a lot of situations in which the same speaker might end one debate and start the next) would improve the UCSSR example both functionally as well as substantially as we don't want to measure other speaker's words as context for the sentiment analysis.

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