Skip to content

Instantly share code, notes, and snippets.

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
);
@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
@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 / 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 / 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 / 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 / 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 = [], []
## all
find ../KNBC_v1.0_090925/corpus1 -type f -name "KN*" | LC_ALL=C sort | xargs cat | python ../tools/knbc2cabocha.py KNP | python ../tools/replace_pos.py mecab -d /usr/local/lib/mecab/dic/jumandic > corpus.euc
iconv -f EUC-JP -t UTF-8 corpus.euc > corpus
/usr/local/libexec/cabocha/cabocha-learn -e chunk -P JUMAN -t utf-8 corpus chunk.model;
/usr/local/libexec/cabocha/cabocha-learn -e dep -P JUMAN -t utf-8 corpus dep.model
cat corpus | python ../tools/to_sent.py | mecab -d /usr/local/lib/mecab/dic/jumandic > tagged
time cat tagged | cabocha -m dep.model -M chunk.model -P JUMAN -I1 -f1 > result
python ../tools/eval.py result corpus
## simple cv
## all
find ../KNBC_v1.0_090925/corpus1 -type f -name "KN*" | LC_ALL=C sort | xargs cat | python ../tools/knbc2kyoto.py KNP | python ../tools/replace_pos.py mecab -d /usr/local/lib/mecab/dic/jumandic > corpus.euc
iconv -f EUC-JP -t UTF-8 corpus.euc > corpus
mkdir -p model/knbc && rm -rf model/knbc/*
jdepp -t 0 -I 1 -c corpus -m model/knbc -- -t 1 -d 2 -c 0.0008 -i 40 -p
jdepp -t 3 -I 1 -c corpus -m model/knbc -- -t 1 -d 2 -c 0.0008 -i 40 -p -- -s 0.02 -i 5 -t 1
jdepp -t 0 -I 2 -c corpus -m model/knbc -- -t 1 -d 2 -c 0.00005 -i 40 -p
jdepp -t 3 -I 2 -c corpus -m model/knbc -- -t 1 -d 2 -c 0.00005 -i 40 -p -- -- -s 0.005 -i 5 -t 1
cat corpus | python ../tools/to_sent.py | mecab -d /usr/local/lib/mecab/dic/jumandic > tagged
@hiropppe
hiropppe / mac.vimrc
Last active March 21, 2017 19:08
頭の2行とコピペだけやればとりあえずそれっぽくなる
$ mkdir -p ~/.vim/bundle
$ git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
$ vim ~/.vimrc
" Note: Skip initialization for vim-tiny or vim-small.
if 0 | endif
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved