Skip to content

Instantly share code, notes, and snippets.

@nszoni
Last active November 24, 2021 12:59
Show Gist options
  • Save nszoni/1d7c7efc78ae6f259f8d920002ed76fc to your computer and use it in GitHub Desktop.
Save nszoni/1d7c7efc78ae6f259f8d920002ed76fc to your computer and use it in GitHub Desktop.
Get entities
#init empty vector
entities <- c()
#get entities and append to vector
for (i in 1:length(hungary_processed$text_processed)){
entry <- detect_entities(hungary_processed$text_processed[i])
if (ncol(entry) > 1){
entities <- c(entities, entry[, 5])
log_info("Found entities for post {i}")
} else {
log_info("Found NO entities for post {i}, skipping")
}
}
#extract top 10
entity_freq <- data.frame(sort(table(wordStem(entities, 'en')), decreasing = TRUE)) %>%
slice(1:10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment