Propacil's note

Feb 26 2012

新聞比べ読みをしたらいいとトラックバックがあったんだけど*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やメルコジへの言及は少ないなぁ。

*1http://bit.ly/w5SNap

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

)

(via shimamura-kun)

716 notes

  1. kkuray3kn reblogged this from usaginobike
  2. kayatokasasuscrapbook reblogged this from usaginobike
  3. ynakajima reblogged this from tezcatlipoca453
  4. dragogazer reblogged this from firebum
  5. yoruyoru reblogged this from usaginobike
  6. tezcatlipoca453 reblogged this from usaginobike
  7. long-tweet reblogged this from usaginobike and added:
    何か既製の、単に情報収集目的で読んだり聴いたり観たりしているメディアに関しては、もうこれで充分なんじゃないか?と思った。 特に、恣意的な情報操作については(アルゴリズムがバレる迄は)上手くフィルタリングできそうだし、むしろベターかも。
  8. usaginobike reblogged this from gtokio
  9. bigfaces reblogged this from oharico
  10. firebum reblogged this from oharico
  11. oharico reblogged this from shinoddddd
  12. tanakak06 reblogged this from horoniga
  13. kabibouzu reblogged this from toyolina
  14. shibuhei reblogged this from hepton-rk
  15. 7tsukix reblogged this from hepton-rk
  16. tamoot reblogged this from hepton-rk
  17. hepton-rk reblogged this from saikiyoshiyuki
  18. saikiyoshiyuki reblogged this from gakkie
  19. enjoylivingordie reblogged this from toyolina
  20. ktsukago reblogged this from gakkie
  21. gakkie reblogged this from glasslipids
  22. precall reblogged this from toyolina
  23. glasslipids reblogged this from toyolina
  24. eurekaaaaaaaa reblogged this from toyolina
  25. toyolina reblogged this from mmtki
  26. gmdrayt reblogged this from mmtki
  27. mmtki reblogged this from otemoto-otumami
  28. shin1-p reblogged this from oharico and added:
    こういうのでシステム的に各紙読んでいけば、どういう世論にしていきたいのかとか色々捗るのかも。
  29. henachoko reblogged this from reservoir
  30. tosh728 reblogged this from chiisanaehon
  31. chiisanaehon reblogged this from reservoir
  32. reservoir reblogged this from yunh
  33. yunh reblogged this from gearmann
  34. c610 reblogged this from hiro-saku-go
  35. mujako reblogged this from nissingeppo
  36. nissingeppo reblogged this from himatbshiz
  37. trash-case reblogged this from himatbshiz
Page 1 of 1