forked from EPINetz/EPINetz-Policy-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolicy_field_visualizations_textgraph.R
73 lines (58 loc) · 2.87 KB
/
policy_field_visualizations_textgraph.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## Visualize Policy Field Contents ##
#####################################
{
library(tidyverse)
library(quanteda)
library(quanteda.textstats)
library(data.table)
library(furrr)
library(vroom)
library(igraph)
library(RandomWalkRestartMH)
library(scales)
library(ggraph)
library(textgraph)
library(future)
}
plan(multisession, workers = 16)
n_terms <- 10 # number of top terms to be extracted per timeframe and policy field
classification_measure = "ScoreNormMean" # classification measure found in the classification results
timeframes = c("2023-04-02", "2023-04-09", "2023-04-16")
timeframes %>%
future_walk(\(timeframe)
{
network_twitter <- readRDS(paste0("init_classification/walk_network_data/",
timeframe, ".RDS"))
rwr_terms_twitter <- vroom(paste0("init_classification/walk_terms/",
timeframe, ".csv"))
twitter_plots <- visualize_rwr(rwr_terms_twitter,
network_twitter,
group_name = "policy_field",
classification_measure = classification_measure,
n_terms = n_terms,
verbose = F
)
twitter_plots %>%
iwalk(\(plot, name)
ggsave(filename = paste0("twitter_", timeframe,
"_", name, ".png"),
plot = plot,
path = "visualizations"))
network_news <- readRDS(paste0("news_classification/walk_network_data/",
timeframe, ".RDS"))
rwr_terms_news <- vroom(paste0("news_classification/walk_terms/",
timeframe, ".csv"))
news_plots <- visualize_rwr(rwr_terms_news,
network_news,
group_name = "policy_field",
classification_measure = classification_measure,
n_terms = n_terms,
verbose = F
)
news_plots %>%
iwalk(\(plot, name)
ggsave(filename = paste0("news_", timeframe,
"_", name, ".png"),
plot = plot,
path = "visualizations"))
})