Skip to content

Instantly share code, notes, and snippets.

@hiropppe
hiropppe / eval.py
Last active November 29, 2015 17:40
J.DepPの付属のチャンキングと係り受けの評価スクリプト
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, re
if len (sys.argv) < 3:
sys.exit ("Usage: %s auto gold" % sys.argv[0])
def collect_info (fn):
sep = re.compile (r'(?:\t|\s)*')
chunk, depnd = [], []
@hiropppe
hiropppe / eval_all.py
Last active November 29, 2015 18:13
J.DepP付属の評価スクリプト(tools/eval.py)の出力をガッちゃんこするやつ
#!/usr/bin/env python
import sys, re
r_sum = re.compile(r'\((\d+)/(\d+)\)')
acc, param = [], []
for line in sys.stdin:
if line.split()[0] in (['precision:', 'recall:', 'sent']):
m = r_sum.findall(line)
@hiropppe
hiropppe / knbc2cabocha.py
Last active November 30, 2015 14:41
KNBコーパスをCaboCha形式へ変換するスクリプト
#!/usr/bin/env/python
# Usage: knbc2cabocha.py [format]
# convert KNB corpus to CaboCha format
import sys, re
header, data, head, body, t2c = "", "", [], [], {}
pat_d = re.compile (r'^\d+')
pat_s = re.compile (r'\s+')
for line in sys.stdin:
if line[0] == '#':
@hiropppe
hiropppe / simple_setting_for_python.vimrc
Last active November 4, 2015 04:05
ec2とかちょっと入った環境でなんか書きたいときにこれ使う
set encoding=utf8
set number
set paste
set expandtab
set textwidth=0
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set backspace=indent,eol,start
@hiropppe
hiropppe / centos7_pyenv_virtualenv_setup.sh
Last active November 14, 2015 07:06
手元のvm(centos7)のpyenv環境の設定メモ、基本githubのREADMEどおり
yum install -y gcc patch openssl-devel zlib-devel bzip2-devel readline-devel sqlite-devel
curl -kL https://bootstrap.pypa.io/get-pip.py | python
pip install --upgrade pip
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
exec -l $SHELL
@hiropppe
hiropppe / github_push_to_piccolo_repository.log
Last active November 16, 2017 00:31
Gitリポジトリを他のリモートリポジトリにプッシュする
## 本家をクローン
[root@docker-host gitbucket_workspace]# git clone https://github.com/......../fork-test.git
[root@docker-host gitbucket_workspace]# cd fork-test/
[root@docker-host fork-test]# git tag
release_0.0.1
release_0.0.2
[root@docker-host fork-test]# git branch
* master
[root@docker-host fork-test]# git branch -a
* master
import MySQLdb
import itertools
from random import randrange, choice
spot_ddl = """
CREATE TABLE IF NOT EXISTS spot (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(10) NOT NULL,
seq INT NOT NULL
);
import pymongo
from bson.dbref import DBRef
from collections import OrderedDict
from random import randrange, choice
client = pymongo.MongoClient()
test = client.test
spot = test.spot
play = test.play
@hiropppe
hiropppe / zip.sql
Last active October 2, 2015 13:52
MySQL function which behaves like zip function.
CREATE FUNCTION `zip`(_first text, _second text, _separator text, _pair_separator text) RETURNS text CHARSET utf8
BEGIN
DECLARE _ret text;
IF 0 < LENGTH(_first) THEN
SELECT
GROUP_CONCAT(
CONCAT_WS(
_pair_separator,
REPLACE(SUBSTRING_INDEX(v.`first`, _separator, p.rownum), CONCAT(SUBSTRING_INDEX(v.`first`, _separator, p.rownum - 1), _separator), ''),
public class IdWorker {
long workerBits = 5L;
long datacenterBits = 5L;
long sequenceBits = 12L;
long workerIdShift = sequenceBits;
long datacenterIdShift = sequenceBits + workerBits;
long timestampLeftShift = sequenceBits + workerBits + datacenterBits;