Skip to content

Instantly share code, notes, and snippets.

View amittal-tcd's full-sized avatar

Adhishwar Mittal amittal-tcd

View GitHub Profile
@amittal-tcd
amittal-tcd / Wordclod.py
Created October 31, 2020 01:32
Create wordcloud from keyword frequency and associated review rating
# Import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from wordcloud import WordCloud
# Create combination metric and dictionary for wordcloud
df_r2 = df_r[(df_r['Rating'] <= 2)]
df_k2 = df_k.merge(df_r2, left_on = 'Key', right_on = 'Key')[['Keyword', 'Rating']]
df_k2['Rating'] = df_k2['Rating'].map(lambda x: 5 - x)
@amittal-tcd
amittal-tcd / Trustpilot Reviews Keyword Extractor.py
Last active October 31, 2020 01:04
Code to extract keywords from trustpilot review text
# Import libraries
import pandas as pd
import numpy as np
import yake
from yake.highlight import TextHighlighter
# Set Yake Parameters
language = "en"
max_ngram_size = 3
deduplication_thresold = 0.9
@amittal-tcd
amittal-tcd / TrustPilot Scraping.py
Last active October 31, 2020 01:29
TrustPilot Reviews Scraping Code
# Import libraries
import pandas as pd
import numpy as np
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
import math
import time
import random