Mercurial > repos > icfp2013
comparison tools/parse.scala @ 2:5cf8de487ed6
Adding sizes analysis
author | Joshua Garnett <josh.garnett@gmail.com> |
---|---|
date | Thu, 08 Aug 2013 23:06:56 -0400 |
parents | cdfc5e2de435 |
children |
comparison
equal
deleted
inserted
replaced
1:cdfc5e2de435 | 2:5cf8de487ed6 |
---|---|
9 val json = JSONValue.parse(file).asInstanceOf[JSONArray] | 9 val json = JSONValue.parse(file).asInstanceOf[JSONArray] |
10 | 10 |
11 var totalProblems = json.size | 11 var totalProblems = json.size |
12 var totalSize = 0 | 12 var totalSize = 0 |
13 val operatorHash = HashMap[String, Int]() | 13 val operatorHash = HashMap[String, Int]() |
14 val allSizes = HashMap[Int, Int]() | |
14 | 15 |
15 for(p <- json) { | 16 for(p <- json) { |
16 val problem = p.asInstanceOf[JSONObject] | 17 val problem = p.asInstanceOf[JSONObject] |
17 totalSize += problem.get("size").asInstanceOf[java.lang.Integer] | 18 val size = problem.get("size").asInstanceOf[java.lang.Integer] |
19 totalSize += size | |
18 val operators = problem.get("operators").asInstanceOf[JSONArray] | 20 val operators = problem.get("operators").asInstanceOf[JSONArray] |
21 | |
22 allSizes(size) = allSizes.get(size) match { | |
23 case Some(count) => count + 1 | |
24 case None => 1 | |
25 } | |
26 | |
19 for(o <- operators) { | 27 for(o <- operators) { |
20 val operator = o.asInstanceOf[String] | 28 val operator = o.asInstanceOf[String] |
21 operatorHash(operator) = operatorHash.get(operator) match { | 29 operatorHash(operator) = operatorHash.get(operator) match { |
22 case Some(count) => count + 1 | 30 case Some(count) => count + 1 |
23 case None => 1 | 31 case None => 1 |
31 | 39 |
32 println("Operator Count: ") | 40 println("Operator Count: ") |
33 for((key, value) <- operatorHash) { | 41 for((key, value) <- operatorHash) { |
34 println(" " + key + ":" + value) | 42 println(" " + key + ":" + value) |
35 } | 43 } |
44 | |
45 println("Size Count: ") | |
46 for(key <- allSizes.keys.toList.sorted) { | |
47 println(" " + key + ":" + allSizes(key)) | |
48 } |