require(quanteda)
require(ggplot2)
Representation of world threats
corp <- readRDS('Data/data_corpus_nytimes_summary.RDS')
toks <- tokens(corp)
dict <- dictionary(file = 'english.yml')
toks_dict <- tokens_lookup(toks, dict, level = 3)
mt_dict <- dfm(toks_dict)
mt_dict <- dfm_remove(mt_dict, 'us')
for (t in seq(1850, 2010, 10)) {
mt_col <- fcm(mt_dict[floor(docvars(mt_dict, 'year') / 10) * 10 == t])
size <- log(rowSums(mt_col) + 1)
size <- size / max(size)
plot <- textplot_network(mt_col, min_freq = 0.85, edge_size = 5,
vertex_alpha = 0.8, vertex_size = size * 3)
plot <- plot + ggtitle(paste0(t, 's'))
print(plot)
}
















