View peano.py
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 random | |
def Merge(x, y): | |
return ''.join([a for t in zip(x, y) for a in t]) | |
def Peano(x, y): | |
interim = ''.join(Merge(format(x, '08b'), format(y, '08b'))) | |
return int(interim, base=2) | |
def generate(n=100, ln=30): |
View slate.js
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
var pushLeft = slate.operation("push", { | |
"direction" : "left", | |
"style" : "bar-resize:screenSizeX/2" | |
}); | |
var pushRight = slate.operation("push", { | |
"direction" : "right", | |
"style" : "bar-resize:screenSizeX/2" | |
}); |
View fromstring.py
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
""" | |
Use at own risk. | |
I use nltk for many purposes, but I needed a faster version of nltk.Tree.fromstring. | |
This implementation is much faster and works for my use case, but it | |
has not been tested extensively on complex input. | |
Original fromstring implementation from nltk is here: | |
https://github.com/nltk/nltk/blob/develop/nltk/tree.py |
View context_insensitive_word_embeddings.py
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 os | |
import hashlib | |
from allennlp.commands.elmo import ElmoEmbedder | |
from allennlp.data.token_indexers.elmo_indexer import ELMoCharacterMapper | |
import numpy as np | |
def save_elmo_cache(path, vectors): | |
np.save(path, vectors) |
View ep1-outline.txt
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
YES Bernard's secret revealed. # His name was an anagram. | |
NO Man in black pays a visit to Dolores. | |
YES Host gets repaired. # Bernard | |
YES There's a flashback. # Bernard has a flashback | |
? Radiohead's song played. | |
? The maze is referenced. | |
NO Maeve uses her powers. | |
YES A character gets redemption. # Dolores gets redemption on some of the wealthy men. | |
? "Wake up, Dolores". | |
? A new host storyline is presented (perhaps by Sizemore). |
View git-tmp.py
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 | |
import json | |
import os | |
import shutil | |
import subprocess | |
import sys | |
import tempfile | |
# env |
View akbc
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
https://docs.google.com/presentation/d/1vtsYo064-oO1ZeFuB5uOBHIM5dMt3bUh6qkgFlj_kbU/edit?usp=sharing |
View conll2003.py
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 os | |
import collections | |
path = os.path.expanduser('~/data/conll2003/eng.train') | |
# Read raw data. | |
with open(path) as f: | |
dataset = [] | |
example = dict() | |
for line in f: |
View match_ptb_propbank.py
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 | |
import os | |
import sys | |
import time | |
import collections | |
import json | |
from tqdm import tqdm | |
View bert-masking.py
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
# Run once for each size. | |
In [1]: import torch | |
In [2]: a = torch.arange(100).view(10, 10) | |
In [3]: a | |
Out[3]: | |
tensor([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], | |
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19], |
NewerOlder