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 MeCab | |
def tokenization(text, dic_path, lex = None): | |
# -Oyomi (ヨミ付与) -Ochasen (ChaSen互換) -Odump (全情報を出力) | |
unknown_option = "-U %M\\t未知語,*,*,*,*,*,*,*,*\\n" | |
mecab_options = " ".join(["-d", dic_path, unknown_option]) | |
tagger = MeCab.Tagger(mecab_options) | |
parse = tagger.parse(text).replace('\t',',') | |
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
<?php | |
public function createapp($email, $password){ | |
$url = "https://api.heroku.com/apps"; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password); | |
$headers = ['Accept: application/vnd.heroku+json; version=3',"Content-Type: application/json"]; |
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
from glob import glob | |
from os import path | |
def listup_file_name(data_path, extension=None, abspath=True): | |
extension = '.' + extension if extension else '' | |
if abspath: | |
return glob(data_path + '*' + extension) | |
else: | |
return glob(path.relpath(data_path + '*' + extension)) |
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
def step_function(x): | |
return np.where(x >= 0, 1, 0) | |
### It is equivalent to below code to give 1-D array to np.where. | |
### variables = np.where(condition, val1, val2) <=> variables = val1 if x >= 0 else val2 | |
def step_function(x:list): | |
return np.maximum(x, 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
a = list(range(10)) | |
print("before : ", a) | |
b = np.random.permutation(a) | |
print("after : ", b) | |
====>>>> | |
before : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
after : [9 7 4 0 8 3 2 6 5 1] |
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
a = np.zeros([2,2]) | |
a[(0, 1),(0, 1)] = 1 | |
print(a) | |
return | |
====>>>> array([1, 0], | |
[0, 1]) | |
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
def __str__(self) | |
# printやformat文の引数としてオブジェクトが指定された時に | |
# 呼び出され、非公式の文字列表現を返す。 | |
def __call__() | |
# classを直接呼び出す時に実行される。 | |
def __repr__() | |
# 正式なオブジェクトの内容を文字列で返し、 | |
# インタプリターが同値性をチェックする時に使われる。 |
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
環境変数の設定の仕方 | |
- ~/.config/fish/config.fishに書き込む |
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 | |
current_dir = os.path.dirname(os.path.abspath("__file__")) |
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
from datetime import datetime as dt | |
def get_timestamp(): | |
dt_obj = dt.now() | |
return dt_obj.strftime("%Y/%m/%d, %H:%M:%S") | |
OlderNewer