Skip to content

Instantly share code, notes, and snippets.

View vchahun's full-sized avatar

Victor Chahuneau vchahun

View GitHub Profile
@vchahun
vchahun / scraper.py
Created April 14, 2011 22:36
Scrape links from Google News
We couldn’t find that file to show.
@vchahun
vchahun / batch.sh
Created October 18, 2011 16:56
Parallel batch tokenization
#!/usr/bin/env bash
set -e
set -o pipefail
myDir=$(dirname $0)
if [[ $# != 4 && $# != 5 ]]; then
echo >&2 "Usage: $0 myfine.fst inText outToks tempDir [--text]"
echo >&2 " --text is for use with recitation lowercaser"
exit 1
fi
@vchahun
vchahun / opszip.py
Created November 16, 2011 22:40
Obfuscated python
opzip = lambda *operators: (lambda *args: tuple(op(*arg) for (op, arg) in zip(operators, zip(*args))))
@vchahun
vchahun / trec.py
Created March 19, 2012 17:03
Trec evaluation
from contextlib import contextmanager
from tempfile import NamedTemporaryFile
import logging
import re
import requests
EVAL = "http://boston.lti.cs.cmu.edu/classes/11-741/HW/HW3/upload.cgi"
def html2txt(html):
txt = re.sub("<[^>]+>", "\n", html)
@vchahun
vchahun / dict-loops.py
Created April 6, 2012 00:46
Dictionary assignment in a loop
l = [(1, 2), (3, 4), (5, 6)]
d = {}
for d['a'], d['b'] in l:
print d
@vchahun
vchahun / cdec-mt.py
Created August 8, 2012 23:23
Multi-process decoding with cdec
#!/usr/bin/env python
import sys
import argparse
import logging
import multiprocessing as mp
import cdec
decoder = None
def make_decoder(config, weights):
global decoder
@vchahun
vchahun / benchmark.ipy
Created August 16, 2012 01:03
Never use scipy.stats!!
import scipy.stats as ss
import math
import numpy as np
from timeit import timeit
np_log_poisson = lambda k, l: -l + k * np.log(l) - math.lgamma(k+1)
log_poisson = lambda k, l: -l + k * math.log(l) - math.lgamma(k+1)
%timeit -n 10000 ss.poisson.logpmf(5, 4) # 164.0 us
%timeit -n 10000 ss.poisson._logpmf(5, 4) # 23.1 us
@vchahun
vchahun / Draw.ipynb
Created September 26, 2012 03:38
Draw with pyfst
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vchahun
vchahun / fst.svg
Created September 30, 2012 04:12
Simple FST
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vchahun
vchahun / pyfst.ipynb
Last active October 11, 2015 09:07
pyfst demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.