Skip to content

Instantly share code, notes, and snippets.

Avatar
⛩️
Enjoying Kyoto.

Shotaro Tanaka yubessy

⛩️
Enjoying Kyoto.
View GitHub Profile
View file0.txt
>>> 'あいう'
'\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86'
View corenlp_example.py
import pprint
import json
import corenlp
# パーサの生成
corenlp_dir = "/usr/local/lib/stanford-corenlp-full-2013-06-20/"
parser = corenlp.StanfordCoreNLP(corenlp_path=corenlp_dir)
# パースして結果をpretty print
result_json = json.loads(parser.parse("I am Alice."))
@yubessy
yubessy / file0.txt
Last active Aug 29, 2015
PythonでExcelファイルを作成 + similarity matrix ref: http://qiita.com/yubessy/items/a39a565cdc2c5872cce9
View file0.txt
$ pip install xlsxwriter
@yubessy
yubessy / Default (OSX).sublime-keymap
Last active Aug 29, 2015
Sublime Text 2でコマンドパレットのコマンドにショートカットキーを割り当てる ref: http://qiita.com/yubessy/items/546fc167e6c6c248415b
View Default (OSX).sublime-keymap
[
{
"keys": ["command+_"],
"command": "run_emmet_action",
"args": {
"action": "merge_lines"
}
}
]
View sql_style1.py
sql_stmt = "CREATE TABLE Test(" \
"id INTEGER PRIMARY KEY, " \
"val TEXT NOT NULL)"
@yubessy
yubessy / myhtmlclean.py
Created Jun 29, 2014
HTMLをクリーンアップ
View myhtmlclean.py
# -*- coding: utf-8 -*-
# stdlib
import re
LEFT_SPACES = re.compile(r'\s+<')
RIGHT_SPACES = re.compile(r'>\s+')
SCRIPT_TAG = re.compile(r'<script[^>]*>.*?</script>')
COMMENT = re.compile(r'<!--[\s\S]*?-->')
@yubessy
yubessy / mywiki.py
Created Jun 29, 2014
MediaWIki APIを使って項目の別名を取得したりなど
View mywiki.py
#-*- encoding: utf-8 -*-
# thirdlib
import requests
BASE_URL = "http://en.wikipedia.org/w/api.php"
BLLIMIT = 250
def get_regular_name(q):
@yubessy
yubessy / mycompress.py
Last active Aug 29, 2015
Pythonのオブジェクト圧縮・展開
View mycompress.py
# -*- coding: utf-8 -*-
# stdlib
import cPickle as pickle
import zlib
PROTOCOL = pickle.HIGHEST_PROTOCOL
def save_to_str(obj):
@yubessy
yubessy / mydatex.py
Created Jun 29, 2014
Wikipediaの各年ページの日付をパース
View mydatex.py
# -*- coding: utf-8 -*-
# stdlib
import re
import datetime
# thirdlib
from dateutil.parser import parse
MONTHS = (
"January",
"February",