From Wikipedia, the free encyclopedia
#!/usr/bin/ruby
# The program is under GPL.
$KCODE = 'e'
require 'romkan.rb'
require 'uconv'
$:.push("/usr/local/lib/site_ruby/1.8")
require 'suikyo/suikyo.rb'
def strip_down(s)
s.gsub(/'/, '').gsub(/rou/, 'ro') \
.gsub(/jou/, 'jo') \
.gsub(/dou/, 'do') \
.sub(/tou/, 'to') \
.sub(/Shuu/, 'Shu') \
.sub(/Yousuke/, 'Yosuke') \
.sub(/Etou/, 'Eto') \
.sub(/Yuu/, 'Yu')
end
def to_romaji_name(romaji)
romaji = romaji[2, romaji.length - 4]
suikyo = Suikyo.new
suikyo.table.loadfile("katakana-hiragana")
(last, first) = romaji.split(/(?:#{"\xa1\xa1"}|\s)+/, 2)
last = suikyo.convert(last) # kata -> hira
first = suikyo.convert(first) # kata -> hira
last = last.to_roma.capitalize
first = first.to_roma.capitalize
last = strip_down(last)
first = strip_down(first)
return [first, last]
end
cite = $*[0]
t = `curl -s #{cite}`
t = Uconv.u8toeuc(Uconv.sjistou8(t))
t = t.split(/\<td width=\"650\" align=\"left\" class=\"largefont\"\>[^<>]*\<br \/\>[\n\r\s]*/, 2)[1]
(kanji, t) = t.split(/[\r\n]+/, 2)
kanji.gsub!(/#{"\xa1\xa1"}+/, ' ')
(romaji, t) = t.split(/[\r\n]+/, 2)
romaji.strip!
(first, last) = to_romaji_name(romaji)
t = t.split(/#{'<span class="normalfont"><br />'}\s*#{'<br />'}/, 2)[1]
(from, t) = t.split(/#{Uconv.u8toeuc('【生年')}/, 2)
from.sub!(/.+[\r\n]+/, '')
from.gsub!(/[\r\n]/, '')
from.gsub!(/\s+/, ' ')
from.gsub!(/#{"\xa1\xa1"}+/, ' ')
from.strip!
(l, t) = t.split(/\<br \/\>/, 2)
l.sub!(/^[^0-9]*/, '')
(birth_year, birth_month, birth_day) = l.strip.split(/[^0-9]+/)
birth_month = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"][birth_month.to_i - 1]
(l, t) = t.split(/\<br \/\>/, 2)
l.strip!
party = l[l.length - 4, 4]
party = Uconv.euctou8(party)
if party == '自民' then
party = 'the [[Liberal Democratic Party (Japan)|]]'
elsif party == '民主' then
party = 'the [[Democratic Party of Japan]]'
elsif party == '公明' then
party = 'the [[New Komeito Party]]'
elsif party == '無所属' or party == '所属' then
party = 'independent'
end
t.index(/\"([^\"]+)\"/)
link = $1
kanji = Uconv.euctou8(kanji)
from = Uconv.euctou8(from)
if birth_day == nil then
birth = birth_year
else
birth_month.sub!(/^0/, '')
birth_day.sub!(/^0/, '')
birth = "#{birth_month} #{birth_day}, #{birth_year}"
end
now = Time.now
accessdate = "#{now.year}-#{sprintf("%02d", now.month)}-#{sprintf("%02d", now.day)}"
if party == 'independent' then
member = ', an independent and member'
else
member = " of #{party}, a member"
end
puts <<END
{{nihongo|'''#{first} #{last}'''|#{kanji}|extra=born #{birth}}} is a [[Japan]]ese [[politician]]#{member} of the [[House of Councillors]] in the [[Diet of Japan|Diet]] (national legislature). A native of [[#{from}]] and graduate of [[ University]], he was elected to the House of Councillors for the first time in 19.
== References ==
* {{cite web |url=#{cite} |title=政治家情報 〜#{kanji}〜 |work=[http://www.senkyo.janjan.jp/ ザ・選挙] |publisher=''[[JANJAN]]'' |accessdate=#{accessdate} |language=Japanese}}
== External links ==
* [#{link} Official website] in Japanese.
{{Japan-politician-stub}}
{{DEFAULTSORT:#{last}, #{first}}}
[[Category:Japanese politicians]]
[[Category:Living people]]
[[Category:#{birth_year} births]]
[[ja:#{kanji.gsub(/ /, '')}]]
END