Skip to content

Instantly share code, notes, and snippets.

Yusuke Oda odashi

Block or report user

Report or block odashi

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
@odashi
odashi / imake.zsh
Last active Feb 24, 2019
Performs a command when the content of a directory changed.
View imake.zsh
#!/bin/zsh
autoload colors; colors
if [ $# != 2 ]; then
echo "usage: $0 <root-dir> <command>"
exit 1
fi
ROOTDIR=$1
@odashi
odashi / cudnn_convolution_forward.cu
Created Jan 8, 2018
Example usage of cuDNN convolution forward functions.
View cudnn_convolution_forward.cu
#include <iomanip>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cuda.h>
#include <cudnn.h>
#define CUDA_CALL(f) { \
cudaError_t err = (f); \
@odashi
odashi / primitiv_xor.cc
Last active Dec 26, 2017
primitiv examples for Qiita (C++11/Python3)
View primitiv_xor.cc
// 実行方法:
// g++ -std=c++11 xor.cc -lprimitiv && ./a.out
#include <cstdio>
#include <iostream>
#include <primitiv/primitiv.h>
using namespace primitiv;
namespace D = primitiv::devices;
namespace F = primitiv::functions;
@odashi
odashi / gameoflife.cc
Last active Jun 6, 2017
Game of life on X11
View gameoflife.cc
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <random>
#include <thread>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
using namespace std;
@odashi
odashi / gameoflife.py
Last active Jun 1, 2017
The console game of life
View gameoflife.py
#!/usr/bin/env python3
import curses
from random import random
from time import sleep
def main(scr):
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_WHITE)
@odashi
odashi / apply_byte_pair_encoding.py
Last active Aug 15, 2017
Byte-pair encoding tools
View apply_byte_pair_encoding.py
#!/usr/bin/env python3
import sys
from argparse import ArgumentParser
from collections import defaultdict
def parse_args():
p = ArgumentParser('Converts word to integer using byte-pair encoding.')
p.add_argument(
'--input',
@odashi
odashi / generators.py
Created Mar 23, 2016
Frequently-used batch generators for my NLP study.
View generators.py
import builtins
import random
def word_list(filename):
with open(filename) as fp:
for l in fp:
yield l.split()
def batch(generator, size):
batch = []
@odashi
odashi / mert.py
Last active May 1, 2016
Minimum error-rate training for statistical machine translation
View mert.py
#!/usr/bin/python3
import math
import random
import sys
from argparse import ArgumentParser
from collections import defaultdict
from util.functions import trace
def parse_args():
@odashi
odashi / bleu.py
Last active Sep 20, 2019
BLEU calculator
View bleu.py
# usage (single sentence):
# ref = ['This', 'is', 'a', 'pen', '.']
# hyp = ['There', 'is', 'a', 'pen', '.']
# stats = get_bleu_stats(ref, hyp)
# bleu = calculate_bleu(stats) # => 0.668740
#
# usage (multiple sentences):
# stats = defaultdict(int)
# for ref, hyp in zip(refs, hyps):
# for k, v in get_bleu_stats(ref, hyp).items():
@odashi
odashi / StanfordTokenizerRunner.java
Created Jan 26, 2016
Stanford Tokenizerを強制的に1行ずつ解析させるラッパ。パイプ通信用に使える。
View StanfordTokenizerRunner.java
import java.io.*;
import java.util.*;
import edu.stanford.nlp.ling.Word;
import edu.stanford.nlp.process.WordTokenFactory;
import edu.stanford.nlp.process.PTBTokenizer;
public class StanfordTokenizerRunner {
private static List<String> tokenize(String text) {
PTBTokenizer<Word> tokenizer = new PTBTokenizer<Word>(
You can’t perform that action at this time.