HW2xHW4

VECTORIZATION (Pandas style!)

STEP 1: Import ALL the things

Import libraries

In [1]:
##########################################
# NOTE: I'm toying with the idea of requiring the library just above 
# when I use it so it makes more sense in context
##########################################
# import os
# import pandas as pd
# from nltk.tokenize import word_tokenize, sent_tokenize
# from nltk.sentiment import SentimentAnalyzer
# from nltk.sentiment.util import *
# from nltk.probability import FreqDist
# from nltk.sentiment.vader import SentimentIntensityAnalyzer
# sid = SentimentIntensityAnalyzer()

Import data from files

In [113]:
import os
def get_data_from_files(path):
    directory = os.listdir(path)
    results = []
    for file in directory:
        f=open(path+file)
        results.append(f.read())
        f.close()
    return results

# neg = get_data_from_files('../neg_cornell/')
# pos = get_data_from_files('../pos_cornell/')

# neg = get_data_from_files('../neg_hw4/')
# pos = get_data_from_files('../pos_hw4/')

neg = get_data_from_files('../hw4_lie_false/')
pos = get_data_from_files('../hw4_lie_true/')

STEP 2: Prep Data

STEP 2a: Turn that fresh text into a pandas DF

In [114]:
import pandas as pd
neg_df = pd.DataFrame(neg)
pos_df = pd.DataFrame(pos)

STEP 2b: Label it

In [115]:
pos_df['PoN'] = 'P'
neg_df['PoN'] = 'N'

STEP 2c: Combine the dfs

In [116]:
all_df = neg_df.append(pos_df)
In [117]:
all_df[:3]
Out[117]:
0 PoN
0 Gannon’s Isle Ice Cream served the best ice cr... N
1 Hibachi the grill is one of my favorite restau... N
2 RIM KAAP One of the best Thai restaurants in t... N

STEP 3: TOKENIZE (and clean)!!

In [118]:
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.sentiment import SentimentAnalyzer
from nltk.sentiment.util import *
In [119]:
## Came back and added sentences for tokinization for "Summary experiment"
def get_sentence_tokens(review):
    return sent_tokenize(review)
    
all_df['sentences'] = all_df.apply(lambda x: get_sentence_tokens(x[0]), axis=1)
all_df['num_sentences'] = all_df.apply(lambda x: len(x['sentences']), axis=1)
In [120]:
def get_tokens(sentence):
    tokens = word_tokenize(sentence)
    clean_tokens = [word.lower() for word in tokens if word.isalpha()]
    return clean_tokens

