"

新聞比べ読みをしたらいいとトラックバックがあったんだけど*1

僕も日経の何がいいかよくわからん。エライ人が日経嫁とかウルサイんですね。僕も言われたことあります。

あんなもの自分で読むとストレスたまるので、とりあえずプログラムに読ませてみた。

日経の社説を取得するプログラム

#!/usr/bin/env ruby
#日経新聞の社説。
require 'rubygems'
require 'mechanize'

m = Mechanize.new
m.get "http://s.nikkei.com/yuWJm2"
#m.page.search('/html/body//h2[contains(., "社説")]').first.parent
list = m.page.search('//h4/a').map{|e| [e.text,"http://s.nikkei.com/nKGjqr"+e["href"]] }
list.each{|e| 
    m.get e[1]
    title = m.page.search('h4.cmn-article_title.cmn-clearfix').text.strip
    date  = m.page.search('h4.cmn-article_title.cmn-clearfix').text.strip
    body  = m.page.search('div.cmn-article_text.JSID_key_fonttxt').text.gsub(/\t/, "")
    open("#{title}-#{date}.txt","w"){|f| f.write body}
}

Rubyに読ませてみた。

f:id:takuya_1st:20120221031851j:image(スクリーンショット 2012-02-21 3.18.12)

Rubyに代わりに読んでもらおう。

$KCODE ='u'
system("cat *.txt > all.nikkei")
text = open("all.nikkei").read
regex = /[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+/
words = text.scan regex
counts = Hash.new(0)
words.each{|e| counts[e]  =  counts[e] + 1 }
sorted = counts.to_a.sort{|a,b| b[1] <=> a[1]}
sorted.each{|e| puts "#{e[0]}=>#{e[1]}"}
puts "-"*10
puts words.size

結果

「てにをは」などがこれだけ

の=>426 を=>305 が=>187 に=>180 は=>158 で=>86  と=>57  も=>56  や=>53  な=>51  だ=>39  い=>37 し=>35  する=>33 した=>31 り=>26 る=>25 
キーワードはこんな感じ。
ガス=>25 年=>23 政府=>22 日本=>22 
天然=>16 高=>15 人=>15 東電=>15 強=>13 考=>12 続=>12 得=>11 問題=>11 受=>11
中国=>11
対応=>10
研究=>10
エネルギー=>10
合=>10
必要=>10
上=>9
課題=>9
企業=>9
日銀=>9
電力=>8
送電網=>8
テロ=>8
温度計=>7


結果

今週の日経さんは「電力と日本と、政府と、中国」にご執心で、「高い〜」や「強い〜」が好きなようですね。そしてやたら天然ガスにご執心です。


これだけでもう何書いてあるか想像が付くわ。。。

tf/idf的には逆も見たいところ。

一回だけ出てくる、特徴語を見たらなんと「国会」が一回だけ。まぁ◯◯党や◯◯大臣というもっと具体例で言及してるんかねぇ。でもそれ政府なんだよねぇ。やっぱ国会は国会の機能は果たしてないってことか。

TPP、FRBやメルコジへの言及は少ないなぁ。

"
— 日経の社説を一気に取得する。自分で読むのはバカバカしいからRubyに日経を読ませる。 http://bit.ly/wmiE2U (via redtower)

(via biikame)

699 02.25.12
dropshadow
  1. tanakak06 reblogged this from horoniga
  2. kabibouzu reblogged this from toyolina
  3. shibuhei reblogged this from hepton-rk
  4. 7tsukix reblogged this from hepton-rk
  5. tamoot reblogged this from hepton-rk
  6. hepton-rk reblogged this from saikiyoshiyuki
  7. saikiyoshiyuki reblogged this from gakkie
  8. enjoylivingordie reblogged this from toyolina
  9. ktsukago reblogged this from gakkie
  10. gakkie reblogged this from glasslipids
  11. precall reblogged this from toyolina
  12. glasslipids reblogged this from toyolina
  13. eurekaaaaaaaa reblogged this from toyolina
  14. toyolina reblogged this from mmtki
  15. gmdrayt reblogged this from mmtki
  16. mmtki reblogged this from otemoto-otumami
  17. shin1-p reblogged this from oharico and added:
    こういうのでシステム的に各紙読んでいけば、どういう世論にしていきたいのかとか色々捗るのかも。
  18. oharico reblogged this from shinoddddd
  19. henachoko reblogged this from reservoir
  20. tosh728 reblogged this from chiisanaehon
  21. chiisanaehon reblogged this from reservoir
  22. reservoir reblogged this from yunh
  23. yunh reblogged this from gearmann
  24. c610 reblogged this from hiro-saku-go
  25. mujako reblogged this from nissingeppo
  26. nissingeppo reblogged this from himatbshiz
  27. trash-case reblogged this from himatbshiz
  28. powchin reblogged this from mnak
  29. yoshinam reblogged this from staro-h
  30. orochix reblogged this from znuffery2k
  31. znuffery2k reblogged this from hisame
  32. hiro-saku-go reblogged this from peckori
  33. flyingtadpole reblogged this from hrowl
  34. sudachi1410 reblogged this from himatbshiz
  35. mm1941 reblogged this from matsunom
  36. cq5yknok reblogged this from rokisin
  37. megumu226 reblogged this from staro-h
  38. moufurafura reblogged this from himatbshiz
  39. hisame reblogged this from dekoi2501post
  40. himatbshiz reblogged this from yukio
  41. sikimi reblogged this from hrowl