Skip to content

Instantly share code, notes, and snippets.

@shunsukeaihara
shunsukeaihara / blog.ipynb
Last active August 29, 2015 14:03
IPython Notebookをアドホック分析環境として使う
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shunsukeaihara
shunsukeaihara / salient region detection.ipynb
Last active August 29, 2015 14:23
salient region detection from superpixles
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shunsukeaihara
shunsukeaihara / gist:eec6bb9e6f721dbd9c61
Last active August 29, 2015 14:25
Global contrast based salient region detectionをベースにいろいろいじったり
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# (WIP)画像から主題っぽい領域を判定"
]
},
{
@shunsukeaihara
shunsukeaihara / estimate_alpha.pyx
Last active August 29, 2015 14:27
cython translation of the estimating alpha parameter for mel-cepstrum in go (https://bitbucket.org/happyalu/mcep_alpha_calc)
# -*- coding: utf-8 -*-
# distutils: language = c++
import numpy as np
cimport numpy as np
cimport cython
from libc.stdlib cimport malloc, free
from libc.math cimport log, M_PI, sin, cos, atan
from libc.float cimport DBL_MAX
@shunsukeaihara
shunsukeaihara / cabo_wrapper.rb
Created January 23, 2013 08:30
ruby wrapper for japanese dependency parser cabocha 0.5
#!/usr/bin/ruby -Kw
$KCODE="UTF-8"
require "CaboCha"
require "kconv"
class DepAnalyzeByCabocha
@cabo
def initialize(args=[])
@cabo = CaboCha::Parser.new(args)
end
@shunsukeaihara
shunsukeaihara / gmixture.py
Created January 23, 2013 08:44
Mixture model for graph
# -*- coding: utf-8 -*-
import math
import numpy as NP
from scipy.maxentropy import logsumexp
from operator import itemgetter
class NewmanEM:
def __init__(sel):
pass
@shunsukeaihara
shunsukeaihara / npgraph.py
Last active December 16, 2015 01:19
あとでCとopmempで書きなおす
# -*- coding: utf-8 -*-
import numpy as np
from scipy.special.basic import digamma
import logging
class NpGraph():
def __init__(self,T=10,C=(1.0,1.0),phi=0.001,thresh=0.001,niter = 500):
self._T = T#最大クラスタ数
self._c1 = C[0]
self._c2 = C[1]
self._phi0=phi
@shunsukeaihara
shunsukeaihara / cabocha_warpper.py
Created May 22, 2013 08:32
cabochaのラッパーのベース
# -*- coding: utf-8 -*-
import CaboCha
import chardet
import syslog
import math
from collections import defaultdict
import unicodedata
syslog.openlog('cabocha_wrapper',syslog.LOG_PID|syslog.LOG_PERROR,syslog.LOG_SYSLOG)
AVG_LENGTH = 200.0
@shunsukeaihara
shunsukeaihara / npgraph.pyx
Last active December 17, 2015 18:29
npgraphのcython版 概ねpython版と出力は一致。計算を一部効率化 次の目標は入力のグラフを疎行列化 numpyのpythonオブジェクト使っているとgilのせいでopenmp使えないっぽい。.dataを使って生配列に変更する必要あり。
# -*- coding: utf-8 -*-
import numpy as np
cimport numpy as np
from libc.math cimport log
from scipy.misc import logsumexp
cdef double digamma(double x):
cdef double result = 0.0
cdef double xx, xx2, xx4
assert x>=0, "digamma error"
@shunsukeaihara
shunsukeaihara / crawl.py
Last active April 22, 2016 10:42
rongorongoのThomas Barthel's Transliteration Systemのデータをクローリングしてファイルに保存したり、文字の正規化や分解を行うスクリプト。詳細は以下 http://argmax.jp/index.php?ron
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
import re
URL = "http://kohaumotu.org/rongorongo_org/translit/%s.html"
for i in range(97,123):
url = URL % chr(i)
html = urllib2.urlopen(url).read()