Skip to content

Instantly share code, notes, and snippets.

View chezou's full-sized avatar

Aki Ariga chezou

View GitHub Profile
@chezou
chezou / example2.rb
Created January 30, 2014 15:03
classとメソッドの設計は適当ですが、こんなイメージです。
count = 0
if target_user_ids.empty?
count += Foo.all.count
else
target_user_ids.each do |user_ids|
count += Foo.where(user_id: user_ids).count
end
end
@chezou
chezou / kytea.0.4.6.diff
Last active August 29, 2015 14:03
patch for kytea 0.4.6
diff --git a/src/lib/kytea.cpp b/src/lib/kytea.cpp
index 8dbae30..04324c3 100644
--- a/src/lib/kytea.cpp
+++ b/src/lib/kytea.cpp
@@ -74,6 +74,11 @@ void Kytea::addTag(typename Dictionary<Entry>::WordMap& allWords, const KyteaStr
Entry::setInDict(it->second->inDict,dict);
}
}
+
+
@chezou
chezou / dict.jl
Last active August 29, 2015 14:10
Julia Dict() execution time
dict = Dict()
@time for i in [1:10000000]
dict[i] = 1
end
# elapsed time: 22.824151615 seconds (2413509808 bytes allocated, 9.20% gc time)
dict = Dict()
@time for i in [1:10000]
dict[i] = 1
end
@chezou
chezou / WordCount.jl
Created December 4, 2014 15:05
Word count benchmark using MeCab
# Julia using -O wakati
using Benchmark
using MeCab
function count_word(text::UTF8String)
mecab = Mecab("-O wakati")
counts = Dict{UTF8String, Int}()
for word in split(sparse_tostr(mecab, text))
counts[word] = get(counts, word, 0) + 1
end
julia> Pkg.update()
INFO: Updating METADATA...
...snip...
INFO: Building Homebrew
remote: Counting objects: 818, done.
remote: Compressing objects: 100% (232/232), done.
remote: Total 818 (delta 644), reused 759 (delta 585)
Receiving objects: 100% (818/818), 92.06 KiB | 0 bytes/s, done.
Resolving deltas: 100% (644/644), completed with 144 local objects.
From https://github.com/Homebrew/homebrew
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chezou
chezou / mikon-plot-ttest.ipynb
Last active August 29, 2015 14:13
mikon example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chezou
chezou / re2test.cpp
Created November 25, 2011 12:39
Sample of re2 libirary in Japanese
#compile g++ -Wall re2test.cpp -o re2.out -lre2 -lpthread
#include <iostream>
#include <string>
#include <re2/re2.h>
#include <cassert>
using namespace std;
int main(int argc, char **argv){
@chezou
chezou / re2test2.cpp
Created November 25, 2011 15:42
Sample cord of re2 of PartialMatchN
#include <iostream>
#include <string>
#include <re2/re2.h>
#include <vector>
using namespace std;
int main(){
string str("あぶらかたぶら");