quanteda Basics
Learn how to implement basic NLP tasks with quanteda.
We'll cover the following...
We'll cover the following...
We compared tm, tidytext, and quanteda for a brief overview of how the different packages implemented text mining and natural language processing tasks. Here is the code presented in that lesson:
R
# install.packages("quanteda")# install.packages("readtext")library(quanteda, quietly = TRUE)library(readtext)textDF <- readtext(file = "data/mws*txt", docvarsfrom = "filenames")quantCorpus <- corpus(textDF)tokens(quantCorpus)
In the code above, quanteda commands are used:
Line 7:
readtextis used to read text files in thedatadirectory with names beginning withmws. This produces adata.frame.docvarsfromsaves the file names as thedoc id.Line 9:
corpusconverts thedata.frameinto aquantedacorpus.Line 11:
tokensis used to tokenize the corpus.
The result shows the corpus with two documents. It ...