Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import tempfile | |
import tcptest | |
from elasticsearch import Elasticsearch | |
SYNONYMS_PATH = "/tmp/wikipedia_synonym.txt" | |
settings = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -e `/usr/local/bin/mecab-config --dicdir`/unidic ]; then | |
if [ "`yum list installed| grep unzip.x86_64`" = "" ]; then | |
yum install -y unzip | |
fi | |
wget "http://jaist.dl.osdn.jp/unidic/58338/unidic-mecab-2.1.2_src.zip" -O /tmp/unidic-mecab-2.1.2_src.zip | |
unzip /tmp/unidic-mecab-2.1.2_src.zip -d /tmp | |
cd /tmp/unidic-mecab-2.1.2_src | |
./configure | |
make | |
make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget --no-cookies --no-check-certificate \ | |
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie"\ | |
"http://download.oracle.com/otn-pub/java/jdk/8u65-b14/jdk-8u65-linux-x64.rpm" -O /tmp/jdk-8u65-linux-x64.rpm | |
rpm -ivh /tmp/jdk-8u65-linux-x64.rpm |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pushd . | |
# Install blas | |
cd /tmp | |
wget http://www.netlib.org/blas/blas.tgz | |
tar xzf blas.tgz | |
cd BLAS* | |
gfortran -O3 -m64 -fPIC -c *.f | |
ar r libfblas.a *.o | |
ranlib libfblas.a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.sparse import csr_matrix | |
def dict2sparse(d): | |
data = list(d.values()) | |
indices = list(d.keys()) | |
indptr = [0, len(d)] | |
return csr_matrix((data, indices, indptr), shape=(1, max(d)+1), dtype=np.uint32) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CHINESE_MAP = {'1': '一', '2': '二', '3': '三', '4': '四', '5': '五', '6': '六', '7': '七', '8': '八', '9': '九'} | |
CHINESE_DIGITS = ('十', '百', '千', '万', '十万', '百万', '千万', '億', '十億', '百億', '千億', '兆', '十兆', '百兆', '千兆') | |
def arabic2chinese(arabic): | |
chinese = [] | |
if len(arabic) == '0': | |
return '〇' | |
arabic = arabic.replace(',', '') | |
for (i, num) in enumerate(arabic[::-1]): | |
if num == '0': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def eliminate_zero_raws(x): | |
return x[np.unique(x.nonzero()[0])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
from collections import deque | |
class TopK(): | |
def __init__(self, k=5): | |
self.k = k | |
self._initialize() |