Skip to content

Instantly share code, notes, and snippets.

Kyle Gorman kylebgorman

Block or report user

Report or block kylebgorman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kylebgorman
kylebgorman / lnre.py
Last active Sep 1, 2019
LNRE calculator
View lnre.py
#!/usr/bin/env python
"""LNRE calculator.
This script computes a number of statistics characterizing LNRE data:
* N: corpus size
* V: vocabulary size
* V(1): the number of _hapax legomena_ (symbols occuring once)
* V(2): the number of _dis legomena_ (symbols occurring twice)
* V/N: vocabulary growth rate
@kylebgorman
kylebgorman / byte.sym
Created Jul 10, 2019
OpenFst byte symbol table
View byte.sym
<epsilon> 0
<SOH> 1
<STX> 2
<ETX> 3
<EOT> 4
<ENQ> 5
<ACK> 6
<BEL> 7
<BS> 8
<HT> 9
@kylebgorman
kylebgorman / casefold.py
Created Jul 10, 2019
Applies Unicode case folding to input data
View casefold.py
#!/usr/bin/env python
import fileinput
import nltk
if __name__ == "__main__":
for line in fileinput.input():
print(line.rstrip().casefold())
@kylebgorman
kylebgorman / word_tokenize.py
Last active Jul 10, 2019
Applies NLTK PTB tokenizer to input text
View word_tokenize.py
#!/usr/bin/env python
import fileinput
import nltk
if __name__ == "__main__":
for line in fileinput.input():
print(" ".join(nltk.word_tokenize(line)))
@kylebgorman
kylebgorman / lmcompile.py
Last active Jul 10, 2019
FAR compilation for tokens, with simple UNKing support
View lmcompile.py
#!/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 Jul 9, 2019
The minimal non-trivial Python script
View minimal.py
#!/usr/bin/env python
"""ONE-LINE DESCRIPTION HERE."""
import argparse
import logging
def main(args):
# ADD LOGIC HERE.
@kylebgorman
kylebgorman / covfefe.py
Created Jun 8, 2019
Which English word is most similar to "covfefe"?
View covfefe.py
#!/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
Update shared library caches
View fix.sh
# On Linux:
sudo ldconfig
# On Mac OS X:
sudo update_dyld_shared_cache
@kylebgorman
kylebgorman / yeonju_solution.py
Created Feb 27, 2019
Yeonju's solution to part one of MP1
View yeonju_solution.py
"""Yeonju's solution to part 1 of MP1."""
import nltk
text = """du
du hast
du hast mich
du
du hast
du hast mich
View .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"
You can’t perform that action at this time.