CSCI 270 - Lab 6
Sentiment Understanding


Description

On a Mac

Open up the terminal and type

conda env list

Hopefully you only see the "root" environment. Then type

source activate root

to get the mappings correct for your programs. Now type

python

and you should get the Anaconda version 3.X. Here is what I see

Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now in the python console, type

import nltk
nltk.download()

Use this GUI to find the "book" link in the "Collections" tab and download it. This will load many datasets and libraries.

Also install the VADER library and collection.

Next, exit out of python, back to the terminal. Time to install more libraries.

pip install afinn
pip install graphviz
pip install google-api-python-client
pip install google-cloud-language

Finally, follow the Quickstart Instructions to get the credentials and libraries installed for Google Cloud. Because we are accessing the API through Python, you should not have to install the Cloud Tools.

On a Windows Machine

Open up the Anaconda Prompt and type

conda env list

Hopefully you only see the "root" environment. Then type

activate root

to get the mappings correct for your programs. Now type

python

and you should get the Anaconda version 3.X. Here is what I see

Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now in the python console, type

import nltk
nltk.download()

Use this GUI to find the "book" link in the "Collections" tab and download it. This will load many datasets and libraries.

Also install the VADER library and collection.

Next, exit out of python, back to the terminal. Time to install more libraries.

pip install afinn
pip install graphviz
pip install google-api-python-client
pip install google-cloud-language

Finally, follow the Quickstart Instructions to get the credentials and libraries installed for Google Cloud. Because we are accessing the API through Python, you should not have to install the Cloud Tools.

Sentiment Analysis

Analyze your selected poem using the Sentiment Analysis tools AFINN and VADER. Discuss which words have the largest effect on your overall sentiment score for the document.

Part of Speech Tagging

Train a Bigram Tagger (with a backup Unigram Tagger ( with a backup Default NN Tagger)) using the labeled Brown corpus of text.

Use this tagger to find the part of speech for the bold words in the following sentences. How accurate are the taggings?

Parsing

Pick two sentences from this collection of 65 Long Sentences in Literature.

Use the Google Cloud API to parse these sentences and draw the resulting parse-tree using the graphvix library for Digraphs.

CHANGE FOR SENTENCE LENGTH

For the following sentence:

Gasper Hicks stared down at the dead teenager at the foot of his door and 
realized he knew him; knew him as a boy, from the days when Gasper taught 
Sunday school, knew him as a blonde, dirt-faced kid desperate for attention, 
knew him as one of the dozen anxious children they bussed from the trailer park.

compare the parse trees generated by the Stanford Parser and Google Cloud Natural Language. What differences in structure and/or tagging do you find? Do you think these differences are significant?

What to Hand In

Turn in your .ipynb file to the Lab 6 directory on Moodle.
© Mark Goadrich, Hendrix College