toks <- tokens(data_corpus_inaugural)
dict <- dictionary(list(country = "united states",
law=c('law*', 'constitution'),
freedom=c('free*', 'libert*')))
dfm(tokens_lookup(toks, dict, 'glob', verbose = TRUE))
dict_fix <- dictionary(list(country = "united states",
law = c('law', 'constitution'),
freedom = c('freedom', 'liberty')))
dfm(applyDictionary(toks, dict_fix, valuetype='fixed'))
dfm(tokens_lookup(toks, dict_fix, valuetype='fixed'))
Run the code above in your browser using DataLab