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
--- | |
title: "NLP Project 1: Language modeling" | |
author: Fred Callaway | |
--- | |
__Note to Grader:__ I had difficulties with my partner, which is why this is being turned in late, and separately. Please contact Dr.Cardie if you are hearing this for the first time. | |
# Model components |
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 re | |
def add_print_parentheses(file_name): | |
match = None # a regex match when we are in a print statment | |
lines = [] | |
with open(file_name) as file: | |
for line in file: | |
line = line.rstrip() | |
if match: # we are in a print statement | |
indentation = re.match(r'[ ]*', line).span()[1] |
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
"""IO spoofing.""" | |
import sys | |
from contextlib import contextmanager | |
from io import StringIO | |
from collections import deque | |
@contextmanager | |
def capture_stdout(): |
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/python | |
# -*- coding: utf-8 -*- | |
import sublime, sublime_plugin | |
import os | |
import re | |
import webbrowser | |
import itertools | |
from datetime import datetime | |
from datetime import timedelta |
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 | |
# encoding: utf-8 | |
""" | |
gscholar.py | |
Created by Andrew Ning on November 16, 2013 | |
Updated by Fred Callaway September 2016 | |
""" | |
from __future__ import print_function |
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
@font-face { | |
font-family: 'Cinzel'; | |
font-style: normal; | |
font-weight: 400; | |
src: local('Cinzel-Regular'), url(//themes.googleusercontent.com/static/fonts/cinzel/v1/mLL0ZqnXRx3m16FnBy9gcg.woff) format('woff'); | |
} | |
@font-face { | |
font-family: 'Droid Sans'; | |
font-style: normal; | |
font-weight: 400; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 itertools as it | |
import numpy as np | |
ivs = [ | |
('hit', [0, 1, 2]), | |
('layout', 'ABCDEF'), | |
('cue', 'TF'), | |
] | |
# At present, the first iv defines the number and orderof trials. Thus, |
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 numpy as np | |
import pymc3 as pm | |
import theano | |
class StochasticMatrix(pm.Continuous): | |
"""A stochastic matrix has rows that sum to 1.""" | |
def __init__(self, theta, *args, **kwargs): | |
shape = (theta.shape[-1], theta.shape[-1]) | |
kwargs.setdefault('shape', shape) | |
super(StochasticMatrix, self).__init__(*args, **kwargs) |
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 toolz import pipe | |
class Blank(object): | |
"""Forgive me Lord, for I have sinned. | |
Inspired by implicit partial application in Coconut: | |
http://coconut.readthedocs.io/en/master/DOCS.html#implicit-partial-application | |
""" | |
def __getattr__(self, attr): |
OlderNewer