Skip to content

Instantly share code, notes, and snippets.

package main
import (
"container/heap"
"fmt"
)
type PriorityQueue []*Node
func (this PriorityQueue) Len() int { return len(this) }
package lu
import (
"fmt"
)
type Matrix [][]float64
func NewMatrix() Matrix {
return Matrix{}
@tma15
tma15 / dirdump.go
Last active January 16, 2016 04:33
package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"sort"
"syscall"
)
@tma15
tma15 / countelem.go
Last active August 29, 2015 14:08
Count overlapping elements between two sets
package main
import (
"fmt"
"sort"
)
func CountDuplicateElem(x, y []string) int {
// fmt.Println(x)
// fmt.Println(y)
#!/usr/bin/python
import re
import json
import numpy as np
import maf
import maflib.util
def configure(conf):
pass
@tma15
tma15 / mecab.go
Last active August 29, 2015 14:07
Simple Feature Vectorizer
package main
// #cgo LDFLAGS: -L/usr/local/Cellar/mecab/0.996/lib -lmecab -lstdc++ `mecab-config --libs`で得られる結果
// #cgo CFLAGS: -I/usr/local/Cellar/mecab/0.996/include `mecab-config --cflags`で得られる結果
// #include <mecab.h>
import "C"
// import "fmt"
import "strings"
@tma15
tma15 / file0.txt
Last active October 6, 2019 06:02
scikit-learnのParallelで並列処理 ref: https://qiita.com/tma15/items/7bace8cb391fff85db88
>>> from math import sqrt
>>> from sklearn.externals.joblib import Parallel, delayed
>>> Parallel(n_jobs=1)(delayed(sqrt)(i**2) for i in range(10))
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
@tma15
tma15 / beta.py
Created August 29, 2013 13:13
ベータ分布をPythonで書く ref: http://qiita.com/tma15/items/35643006cd0beb97c6a9
#!/usr/bin/python
#-*- coding:utf8 -*-
"""
DBDA FIGURE 5.1
"""
import math
import numpy as np
from pylab import *
def beta(theta, a, b):
@tma15
tma15 / file1.txt
Created February 8, 2012 10:56
NLTKを使って情報利得を計算 ref: http://qiita.com/items/2126
('worse',) 0.52573480121
('fine',) 0.5
('good',) 0.188721875541
('bad',) 0.188721875541
('excellent',) 0.0428913353502
('very',) 0.0
@tma15
tma15 / join_dakuten.py
Created February 8, 2012 08:09
文字と濁点・半濁点が分かれていて,それらを結合したい時 ref: http://qiita.com/items/2112
import unicodedata
unicodedata.normalize('NKFC', unistr)