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 __future__ import unicode_literals | |
from bs4 import BeautifulSoup | |
import urllib | |
from selenium import webdriver | |
import time | |
import spacy | |
from twython import Twython | |
import json | |
# "loadin' the pipeline" |
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
// The Nature of Code | |
// Daniel Shiffman | |
// http://natureofcode.com | |
// Genetic Algorithm, Evolving Shakespeare | |
// A class to describe a pseudo-DNA, i.e. genotype | |
// Here, a virtual organism's DNA is an array of character. | |
// Functionality: | |
// -- convert DNA into a string |
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 bs4 | |
import urllib | |
url = "https://www.amazon.com/TopHeadwear-Face-Mask-Colors-Black/dp/B00X82QUHY/ref=sr_1_8?ie=UTF8&qid=1486007211&sr=8-8&keywords=black+ski+mask" | |
html = urllib.urlopen(url).read() | |
soup = bs4.BeautifulSoup(html, 'html.parser') | |
titles = soup.select('.review-data') |
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
# generate dictionaries to feed into markov.py | |
import markov | |
# cb speak | |
cb_terms_file = open("/Users/user/Documents/itp/rwet/final/categories/cbspeak-terms.txt").readlines() | |
cb_terms = markov.char_level_generate(cb_terms_file, 4, 100) | |
cb_defs_file = open("/Users/user/Documents/itp/rwet/final/categories/cbspeak-defs.txt").readlines() | |
cb_defs = markov.char_level_generate(cb_defs_file, 4, 100) |
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
# rwet hw 3 | |
import random | |
from string import punctuation | |
# strip first ~50 lines of metadata | |
lyrics_file = "/path/to/file" | |
lyrics = [line.strip() for line in \ | |
open(lyrics_file).readlines() | |
if len(line.strip()) > 0] |
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
# hw3 for rwet | |
import urllib | |
import json | |
import random | |
nouns_data = urllib.urlopen("https://raw.githubusercontent.com/dariusk/corpora/master/data/words/nouns.json").read() | |
noun_json = json.loads(nouns_data) | |
url = "http://api.nytimes.com/svc/books/v3/lists/combined-print-and-e-book-fiction.json?&api-key=🐈" |
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
# cribbed from Allison Parrish and Ross Goodwin | |
# https://gist.github.com/aparrish/ea3911c31cec8c858bd0/revisions | |
# https://gist.github.com/rossgoodwin/d45cba970add12c6190d | |
import random | |
from string import punctuation | |
# strip first ~50 lines of metadata | |
def not_with_semicolon(line): | |
if not line.startswith(';;;') and not line[0] in punctuation: |