Skip to content

Instantly share code, notes, and snippets.

View kylebgorman's full-sized avatar

Kyle Gorman kylebgorman

View GitHub Profile
@kylebgorman
kylebgorman / lmcompile.py
Last active July 10, 2019 14:08
FAR compilation for tokens, with simple UNKing support
#!/usr/bin/env python
"""Compiles compact FAR from tokenized data for LM construction."""
import argparse
import collections
import heapq
import logging
import operator
from typing import List
@kylebgorman
kylebgorman / minimal.py
Created July 9, 2019 02:27
The minimal non-trivial Python script
#!/usr/bin/env python
"""ONE-LINE DESCRIPTION HERE."""
import argparse
import logging
def main(args):
# ADD LOGIC HERE.
@kylebgorman
kylebgorman / covfefe.py
Created June 8, 2019 19:11
Which English word is most similar to "covfefe"?
#!/usr/bin/env python
# What's the nearest word (in Levenshtein distance) to "covfefe"?
import string
# Available from: https://github.com/kylebgorman/EditTransducer
import edit_transducer
# You probably have this file if you're on Linux or Mac OS X.
with open("/usr/share/dict/words") as source:
@kylebgorman
kylebgorman / fix.sh
Created May 6, 2019 18:14
Update shared library caches
# On Linux:
sudo ldconfig
# On Mac OS X:
sudo update_dyld_shared_cache
@kylebgorman
kylebgorman / yeonju_solution.py
Created February 27, 2019 14:53
Yeonju's solution to part one of MP1
"""Yeonju's solution to part 1 of MP1."""
import nltk
text = """du
du hast
du hast mich
du
du hast
du hast mich
@kylebgorman
kylebgorman / .somafm_aliases
Last active October 21, 2020 23:08
SomaFM aliases
alias beatblender="mplayer -playlist http://somafm.com/beatblender130.pls"
alias covers="mplayer -playlist http://somafm.com/covers130.pls"
alias deepspaceone="mplayer -playlist http://somafm.com/deepspaceone130.pls"
alias defconradio="mplayer -playlist http://somafm.com/defconradio130.pls"
alias dronezone="mplayer -playlist http://somafm.com/dronezone130.pls"
alias fluid="mplayer -playlist http://somafm.com/fluid130.pls"
alias groovesalad="mplayer -playlist http://somafm.com/groovesalad130.pls"
alias gsclassic="mplayer -playlist http://somafm.com/gsclassic130.pls"
alias indiepoprocks="mplayer -playlist http://somafm.com/indiepoprocks130.pls"
alias lush="mplayer -playlist http://somafm.com/lush130.pls"
@kylebgorman
kylebgorman / torch_cuda.py
Last active October 8, 2019 15:58
Checks that PyTorch can reach CUDA
#!/usr/bin/env python
"""Checks that PyTorch can reach CUDA."""
import sys
import torch
if __name__ == "__main__":
if not torch.cuda.is_available():
@kylebgorman
kylebgorman / log_odds.pyx
Last active February 6, 2024 19:49
Log-odds calculations
"""Log-odds computations."""
from libc.math cimport log, sqrt
from libc.stdint cimport int64_t
ctypedef int64_t int64
@kylebgorman
kylebgorman / LING78100-lecture04.ipynb
Last active October 3, 2018 20:37
LING78100 Lecture 4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebgorman
kylebgorman / LING83600-mp00.md
Created September 14, 2018 00:08
LING83600-mp00.md

MP 0: Text preparation

In this (optional) MP you will prepare a corpus of free English newswire text for use in later assignments. This is intended to provide practical Python programming experience, but will not be graded.

For this task we will use a subset of the News Crawl corpus consisting of data from the year 2009. This (very large: 3.7 GB) file is available here as a gzipped TAR file.

What to do

  1. Download the file: