Before we start, let's perform some preliminary steps by running the following code:
1 URL = "http://www.cs.cornell.edu/people/pabo/ 2 movie-review-data/review_polarity.tar.gz" 3 download.file(URL,destfile = "reviews.tar.gz") 4 untar("reviews.tar.gz")
This downloads the data you will use in a compressed file. Line 1 and 2 here should be typed on the same line in your console or script window with nospace between the quotation marks. Next, the file is uncompressed in a folder called txt_sentoken
in your working directory. Change your working directory to point to this folder by using the following code line:
setwd("txt_sentoken")
The folder contains the subfolders pos
and neg
. The pos
folder contains 1,000 positive film reviews, whereas the neg
folder contains 1,000 negative film reviews. The reviews were collected by researchers at Cornell University. We will analyze these texts here. The first thing we will do is load both corpora into R.
For this purpose, and to accomplish...