2015-05-07から1日間の記事一覧

2列目の和を連続して出力する

awk

find -name "*ss.csv" | xargs -Iv awk -F"," 'BEGIN{str=0}{str=str+$2}END{print FILENAME,str}' v > tmp2

rubyのワンライナーで日付に関して数値がないところを0で埋める.

ruby -r Date -ane 'BEGIN{h=Hash.new(0);s2=Date.parse("2015-04-08");s1=Date.parse("2006-11-01");};h[$F[1]]=$F[0]; END{(s2-s1).to_i.times.each{|j| v=(s1+j).to_s; print v+","+h[v].to_s+"\n";}}' tmp0 入力ファイル 268 2006-11-01 239 2006-11-02 …

ggplot2のqplotで簡単にきれなグラフ

R

事前にlibrary(ggplot2)はしておく x<-1:10 y<-2*x qplot(x,y,geom="line",xlab="date",ylab="count")+theme_bw(base_size=30) plot(x,y,type="b")は,geom=c("line","point") qplot(cc[4:length(cc)],exp(m1),xlab="Mean of start",ylab="Mean of 6 year ra…

mecabとrubyである単語の前後にある単語を取得

以下でなく連続ワード対応版を使う:: (1)node.feature.split(",")[6].encode("UTF-8","UTF-8") -> node.surfece featureだと未知語がでなくなる問題がある。 (2)複合語版を使うべき。 http://d.hatena.ne.jp/arupaka-_-arupaka/20150511/1431327544m…

mecabとrubyで形態素解析して文章を単語に分割してリストにつめる[基本]

mecabとrubyで形態素解析して文章を単語に分割してリストにつめる[基本] # -*- coding: Utf-8 -*- require 'MeCab' def get_feature_from_text(text1,mecab) list1=[] node=mecab.parseToNode(text1) while node.next != nil do node=node.next list1.push(n…