# make a small murder related dictionary
dict <- list(
kill = c("kill*", "murd*", "wound*", "die*"),
death = c("death*", "dying", "die*", "kill*")
)
# convert it to a weighted format
(dict_weighted <- read.dic(dict, as.weighted = TRUE))
# categorize it back
read.dic(dict_weighted)
# convert it to a string without writing to a file
cat(raw_dict <- write.dic(dict, save = FALSE))
# parse it back in
read.dic(raw = raw_dict)
if (FALSE) {
# save it as a .dic file
write.dic(dict, "murder")
# read it back in as a list
read.dic("murder.dic")
# read in the Moral Foundations or LUSI dictionaries from urls
moral_dict <- read.dic("https://osf.io/download/whjt2")
lusi_dict <- read.dic("https://osf.io/download/29ayf")
# save and read in a version of the General Inquirer dictionary
inquirer <- read.dic("inquirer", dir = "~/Dictionaries")
}
Run the code above in your browser using DataLab