Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

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>

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELI2F7EF42
img
Uploaded by :
KwKJjG6K
Page 1 Preview
hashset fsdatainputstreamfi newbufferedreader stri
Sell Your Old Documents & Earn Wallet Balance