all_df['tokens'] = all_df.apply(lambda x: get_tokens(x[0]), axis=1)
all_df['num_tokens'] = all_df.apply(lambda x: len(x['tokens']), axis=1)
In [121]:
all_df[:3]
Out[121]:
0 PoN sentences num_sentences tokens num_tokens
0 Gannon’s Isle Ice Cream served the best ice cr... N [Gannon’s Isle Ice Cream served the best ice c... 7 [gannon, s, isle, ice, cream, served, the, bes... 72
1 Hibachi the grill is one of my favorite restau... N [Hibachi the grill is one of my favorite resta... 5 [hibachi, the, grill, is, one, of, my, favorit... 65
2 RIM KAAP One of the best Thai restaurants in t... N [RIM KAAP One of the best Thai restaurants in ... 11 [rim, kaap, one, of, the, best, thai, restaura... 141

STEP 4: Remove Stopwords

In [122]:
from nltk.corpus import stopwords
stop_words = set(stopwords.words("english"))
def remove_stopwords(sentence):
    filtered_text = []
    for word in sentence:
        if word not in stop_words:
            filtered_text.append(word)
    return filtered_text
all_df['no_sw'] = all_df.apply(lambda x: remove_stopwords(x['tokens']),axis=1)
all_df['num_no_sw'] = all_df.apply(lambda x: len(x['no_sw']),axis=1)
In [123]:
all_df[:5]
Out[123]:
0 PoN sentences num_sentences tokens num_tokens no_sw num_no_sw
0 Gannon’s Isle Ice Cream served the best ice cr... N [Gannon’s Isle Ice Cream served the best ice c... 7 [gannon, s, isle, ice, cream, served, the, bes... 72 [gannon, isle, ice, cream, served, best, ice, ... 36
1 Hibachi the grill is one of my favorite restau... N [Hibachi the grill is one of my favorite resta... 5 [hibachi, the, grill, is, one, of, my, favorit... 65 [hibachi, grill, one, favorite, restaurants, l... 30
2 RIM KAAP One of the best Thai restaurants in t... N [RIM KAAP One of the best Thai restaurants in ... 11 [rim, kaap, one, of, the, best, thai, restaura... 141 [rim, kaap, one, best, thai, restaurants, town... 75
3 It is a France restaurant which has Michelin t... N [It is a France restaurant which has Michelin ... 6 [it, is, a, france, restaurant, which, has, mi... 71 [france, restaurant, michelin, three, stars, e... 36
4 Its hard to pick a favorite dining experience ... N [Its hard to pick a favorite dining experience... 7 [its, hard, to, pick, a, favorite, dining, exp... 119 [hard, pick, favorite, dining, experience, cio... 62

STEP 5: Create a Frequency Distribution

In [124]:
from nltk.probability import FreqDist
def get_most_common(tokens):
    fdist = FreqDist(tokens)
    return fdist.most_common(12)
all_df['topwords_unfil'] = all_df.apply(lambda x: get_most_common(x['tokens']),axis=1)
In [125]:
def get_most_common(tokens):
    fdist = FreqDist(tokens)
    return fdist.most_common(12)
all_df['topwords_fil'] = all_df.apply(lambda x: get_most_common(x['no_sw']),axis=1)
In [126]:
def get_fdist(tokens):
    return (FreqDist(tokens))
    
all_df['freq_dist'] = all_df.apply(lambda x: get_fdist(x['no_sw']),axis=1)
all_df['freq_dist_unfil'] = all_df.apply(lambda x: get_fdist(x['tokens']),axis=1)
In [127]:
all_df[:3]
Out[127]:
0 PoN sentences num_sentences tokens num_tokens no_sw num_no_sw topwords_unfil topwords_fil freq_dist freq_dist_unfil
0 Gannon’s Isle Ice Cream served the best ice cr... N [Gannon’s Isle Ice Cream served the best ice c... 7 [gannon, s, isle, ice, cream, served, the, bes... 72 [gannon, isle, ice, cream, served, best, ice, ... 36 [(the, 7), (it, 4), (ice, 3), (cream, 3), (and... [(ice, 3), (cream, 3), (best, 2), (chocolate, ... {'gannon': 1, 'isle': 1, 'ice': 3, 'cream': 3,... {'gannon': 1, 's': 1, 'isle': 1, 'ice': 3, 'cr...
1 Hibachi the grill is one of my favorite restau... N [Hibachi the grill is one of my favorite resta... 5 [hibachi, the, grill, is, one, of, my, favorit... 65 [hibachi, grill, one, favorite, restaurants, l... 30 [(the, 8), (is, 6), (it, 3), (hibachi, 2), (gr... [(hibachi, 2), (grill, 2), (restaurants, 2), (... {'hibachi': 2, 'grill': 2, 'one': 1, 'favorite... {'hibachi': 2, 'the': 8, 'grill': 2, 'is': 6, ...
2 RIM KAAP One of the best Thai restaurants in t... N [RIM KAAP One of the best Thai restaurants in ... 11 [rim, kaap, one, of, the, best, thai, restaura... 141 [rim, kaap, one, best, thai, restaurants, town... 75 [(the, 12), (of, 3), (thai, 3), (and, 3), (for... [(thai, 3), (food, 3), (rim, 2), (kaap, 2), (b... {'rim': 2, 'kaap': 2, 'one': 1, 'best': 2, 'th... {'rim': 2, 'kaap': 2, 'one': 1, 'of': 3, 'the'...

STEP 6: Try Different Sentiment Analysis Tools

VADER

In [128]:
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
def get_vader_score(review):
    return sid.polarity_scores(review)

all_df['vader_all'] = all_df.apply(lambda x: get_vader_score(x[0]),axis=1)
In [129]:
def separate_vader_score(vader_score, key):
    return vader_score[key]

all_df['v_compound'] = all_df.apply(lambda x: separate_vader_score(x['vader_all'], 'compound'),axis=1)
all_df['v_neg'] = all_df.apply(lambda x: separate_vader_score(x['vader_all'], 'neg'),axis=1)
all_df['v_neu'] = all_df.apply(lambda x: separate_vader_score(x['vader_all'], 'neu'),axis=1)
all_df['v_pos'] = all_df.apply(lambda x: separate_vader_score(x['vader_all'], 'pos'),axis=1)

DIY SUMMARY

In [130]:
all_df[0][17]
Out[130]:
17    I went to Joeys and had the best lasagna on th...
17    Halos is home. I have been here numerous times...
Name: 0, dtype: object
In [131]:
def get_weighted_freq_dist(review, freq_dist):
    try:
        max_freq = max(freq_dist.values())
        for word in freq_dist.keys():
            freq_dist[word] = (freq_dist[word]/max_freq)
        return freq_dist
    except:
        return 'nope'

all_df['weighted_freq_dist'] = all_df.apply(lambda x: get_weighted_freq_dist(x['sentences'], x['freq_dist']),axis=1)
In [132]:
def get_sentence_score(review, freq_dist):
    sentence_scores = {}
    for sent in review:
        for word in nltk.word_tokenize(sent.lower()):
            if word in freq_dist.keys():
                if len(sent.split(' ')) < 30:
                    if sent not in sentence_scores.keys():
                        sentence_scores[sent] = freq_dist[word]
                    else:
                        sentence_scores[sent] += freq_dist[word]
    return sentence_scores

all_df['sentence_scores'] = all_df.apply(lambda x: get_sentence_score(x['sentences'], x['freq_dist']),axis=1)
In [133]:
def get_summary_sentences(sentence_scores):
    sorted_sentences = sorted(sentence_scores.items(), key=lambda kv: kv[1], reverse=True)
    return ''.join(sent[0] for sent in sorted_sentences[:5])

all_df['summary_sentences'] = all_df.apply(lambda x: get_summary_sentences(x['sentence_scores']), axis=1)
In [134]:
summaries = all_df['summary_sentences'].tolist()
In [135]:
summaries[3]
Out[135]:
'You dont need choose your menu by yourself and they would accord to your customer to help you choose the best menu for you.When you enter the restaurant you would feel that you drop into a new world.The menu consisted by 16 courses and everyone is amazing taste.It is a France restaurant which has Michelin three stars.The dining would spend 3 hours.'

Doing VADER on the Summary Section

In [136]:
all_df['vader_sum_all'] = all_df.apply(lambda x: get_vader_score(x['summary_sentences']),axis=1)
In [137]:
all_df['v_compound_sum'] = all_df.apply(lambda x: separate_vader_score(x['vader_sum_all'], 'compound'),axis=1)
all_df['v_neg_sum'] = all_df.apply(lambda x: separate_vader_score(x['vader_sum_all'], 'neg'),axis=1)
all_df['v_neu_sum'] = all_df.apply(lambda x: separate_vader_score(x['vader_sum_all'], 'neu'),axis=1)
all_df['v_pos_sum'] = all_df.apply(lambda x: separate_vader_score(x['vader_sum_all'], 'pos'),axis=1)

Doing VADER on the Most Frequent Words

In [138]:
def get_freq_words(freq_dist):
    sorted_words = sorted(freq_dist.items(), key=lambda kv: kv[1], reverse=True)
    return ' '.join(word[0] for word in sorted_words[:50])

all_df['v_freq_words'] = all_df.apply(lambda x: get_freq_words(x['freq_dist']), axis=1)

all_df['vader_fq_all'] = all_df.apply(lambda x: get_vader_score(x['v_freq_words']),axis=1)
all_df['v_compound_fd'] = all_df.apply(lambda x: separate_vader_score(x['vader_fq_all'], 'compound'),axis=1)
all_df['v_neg_fd'] = all_df.apply(lambda x: separate_vader_score(x['vader_fq_all'], 'neg'),axis=1)
all_df['v_neu_fd'] = all_df.apply(lambda x: separate_vader_score(x['vader_fq_all'], 'neu'),axis=1)
all_df['v_pos_fd'] = all_df.apply(lambda x: separate_vader_score(x['vader_fq_all'], 'pos'),axis=1)

STEP 7: Test Step 6 with Machine Learning!!

Naive Bayes

In [139]:
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB, MultinomialNB

def get_NB(small_df, labels, no_negs):
    x_train, x_test, y_train, y_test = train_test_split(small_df.values, labels, test_size=0.3, random_state = 109)


    gnb = GaussianNB()
    gnb.fit(x_train, y_train)
    y_pred = gnb.predict(x_test)
    
    if no_negs:
        mnnb = MultinomialNB()
        mnnb.fit(x_train, y_train)
        y_pred_mn = mnnb.predict(x_test)
    
#     clf = MultinomialNB()
#     clf.fit(x_train, y_train)

#     print(clf.predict(x_train[2:3]))
    from sklearn import metrics
    print("Accuracy GNB:", metrics.accuracy_score(y_test, y_pred))
    if no_negs: 
        print("Accuracy MNNB:", metrics.accuracy_score(y_test, y_pred_mn))
In [140]:
# from sklearn.naive_bayes import MultinomialNB
# clf = MultinomialNB()
# clf.fit(x_train, y_train)

# print(clf.predict(x_train[2:3]))

TEST 1: Vader Scores (Original)

In [141]:
small_df = all_df.filter(['v_compound','v_pos', 'v_neg', 'v_neu']) # 0.645
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.39285714285714285
In [142]:
small_df = all_df.filter(['v_pos', 'v_neu']) # 0.645
get_NB(small_df, all_df['PoN'], True)
Accuracy GNB: 0.42857142857142855
Accuracy MNNB: 0.39285714285714285

TEST 2: Vader Scores (from Summary)

In [143]:
small_df = all_df.filter(['v_compound_sum','v_pos_sum', 'v_neg_sum', 'v_neu_sum']) # 0.59
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.39285714285714285
In [144]:
small_df = all_df.filter(['v_pos_sum','v_neu_sum']) # 0.59
get_NB(small_df, all_df['PoN'], True)
Accuracy GNB: 0.4642857142857143
Accuracy MNNB: 0.32142857142857145

TEST 3: Vader Scores (original) AND Vader Scores (summary)

In [145]:
small_df = all_df.filter(['v_compound_sum','v_pos_sum', 'v_neg_sum', 'v_neu_sum', 
                          'v_compound','v_pos', 'v_neg', 'v_neu']) # 0.618
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.39285714285714285
In [146]:
small_df = all_df.filter(['v_pos_sum', 'v_neu_sum', 'v_pos', 'v_neu']) # 0.618
get_NB(small_df, all_df['PoN'], True)
Accuracy GNB: 0.35714285714285715
Accuracy MNNB: 0.42857142857142855

TEST 4: Vader Scores (50 most frequent -- filtered -- words)

In [147]:
small_df = all_df.filter(['v_compound_fd','v_pos_fd', 'v_neu_fd', 'v_neg_fd']) # 0.598
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.4642857142857143
In [148]:
small_df = all_df.filter(['v_pos_fd', 'v_neu_fd']) # 0.598
get_NB(small_df, all_df['PoN'], True)
Accuracy GNB: 0.35714285714285715
Accuracy MNNB: 0.35714285714285715

TEST 5: All compound Vader Scores

In [149]:
small_df = all_df.filter(['v_compound_fd','v_compound_sum', 'v_compound']) # 0.615
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.39285714285714285
In [150]:
small_df = all_df.filter(['v_pos_fd','v_pos_sum', 'v_pos']) # 0.615
get_NB(small_df, all_df['PoN'], True)
Accuracy GNB: 0.4642857142857143
Accuracy MNNB: 0.4642857142857143

TEST 6: ALL THE NUMBERS!!

In [151]:
small_df = all_df.filter(['v_compound_sum','v_pos_sum', 'v_neg_sum', 'v_neu_sum', 
                          'v_compound_fd','v_pos_fd', 'v_neg_fd', 'v_neu_fd', 
                          'v_compound','v_pos', 'v_neg', 'v_neu']) # 0.613
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.42857142857142855

TEST 7: Test UNFILTERED most frequent words

In [152]:
def get_freq_words(freq_dist):
    sorted_words = sorted(freq_dist.items(), key=lambda kv: kv[1], reverse=True)
    return ' '.join(word[0] for word in sorted_words[:50])

all_df['v_freq_words_unfil'] = all_df.apply(lambda x: get_freq_words(x['freq_dist_unfil']), axis=1)

all_df['vader_fd_all_unfil'] = all_df.apply(lambda x: get_vader_score(x['v_freq_words_unfil']),axis=1)

all_df['v_compound_fd_uf'] = all_df.apply(lambda x: separate_vader_score(x['vader_fd_all_unfil'], 'compound'),axis=1)
all_df['v_neg_fd_uf'] = all_df.apply(lambda x: separate_vader_score(x['vader_fd_all_unfil'], 'neg'),axis=1)
all_df['v_neu_fd_uf'] = all_df.apply(lambda x: separate_vader_score(x['vader_fd_all_unfil'], 'neu'),axis=1)
all_df['v_pos_fd_uf'] = all_df.apply(lambda x: separate_vader_score(x['vader_fd_all_unfil'], 'pos'),axis=1)
In [153]:
small_df = all_df.filter(['v_compound_sum','v_pos_sum', 'v_neg_sum', 'v_neu_sum', 
                          'v_compound_fd','v_pos_fd', 'v_neg_fd', 'v_neu_fd', 
                          'v_compound_fd_uf','v_pos_fd_uf', 'v_neg_fd_uf', 'v_neu_fd_uf',
                          'v_compound','v_pos', 'v_neg', 'v_neu']) # 0.618
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.42857142857142855
In [154]:
small_df = all_df.filter(['v_compound_fd_uf','v_pos_fd_uf', 'v_neg_fd_uf', 'v_neu_fd_uf']) # 0.603
get_NB(small_df, all_df['PoN'], False)
Accuracy GNB: 0.32142857142857145
In [155]:
summaries_pos = all_df[all_df['PoN'] == 'P']
summaries_neg = all_df[all_df['PoN'] == 'N']
In [156]:
summaries_pos_list = summaries_pos['summary_sentences'].tolist()
summaries_neg_list = summaries_neg['summary_sentences'].tolist()
In [157]:
summaries_pos_list[:1]
Out[157]:
['']
In [158]:
summaries_neg_list[:1]
Out[158]:
['Gannon’s Isle Ice Cream served the best ice cream and you better believe it!A weird combination but the smooth sweet chocolate combined with the sharp taste of raspberry was devine!The ice cream is delicious the best I had.The place is ideally situated and it is easy to get too.There were so many varieties that I had trouble choosing it.']
In [159]:
### VERSION 1
#     all_words_neg = sentim_analyzer.all_words([mark_negation(doc) for doc in training_docs])
#     unigram_feats = sentim_analyzer.unigram_word_feats(all_words_neg)
#     sentim_analyzer.add_feat_extractor(extract_unigram_feats, unigrams=unigram_feats)
#     training_set = sentim_analyzer.apply_features(training_docs)
#     test_set = sentim_analyzer.apply_features(testing_docs)
sentim_analyzer = SentimentAnalyzer()

def get_nltk_negs(tokens):
    all_words_neg = sentim_analyzer.all_words([mark_negation(tokens)])
    return all_words_neg

def get_unigram_feats(neg_tokens):
    unigram_feats = sentim_analyzer.unigram_word_feats(neg_tokens)
    return unigram_feats
    
all_df['nltk_negs'] = all_df.apply(lambda x: get_nltk_negs(x['tokens']), axis=1)
all_df['unigram_feats'] = all_df.apply(lambda x: get_unigram_feats(x['nltk_negs']), axis=1)
# all_df['nltk_unfil'] = all_df.apply(lambda x: get_nltk_data(x['tokens']), axis=1)
In [160]:
### VERSION 2
#     all_words_neg = sentim_analyzer.all_words([mark_negation(doc) for doc in training_docs])
#     unigram_feats = sentim_analyzer.unigram_word_feats(all_words_neg)
#     sentim_analyzer.add_feat_extractor(extract_unigram_feats, unigrams=unigram_feats)
#     training_set = sentim_analyzer.apply_features(training_docs)
#     test_set = sentim_analyzer.apply_features(testing_docs)
sentim_analyzer = SentimentAnalyzer()

def get_nltk_data(tokens):
#     print(tokens)
    neg_tokens = sentim_analyzer.all_words([mark_negation(tokens)])
    unigram_feats = sentim_analyzer.unigram_word_feats(neg_tokens)
    sentim_analyzer.add_feat_extractor(extract_unigram_feats, unigrams=unigram_feats)
#     print(sentim_analyzer.apply_features(tokens))
    return sentim_analyzer.apply_features(tokens)


# def get_unigram_feats(neg_tokens):
    
#     return unigram_feats
nltk_df = pd.DataFrame()
nltk_df['nltk_data'] = all_df.apply(lambda x: get_nltk_data(x['tokens']), axis=1)

# all_df['nltk']
# all_df['unigram_feats'] = all_df.apply(lambda x: get_unigram_feats(x['nltk_negs']), axis=1)
# all_df['nltk_unfil'] = all_df.apply(lambda x: get_nltk_data(x['tokens']), axis=1)
In [161]:
# all_df['nltk_all'] = 0
In [162]:
nltk_df
Out[162]:
nltk_data
0 ({'contains(i)': False, 'contains(it)': False,...
1 ({'contains(i)': True, 'contains(it)': False, ...
2 ({'contains(i)': True, 'contains(it)': False, ...
3 ({'contains(i)': True, 'contains(it)': False, ...
4 ({'contains(i)': True, 'contains(it)': False, ...
... ...
41 ({'contains(i)': False, 'contains(it)': False,...
42 ({'contains(i)': False, 'contains(it)': False,...
43 ({'contains(i)': True, 'contains(it)': False, ...
44 ({'contains(i)': False, 'contains(it)': False,...
45 ({'contains(i)': True, 'contains(it)': False, ...

92 rows × 1 columns

In [163]:
all_df['nltk_negs']
Out[163]:
0     [gannon, s, isle, ice, cream, served, the, bes...
1     [hibachi, the, grill, is, one, of, my, favorit...
2     [rim, kaap, one, of, the, best, thai, restaura...
3     [it, is, a, france, restaurant, which, has, mi...
4     [its, hard, to, pick, a, favorite, dining, exp...
                            ...                        
41    [a, big, piano, is, in, the, middle, of, the, ...
42    [cant, say_NEG, too_NEG, much_NEG, about_NEG, ...
43    [i, once, went, to, a, restaurant, which, was,...
44    [the, worst, restaurant, experience, of, my, l...
45    [i, ordered, the, food, and, took, it, back, h...
Name: nltk_negs, Length: 92, dtype: object
In [164]:
from nltk.tokenize import casual_tokenize
from collections import Counter
all_df['bow_nosw'] = all_df.apply(lambda x: Counter(casual_tokenize(x[0])), axis=1)
In [165]:
all_df[:3]
Out[165]:
0 PoN sentences num_sentences tokens num_tokens no_sw num_no_sw topwords_unfil topwords_fil ... v_pos_fd v_freq_words_unfil vader_fd_all_unfil v_compound_fd_uf v_neg_fd_uf v_neu_fd_uf v_pos_fd_uf nltk_negs unigram_feats bow_nosw
0 Gannon’s Isle Ice Cream served the best ice cr... N [Gannon’s Isle Ice Cream served the best ice c... 7 [gannon, s, isle, ice, cream, served, the, bes... 72 [gannon, isle, ice, cream, served, best, ice, ... 36 [(the, 7), (it, 4), (ice, 3), (cream, 3), (and... [(ice, 3), (cream, 3), (best, 2), (chocolate, ... ... 0.434 the it ice cream and is i had best chocolate r... {'neg': 0.058, 'neu': 0.673, 'pos': 0.268, 'co... 0.8898 0.058 0.673 0.268 [gannon, s, isle, ice, cream, served, the, bes... [the, it, ice, cream, and, is, i, had, best, c... {'Gannon': 1, '’': 1, 's': 1, 'Isle': 1, 'Ice'...
1 Hibachi the grill is one of my favorite restau... N [Hibachi the grill is one of my favorite resta... 5 [hibachi, the, grill, is, one, of, my, favorit... 65 [hibachi, grill, one, favorite, restaurants, l... 30 [(the, 8), (is, 6), (it, 3), (hibachi, 2), (gr... [(hibachi, 2), (grill, 2), (restaurants, 2), (... ... 0.388 the is it hibachi grill of restaurants i and l... {'neg': 0.0, 'neu': 0.747, 'pos': 0.253, 'comp... 0.8885 0.000 0.747 0.253 [hibachi, the, grill, is, one, of, my, favorit... [the, is, it, hibachi, grill, of, restaurants,... {'Hibachi': 2, 'the': 6, 'grill': 2, 'is': 6, ...
2 RIM KAAP One of the best Thai restaurants in t... N [RIM KAAP One of the best Thai restaurants in ... 11 [rim, kaap, one, of, the, best, thai, restaura... 141 [rim, kaap, one, best, thai, restaurants, town... 75 [(the, 12), (of, 3), (thai, 3), (and, 3), (for... [(thai, 3), (food, 3), (rim, 2), (kaap, 2), (b... ... 0.369 the of thai and for a food rim kaap best in to... {'neg': 0.0, 'neu': 0.714, 'pos': 0.286, 'comp... 0.9559 0.000 0.714 0.286 [rim, kaap, one, of, the, best, thai, restaura... [the, the_NEG, thai, rim, kaap, best, in, to, ... {'RIM': 2, 'KAAP': 2, 'One': 1, 'of': 3, 'the'...

3 rows × 40 columns

In [ ]: