This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wordcloud import WordCloud | |
def generate_word_cloud_from_frequencies(freq_dict, status): | |
wordcloud = WordCloud( | |
width=800, | |
height=400, | |
background_color = 'black', | |
stopwords = stop_words).generate_from_frequencies(frequencies=freq_dict) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def preprocess_tweet(tweet): | |
processed_tweet = [] | |
# Convert to lower case | |
tweet = tweet.lower() | |
#Clean only digits | |
tweet = re.sub("^\d+\s|\s\d+\s|\s\d+$", " ", tweet) | |
# Replaces URLs with the word URL | |
#tweet = re.sub(r'((www\.[\S]+)|(https?://[\S]+))', ' URL ', tweet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_emojis(tweet): | |
# Smile -- :), : ), :-), (:, ( :, (-:, :') | |
tweet = re.sub(r'(:\s?\)|:-\)|\(\s?:|\(-:|:\'\))', ' EMO_POS ', tweet) | |
# Laugh -- :D, : D, :-D, xD, x-D, XD, X-D | |
tweet = re.sub(r'(:\s?D|:-D|x-?D|X-?D)', ' EMO_POS ', tweet) | |
# Love -- <3, :* | |
tweet = re.sub(r'(<3|:\*)', ' EMO_POS ', tweet) | |
# Wink -- ;-), ;), ;-D, ;D, (;, (-; | |
tweet = re.sub(r'(;-?\)|;-?D|\(-?;)|😉', ' EMO_POS ', tweet) | |
# Sad -- :-(, : (, :(, ):, )-: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def preprocess_word(word): | |
# Remove punctuation | |
word = word.strip('\'"?!,.():;``') | |
# Convert more than 2 letter repetitions to 2 letter | |
# funnnnny --> funny | |
word = re.sub(r'(.)\1+', r'\1\1', word) | |
# Remove - & ' | |
word = re.sub(r'(-|\')', '', word) | |
return word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline | |
# load model | |
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") | |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") | |
# create pipeline | |
sa = pipeline("sentiment-analysis", tokenizer=tokenizer, model=model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import snscrape.modules.twitter as sntwitter | |
import pandas as pd | |
def search_hashtag(searchterm, dt_until, dt_since, lang, limit=100000): | |
query = "({searchterm}) lang:{lang} until:{until} since:{since}".format(searchterm=searchterm, lang=lang, until=dt_until, since=dt_since) | |
#query = (#Emmys2022) lang:en until:2022-09-14 since:2022-09-01 | |
tweets = [] | |
limit = limit | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"adana": [ | |
"Hatay", | |
"Osmaniye", | |
"Kahramanmaras", | |
"Kayseri", | |
"Nigde", | |
"Mersin" | |
], | |
"adiyaman": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
#Sample use: $ python3 test_youtube_live.py -c "UCryGec9PdUCLjpJW2mgCuLw" | |
# {'video_id': 'j78TwQCfEzc', 'video_link': 'https://www.youtube.com/watch?v=j78TwQCfEzc', 'published_at': '2019-11-14T03:13:53.000Z', 'title': 'Seeing 2020', 'isLive': True} | |
import argparse | |
import requests | |
import json | |
ap = argparse.ArgumentParser() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
API_URL = 'https://api.intenseye.com/images/detection' | |
TOKEN = '{INTENSEYE_TOKEN}' | |
IMAGE_URL = "http://yavuzkomecoglu.com/img/hababam.jpg" | |
headers = { | |
'Content-Type': 'application/json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from io import BytesIO | |
import numpy as np | |
import requests | |
import json | |
import cv2 | |
TOKEN = '{INTENSEYE_TOKEN}' | |
IMAGE_URL = "http://yavuzkomecoglu.com/img/hababam.jpg" |
NewerOlder