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

KWIC highlighting working only 50% for kwic derived from partition #38

Closed
ablaette opened this issue Sep 5, 2018 · 2 comments
Closed

Comments

@ablaette
Copy link
Collaborator

ablaette commented Sep 5, 2018

library(polmineR)
library(magrittr)
use("GermaParl")


df <- partition("GERMAPARL", year = 2001:2011) %>%
  context(query = "Islam", p_attribute = c("word", "pos"), verbose = FALSE) %>%
  partition_bundle(node = FALSE) %>%
  set_names(s_attributes(., s_attribute = "date")) %>%
  weigh(with = SentiWS) %>%
  summary()


partition("GERMAPARL", year = 2001:2011) %>%
  kwic(query = "Islam", positivelist = c(words_positive, words_negative)) %>%
  highlight(lightgreen = words_positive, orange = words_negative) %>%
  tooltips(setNames(SentiWS[["word"]], SentiWS[["weight"]])) %>%
  as("htmlwidget") -> Y
@PolMine
Copy link
Collaborator

PolMine commented Dec 13, 2018

The issue is not very informative. This is definitely missing:

SentiWS <- get_sentiws()
words_positive <- unique(SentiWS[weight > 0][["word"]])
words_negative <- unique(SentiWS[weight < 0][["word"]])

The colors are dropped, and this what needs to be addressed...

@ablaette
Copy link
Collaborator Author

Critizising myself, I need to note that I repeatedly failed to offer a reproducible example.

Now I think that my initial diagnosis was wrong: Colors were not dropped, but in the example, there were previously assigned colors for the words on the positivelist (in the kwic()-call), and the subsequent highlight()-call could not override these colors (yellow by default).

I think, the error is that kwic() did some highlighting implicitly. Taking this out gives the user more control, and the following example works.

library(polmineR)
library(magrittr)
use("GermaParl")

gist_url <- "https://gist.githubusercontent.com/PolMine/70eeb095328070c18bd00ee087272adf/raw/c2eee2f48b11e6d893c19089b444f25b452d2adb/sentiws.R"
devtools::source_url(gist_url) # danach ist Funktion verfügbar
SentiWS <- get_sentiws()

SentiWS <- get_sentiws()
words_positive <- unique(SentiWS[weight > 0][["word"]])
words_negative <- unique(SentiWS[weight < 0][["word"]])

df <- partition("GERMAPARL", year = 2001:2011) %>%
  context(query = "Islam", p_attribute = c("word", "pos"), verbose = FALSE) %>%
  partition_bundle(node = FALSE) %>%
  set_names(s_attributes(., s_attribute = "date")) %>%
  weigh(with = SentiWS) %>%
  summary()

y <- partition("GERMAPARL", year = 2001:2011) %>%
  kwic(query = "Islam", positivelist = c(words_positive, words_negative)) %>%
  highlight(lightgreen = words_positive, orange = words_negative) %>%
  tooltips(setNames(SentiWS[["word"]], SentiWS[["weight"]])) %>%
  as("htmlwidget")

show(y)

I am about to push polmineR v0.7.11.9030 that will solve this issue.

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