Skip to content

Instantly share code, notes, and snippets.

View bluele's full-sized avatar
building

Jun Kimura bluele

building
View GitHub Profile
@bluele
bluele / hserve
Last active November 8, 2016 14:52
Startup script for simple http server.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
__author__ = 'bluele'
__version__ = '0.10'
__license__ = 'MIT'
__doc__ = """
# simple running
$ hserve
@bluele
bluele / suffixarray.py
Created February 25, 2013 04:53
Suffix Array
#-*- coding:utf-8 -*-
__author__ = 'bluele'
import unittest
class SuffixArray(object):
def __init__(self, string):
self.string = string
@bluele
bluele / path.py
Created January 26, 2013 20:10
Path module provide the utility accessors for File path.
#-*- coding:utf-8 -*-
__author__ = 'bluele'
from os.path import exists as op_exists, join as op_join, dirname as op_dirname, basename as op_basename,\
normpath as op_normpath, split as op_split, normcase as op_normcase, splitext as op_splittext
class Path(object):
def __init__(self, path, is_relative=False):
@bluele
bluele / inherit_unicode.py
Created January 26, 2013 19:46
sub-classing unicode
#-*- coding:utf-8 -*-
__author__ = 'bluele'
class SubUnicode(unicode):
def __new__(cls, val, meta={}):
self = unicode.__new__(cls, val)
self.__meta = meta
return self
@bluele
bluele / re_pattern.py
Created October 20, 2012 16:21
正規表現のパターン
#-*- coding:utf-8 -*-
__author__ = 'junk'
import unittest
import re
re_hiragana = re.compile(ur"^[ぁ-ゞ]$")
re_kana = re.compile(ur"^[ァ-ヾ]$")
re_kanji = re.compile(ur'^[一-龠]$')
re_number = re.compile(ur'^[-+]?(([1-9]\d+|\d)(?:\.\d+)?)$')
@bluele
bluele / generate_sentence.py
Created May 10, 2012 10:06
Generate japanese sentence.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
__doc__ = u"""
指定したコーパスから文章を生成します
ファイルを読み込んでsplit /[、。]/で分割
"""
__usage__ = u"""
USAGE: