February 25, 2012
716 notes
“
新聞比べ読みをしたらいいとトラックバックがあったんだけど*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に読ませてみた。
(スクリーンショット 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やメルコジへの言及は少ないなぁ。
”
新聞比べ読みをしたらいいとトラックバックがあったんだけど*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に読ませてみた。
(スクリーンショット 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 rip-rabbits)
-
kkuray3kn reblogged this from usaginobike
-
kayatokasasuscrapbook reblogged this from usaginobike
-
ynakajima reblogged this from tezcatlipoca453
-
ryuuya liked this
-
dragogazer reblogged this from firebum
-
prantaso-ginza liked this
-
yoruyoru reblogged this from usaginobike
-
tezcatlipoca453 liked this
-
tezcatlipoca453 reblogged this from usaginobike
-
long-tweet reblogged this from usaginobike and added:
何か既製の、単に情報収集目的で読んだり聴いたり観たりしているメディアに関しては、もうこれで充分なんじゃないか?と思った。 特に、恣意的な情報操作については(アルゴリズムがバレる迄は)上手くフィルタリングできそうだし、むしろベターかも。
-
usaginobike reblogged this from gtokio
-
yomeiri liked this
-
mocrlbmut liked this
-
bigfaces reblogged this from oharico
-
firebum reblogged this from oharico
-
dante35 liked this
-
oharico reblogged this from shinoddddd
-
tanakak06 reblogged this from horoniga
-
dog-master liked this
-
kabibouzu reblogged this from toyolina
-
shibuhei reblogged this from hepton-rk
-
7tsukix reblogged this from hepton-rk
-
furafuni liked this
-
tamoot reblogged this from hepton-rk
-
hepton-rk reblogged this from saikiyoshiyuki
-
saikiyoshiyuki reblogged this from gakkie
-
enjoylivingordie reblogged this from toyolina
-
ktsukago reblogged this from gakkie
-
gakkie reblogged this from glasslipids
-
dranktoomuch liked this
-
precall reblogged this from toyolina
-
glasslipids reblogged this from toyolina
-
eurekaaaaaaaa reblogged this from toyolina
-
toyolina reblogged this from mmtki
-
gmdrayt reblogged this from mmtki
-
mmtki reblogged this from otemoto-otumami
-
shin1-p reblogged this from oharico and added:
こういうのでシステム的に各紙読んでいけば、どういう世論にしていきたいのかとか色々捗るのかも。
-
henachoko reblogged this from reservoir
-
shis0k0n liked this
-
tosh728 liked this
-
tosh728 reblogged this from chiisanaehon
-
chiisanaehon reblogged this from reservoir
-
reservoir liked this
-
reservoir reblogged this from yunh
-
yunh reblogged this from gearmann
-
c610 reblogged this from hiro-saku-go
-
mujako reblogged this from nissingeppo
-
nissingeppo reblogged this from himatbshiz
-
human-from-hell liked this
-
trash-case reblogged this from himatbshiz
- Show more notes