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 | |
################################################################################ | |
# pequalnp.py | |
# Graham Neubig | |
# 4/1/2014 | |
# | |
# This is a program that provides an answer for the age-old problem of whether | |
# the class of problems that can be verified in polynomial time (NP) is equal | |
# to the class of problems for which an answer can be provided in polynomial |
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/perl | |
use strict; | |
use utf8; | |
use List::Util qw(max min); | |
binmode STDIN, ":utf8"; | |
binmode STDOUT, ":utf8"; | |
if(@ARGV != 2) { | |
print STDERR "Usage: counterrors.pl REFERENCE SYSTEM\n"; |
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
set.seed(123141) | |
fcount <- 20 | |
tcount <- 1 | |
alpha <- 3 | |
xf <- rnorm(fcount,mean=-1, sd=0.7) | |
xt <- rnorm(tcount,mean=1, sd=0.7) | |
yf <- mat.or.vec(fcount,1) | |
yt <- mat.or.vec(tcount,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
#include <vector> | |
#include <iostream> | |
#include <cstdlib> | |
#include <cmath> | |
using namespace std; | |
int SampleMultinomial(const vector<double> & distribution) { | |
double value = (double)rand()/RAND_MAX; | |
for(int i = 0; i < distribution.size(); i++) |
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 | |
# -*- coding: utf-8 -*- | |
import sys | |
import re | |
import datetime | |
pattern = ur'電力.*供給' | |
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 | |
# *************************** | |
# * solve-3sat.py | |
# * by Graham Neubig | |
# * 4/1/2013 | |
# *************************** | |
# | |
# This is a Python program to provide an answer for satisfiability problems | |
# in conjunctive normal form with 3 variables per clause (3SAT) in LINEAR time. | |
# |
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 | |
# -*- coding: utf-8 -*- | |
# This is a simplified implementation of the LSTM language model (by Graham Neubig) | |
# | |
# LSTM Neural Networks for Language Modeling | |
# Martin Sundermeyer, Ralf Schlüter, Hermann Ney | |
# InterSpeech 2012 | |
# | |
# The structure of the model is extremely simple. At every time step we |
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
""" | |
DyNet implementation of a sequence labeler (POS taggger). | |
This is a translation of this tagger in PyTorch: https://gist.github.com/hal3/8c170c4400576eb8d0a8bd94ab231232 | |
Basic architecture: | |
- take words | |
- run though bidirectional GRU | |
- predict labels one word at a time (left to right), using a recurrent neural network "decoder" | |
The decoder updates hidden state based on: | |
- most recent word |
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 | |
# A python implementation of the string rewriting kernel | |
# by Graham Neubig | |
# | |
# Reference: | |
# Fan Bu, Hang Li, Xiaoyan Zhu. "String Rewriting Kernel". ACL 2012 | |
# http://aclweb.org/anthology-new/P/P12/P12-1047.pdf | |
from math import factorial |
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 | |
# This code implements the training part of the Restricted Boltzmann Machine | |
# language model described by: | |
# Three New Graphical Models for Statistical Language Modeling | |
# Andriy Mnih and Geoffrey Hinton | |
# ICML 2007 | |
# http://www.gatsby.ucl.ac.uk/~amnih/papers/threenew.pdf | |
# | |
# Usage: train-rbmlm.py training-file.txt |
OlderNewer