Skip to content

Commit

Permalink
add remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyima committed Mar 14, 2018
1 parent c991f57 commit fe882c9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions NLP_AWS_SouthPark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"source": [
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Plot-Excerpt\" data-toc-modified-id=\"Plot-Excerpt-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>Plot Excerpt</a></span></li><li><span><a href=\"#Setting-up-Environment\" data-toc-modified-id=\"Setting-up-Environment-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>Setting up Environment</a></span></li><li><span><a href=\"#Sentiment-Analysis-with-Amazon-Comprehend\" data-toc-modified-id=\"Sentiment-Analysis-with-Amazon-Comprehend-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>Sentiment Analysis with Amazon Comprehend</a></span><ul class=\"toc-item\"><li><span><a href=\"#One-text-line\" data-toc-modified-id=\"One-text-line-3.1\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>One text line</a></span></li><li><span><a href=\"#One-One-line\" data-toc-modified-id=\"One-One-line-3.2\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>One One line</a></span></li><li><span><a href=\"#On-one-movie-review-document\" data-toc-modified-id=\"On-one-movie-review-document-3.3\"><span class=\"toc-item-num\">3.3&nbsp;&nbsp;</span>On one movie review document</a></span></li></ul></li><li><span><a href=\"#Conclusion\" data-toc-modified-id=\"Conclusion-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>Conclusion</a></span></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>References</a></span></li></ul></div>"
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Plot-Excerpt\" data-toc-modified-id=\"Plot-Excerpt-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>Plot Excerpt</a></span></li><li><span><a href=\"#Setting-up-Environment\" data-toc-modified-id=\"Setting-up-Environment-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>Setting up Environment</a></span></li><li><span><a href=\"#Sentiment-Analysis-with-Amazon-Comprehend\" data-toc-modified-id=\"Sentiment-Analysis-with-Amazon-Comprehend-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>Sentiment Analysis with Amazon Comprehend</a></span><ul class=\"toc-item\"><li><span><a href=\"#On-a-text-line\" data-toc-modified-id=\"On-a-text-line-3.1\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>On a text line</a></span></li><li><span><a href=\"#On-a-line-in-review-document\" data-toc-modified-id=\"On-a-line-in-review-document-3.2\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>On a line in review document</a></span></li><li><span><a href=\"#On-an-entire-movie-review-document\" data-toc-modified-id=\"On-an-entire-movie-review-document-3.3\"><span class=\"toc-item-num\">3.3&nbsp;&nbsp;</span>On an entire movie review document</a></span></li></ul></li><li><span><a href=\"#Conclusion\" data-toc-modified-id=\"Conclusion-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>Conclusion</a></span></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>References</a></span></li></ul></div>"
]
},
{
Expand Down Expand Up @@ -101,13 +101,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### One text line "
"### On a text line "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"comprehend = boto3.client(service_name='comprehend', region_name='us-east-1')"
Expand Down Expand Up @@ -150,13 +152,22 @@
}
],
"source": [
"text = \"GarrisonTrump’s solution is to violently rape all three, as he nurses a black eye and defends Trump’s actions, is painfully accurate. The parallel between Heidi and Cartman’s poisonous, yet stubborn relationship is extended to Trump’s supporters, who watch Trump’s latest gaffe on tv, and look away, unwilling to criticize him for fear of the left’s rabid gloating. This is unfortunately, exactly what’s happening.\" \n",
"text = \"Garrison Trump’s solution is to violently rape all three, as he nurses a black eye and defends Trump’s actions, is painfully accurate. The parallel between Heidi and Cartman’s poisonous, yet stubborn relationship is extended to Trump’s supporters, who watch Trump’s latest gaffe on tv, and look away, unwilling to criticize him for fear of the left’s rabid gloating. This is unfortunately, exactly what’s happening.\" \n",
"\n",
"print('Calling DetectSentiment')\n",
"print(json.dumps(comprehend.detect_sentiment(Text=text, LanguageCode='en'), sort_keys=True, indent=4))\n",
"print('End of DetectSentiment\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Seems that the review for Garrison Trump in this episode is mostly neative (a dominant proportion of 53%), and somewhat netural (41%). \n",
"\n",
"The result is not surprising, as in this episode President Garrison keeps on his campaign promise to \"fxxk them all to death\", and threaten those who against him. "
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -170,7 +181,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### One One line"
"### On a line in review document"
]
},
{
Expand Down Expand Up @@ -261,7 +272,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### On one movie review document"
"### On an entire movie review document"
]
},
{
Expand Down Expand Up @@ -313,7 +324,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The author's attitude towards the episode \"Doubling down\" of South Park is netural (score: 0.68) to somewhat negative (score: 0.13). "
"Regardless of an negative attitude towards Garrison, the author's attitude towards the episode \"Doubling down\" of South Park is netural (score: 0.68) to somewhat negative (score: 0.13). "
]
},
{
Expand Down

0 comments on commit fe882c9

Please sign in to comment.