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
import dataclasses as dc | |
from jax import tree_util as jt | |
def register_jax_dataclass(cls): | |
"""Registers a dataclass as a JAX pytree.""" | |
if not dc.is_dataclass(cls): | |
raise TypeError('%s is not a dataclass.' % cls) | |
keys = [field.name for field in dc.fields(cls)] |
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
// Wrapper class of KyTea word segmenter. | |
// Author: odashi | |
// Date: 2021-01-26 | |
// License: MIT | |
#include <memory> | |
#include <string> | |
#include "kytea/kytea.h" | |
#include "kytea/string-util.h" |
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/python3 | |
import datetime | |
import sys | |
import math | |
import numpy as np | |
from argparse import ArgumentParser | |
from collections import defaultdict | |
from chainer import FunctionSet, Variable, functions, optimizers |
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
# 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(): |
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
#!/bin/zsh | |
autoload colors; colors | |
if [ $# != 2 ]; then | |
echo "usage: $0 <root-dir> <command>" | |
exit 1 | |
fi | |
ROOTDIR=$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
[cubase parse file] | |
[parser version 0001] | |
[creators first name] https://twitter.com/odashi | |
[creators last name] yus.takara@gmail.com | |
[device manufacturer] ROLAND | |
[device name] INTEGRA-7 | |
[script name] Roland INTEGRA-7 | |
[script version] version 0.03 |
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
<?php | |
/* PHPでTwitter OAuth認証を行うサンプル・プログラム | |
* Author : お出汁 | |
* Creation : 2010/10/12 | |
* Update : 2013/01/21 | |
* Version : 0.3 | |
* Twitter API Wikiのabraham's twitteroauth 0.2.0を使わせて頂いています。 | |
*/ | |
require_once('twitteroauth/twitteroauth.php'); |
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
// 実行方法: | |
// 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; |
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 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', |
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
# debug.py | |
# coding: utf-8 | |
import sys | |
DEBUG = False | |
WHITE = '\033[37m' |