Skip to content

Instantly share code, notes, and snippets.

@kipronokoech
Created August 2, 2020 14:43
Show Gist options
  • Save kipronokoech/d5bfca20d9db1d89af99b043018bbab3 to your computer and use it in GitHub Desktop.
Save kipronokoech/d5bfca20d9db1d89af99b043018bbab3 to your computer and use it in GitHub Desktop.
# Most of the cleaning was done during the data web scraping
# Find the notebook here
# https://github.com/kipronokoech/Reviews-Classification/blob/master/data_collection.ipynb
reviews = []
with open("./data/reviews.txt") as fp:
for index,line in enumerate(fp):
# line is a strong on loading so we need to convert to dictionary
review = ast.literal_eval(line)
#categorize the review and append it to reviews
reviews.append(Review(review['reviewBody'], review['stars']))
# print out the text and the sentiment category of review[0]
print(reviews[0].text)
print(reviews[0].sentiment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment