Created
December 6, 2012 16:31
-
-
Save shizone/4225814 to your computer and use it in GitHub Desktop.
今まで変態AdventCalendarに記事をPostした数を集計して変態ランキングを作る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env xsbtscript | |
!# | |
/*** | |
scalaVersion := "2.9.2" | |
*/ | |
import scala.xml.XML | |
import scala.io.Source | |
val encode = "utf8" | |
def fromRSS(url: String) = { | |
XML.loadString(Source.fromURL(url, encode).getLines.mkString) \\ "author" map (_.text) | |
} | |
def fromDescription(url: String) ={ | |
val descriptions = XML.loadString(Source.fromURL(url, encode).getLines.mkString) \\ "description" map (_.text) | |
for (i <- 1 to 25) yield ("12/" + i + "\\|.+?\\|").r.findFirstIn(descriptions(0)).get.split("\\|")(1) | |
} | |
val hac2011w = fromRSS("http://atnd.org/comments/22020.rss") | |
val hac2012s = fromRSS("http://atnd.org/comments/29918.rss") | |
val hac2012w = fromDescription("http://api.atnd.org/events/?event_id=33835") | |
val hac = hac2011w ++ hac2012s ++ hac2012w | |
val cnt = (Map.empty[String, Int] /: hac) { (r, e) => | |
r + (e -> (r.getOrElse(e, 0) + 1)) | |
} | |
for (t <- cnt.toSeq.sortWith(_._2 > _._2)) println(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
12/7現在
ArrayBuffer((もじゃ変,7), (backpaper0,6), (KASUYA, Daisuke,5), (Kuchitama,5), (dproject21,4), (s_kozake,4), (issps2009,3), (真っ赤なレモン,3), (soudai1025,3), (susumuishigami,2), (winplus,2), (dekokun,2), (megascus,2), (toshi__ya,2), (hakurai,2), (tanago238,2), (bufferings,2), (daiksy,1), (N.Murakami,1), (KTZ ,1), (posaunehm,1), (zephiransas,1), (jyukutyo,1), (はがねのつるぎ,1), (tango238,1), (nyaarto,1), (sudai1025,1), (kuchitama,1), (miya2000,1), (satohjohn,1), (?,1), (mike_neck,1), (組 長,1), (s_taichan,1), (ponkore,1), (zerosum_,1), (ryosms,1), (kshoji,1), (dpoject21,1), (inaton,1))