This file contains hidden or 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
#http://stackoverflow.com/questions/26177620/how-to-execute-scrapy-shell-url-with-notebook | |
import requests | |
from scrapy.http import TextResponse | |
r = requests.get('http://stackoverflow.com/') | |
response = TextResponse(r.url, body=r.text, encoding='utf-8') |
This file contains hidden or 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 pandas as pd | |
import geoip2.database | |
mmdb_path = 'C:\\Users\\Manash\\Downloads\\Compressed\\GeoLite2-Country.mmdb\\GeoLite2-Country.mmdb' | |
ipaddress_path = 'C:\\Users\\Manash\\Downloads\\IP_Address.csv' | |
ipdf = pd.read_csv(ipaddress_path) | |
reader = geoip2.database.Reader(mmdb_path) | |
for ip in ipdf['IP Address']: |
This file contains hidden or 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
status_updates = ['JOIN ME FOR A FEW MINUTES IN PANAMA CITY BEACH, FLORIDA. This is a MOVEMENT like never seen before- and will never be seen again. This is our last chance- lets MAKE AMERICA SAFE AND GREAT AGAIN!', 'I would like to wish everyone who is observing the solemn and holy day of Yom Kippur an inspirational day of reflection. We hope that everyone’s prayers are answered and that we all have a year of peace, security, good health, prosperity and blessings. -DJT', 'JOIN ME FOR A FEW MINUTES IN PANAMA CITY BEACH, FLORIDA. This is a MOVEMENT like never seen before- and will never be seen again. This is our last chance- lets MAKE AMERICA SAFE AND GREAT AGAIN!', 'I would like to wish everyone who is observing the solemn and holy day of Yom Kippur an inspirational day of reflection. We hope that everyone’s prayers are answered and that we all have a year of peace, security, good health, prosperity and blessings. -DJT', 'Great morning in San Antonio, Texas - GREAT afternoon in Dallas, Texas. Departing now |
This file contains hidden or 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
# Dependencies: | |
# NLTK | |
# WordCloud | |
# Scikit-learn | |
# Matplotlib | |
# Scipy | |
# Python version: 2.7 | |
%matplotlib inline |
This file contains hidden or 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
install.packages('ggplot2') | |
require(ggplot2) | |
df <- data.frame(Sentiment = c('Positive', 'Negative'), Count = c(174, 115)) | |
ggplot(df, aes(Sentiment, Count)) + geom_bar(stat="identity") |
This file contains hidden or 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 selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from bs4 import BeautifulSoup | |
from requests import get | |
from lxml import html | |
class FacebookSpider(): | |
def __init__(self, userid, password): | |
self.userid = userid | |
self.password = password |
This file contains hidden or 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 pandas as pd | |
import os | |
import numpy as np | |
import random | |
from sklearn.utils import shuffle | |
import matplotlib.pyplot as plt | |
positive_text_path = './txt_sentoken/pos/' | |
negative_text_path = './txt_sentoken/neg/' |
This file contains hidden or 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 nltk | |
print nltk.__version__ | |
from nltk.tag import StanfordNERTagger | |
import os | |
st = StanfordNERTagger(os.environ.get('STANFORD_MODELS')) | |
print st._stanford_jar |
This file contains hidden or 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 nltk.tag import StanfordNERTagger | |
import os | |
print os.environ.get('STANFORD_MODELS') | |
# Output: | |
#/home/jackspicer/StanfordParser/stanford-ner-2015-12-09/classifiers/english.all.3class.distsim.crf.ser.gz:/home/jackspicer/stanford-postagger-2015-12-09/models/english.conll.4class.distsim.crf.ser.gz:/home/jackspicer/StanfordParser/stanford-ner-2015-12-09/english.muc.7class.distsim.crf.ser.gz | |
# I want to select the first classifier model |
This file contains hidden or 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
void setup(){ | |
Serial.begin(9600); | |
Serial1.begin(9600); | |
Serial.println("Init"); | |
pinMode(13, OUTPUT); | |
} | |
char b; | |
void loop(){ |