Skip to content

Instantly share code, notes, and snippets.

@mrchypark
Created July 1, 2019 06:31
Show Gist options
  • Save mrchypark/dfeca42b53405dbed8d75ad99884bf88 to your computer and use it in GitHub Desktop.
Save mrchypark/dfeca42b53405dbed8d75ad99884bf88 to your computer and use it in GitHub Desktop.
tar %>%
mutate(speech_id = 1:nrow(.)) %>%
unnest_tokens(senten, content,
token="sentences") %>%
select(speech_id, senten) %>%
mutate(sentence_id = 1:nrow(.)) %>%
unnest_tokens(morph, senten,
token = pos) %>%
filter(str_detect(morph, "/n|/v(v|a)")) %>%
mutate(
morph = if_else(
str_detect(morph, "/n"),
str_replace_all(morph, "/.*$", ""),
str_replace_all(morph, "/.*$", "다")
)
) %>%
filter(str_length(morph) > 1) %>%
pairwise_count(morph, sentence_id, sort=T, upper=F) %>%
filter(item1 == "사랑")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment