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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| from collections import defaultdict | |
| def train_unigram(file_name): | |
| my_dict = defaultdict(int) |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| import math | |
| import nist_nlp01_1 | |
| def test_entropy(document, unigram): |
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
| #!/usr/bin/env bash | |
| set -eu | |
| if [ $# -lt 2 ] || [ $# -gt 2 ]; then | |
| echo "Usage: $0 /PATH/TO/INPUT_DIR /PATH/TO/OUTPUT_DIR" | |
| exit 1 | |
| fi | |
| if [ ! -d "$1" ]; then | |
| echo "No such directory $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
| # python でランダムな数列リストを出力するワンライナー | |
| python -c 'num=5;import random;print(random.sample(range(1,num+1),num))' |
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
| // Google Calendar Line Bot | |
| // Main | |
| // Post処理するやつ | |
| function doPost(e) { | |
| var json = JSON.parse(e.postData.contents); | |
| var message = json.events[0].message.text; | |
| if (message != null) { |
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
| # -*- coding: utf-8 -*- | |
| from email.mime.text import MIMEText | |
| from email.utils import formatdate | |
| import smtplib | |
| addr = "" | |
| pswd = "" | |
| subj = "" | |
| body = "" |
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 multiprocessing | |
| import time | |
| def f(x): | |
| for i in range(10**6): | |
| x += i/x | |
| return x | |
| def main(n): | |
| with multiprocessing.Pool(n) as p: |
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 random import choices, random | |
| class TicTacToe: | |
| def __init__(self, mark1='O', mark2='X'): | |
| self._state = [None]*9 | |
| self._actions = list(range(0,9)) | |
| # completion statuses | |
| self._comps = [[0,1,2], [0,4,8], [0,3,6], [1,4,7], |
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
| class FieldPos(object): | |
| def __init__(self, y, x): | |
| self.y = y | |
| self.x = x | |
| class FieldObj(object): | |
| def __init__(self, mark_i, mark_c): | |
| self.mark_i = mark_i | |
| self.mark_c = mark_c |
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 | |
| import timeit | |
| def f(x, y): | |
| return (x+1)*y | |
| def ff(X, y): | |
| res = [] | |
| for x in X: | |
| res.append(f(x,y)) |