Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
hashset fsdatainputstreamfi newbufferedreader stri

Hashset fsdatainputstreamfi newbufferedreader stringline while line catch returnwords inthemapperstep tweet thetweet lengthofthetweetstoestimatethesentimentexpressedbyatweetonahashtag follows string integernegativecount integerwordscount for positivecount elseif wordscount integersentimentdifference sentimentdifference for word stats context inthereducerstep hashtaganddividebythetotalsizeofallthetweetsinwhichitoccurred extendsreducer throwsioexception doubletotaldifference doubletotalwords for string totalwords context

{
����HashSet<String>�words�=�new�HashSet<String>();����try�{

��������if�(fs.exists(wordsListPath))�{
������������FSDataInputStream�fi�=�fs.open(wordsListPath);

We’ll�use�these�in�the�reducer�to�calculate�an�overall�sentiment�ratio�weighted�by�the length�of�the�tweets�to�estimate�the�sentiment�expressed�by�a�tweet�on�a�hashtag,�as follows:

��������public�void�map(Object�key,�Text�value,�Context�context)�throws�IOException,�InterruptedException�{
������������String[]�words�=�value.toString().split("�")�;������������Integer�positiveCount�=�new�Integer(0);
������������Integer�negativeCount�=�new�Integer(0);

������������}

������������Integer�sentimentDifference�=�0;
������������if�(wordsCount�>�0)�{
��������������sentimentDifference�=�positiveCount�-�negativeCount;������������}

After�running�the�preceding�code,�execute�HashTagSentiment�with�the�following command:

$�hadoop�jar�build/libs/mapreduce-example.jar�
com.learninghadoop2.mapreduce.HashTagSentiment�twitter.txt�output-sentiment�<positive�words>�<negative�words>

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Dominic Johnson

PageId: ELI2F7EF42