port from http://getassoc.cs.nii.ac.jp/　Autor: Copyright (c) 2001, 2003-2009 Shingo Nishioka.　Revised BSD License