Created
November 21, 2013 16:29
-
-
Save t1anchen/7584966 to your computer and use it in GitHub Desktop.
jar package manually
This file contains hidden or 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
scalac GetLines.scala && COPY %SCALA_HOME%\lib\scala-library.jar . && jar cfm getlines.jar manifest.txt *.class *.jar && java -jar getlines.jar dict.txt |
This file contains hidden or 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
import scala.collection.mutable.BitSet | |
import scala.collection.mutable.Map | |
// Don't learn this code! | |
// Ugly implementation! | |
object GetLines { | |
def main(args: Array[String]) { | |
if (args.length < 1) { | |
println("Please specify the file to count") | |
return | |
} | |
// Prirequisite | |
val dict = Map[String, BitSet]() | |
// read lines | |
var lineCount = 0 | |
for (line <- io.Source.fromFile(args(0),"Unicode").getLines) { | |
// Parse line | |
val tokens = line.split("\t") | |
val code = tokens(0).toString | |
if (code != "CODE") { // Remove header | |
val floored_serial = tokens(1).toDouble.toInt | |
// Add/Update dict | |
if (dict.keySet.contains(code)) { | |
var bs = dict(code) | |
bs += floored_serial | |
} else { | |
var bs = BitSet(floored_serial) | |
dict.put(code, bs) | |
} | |
} | |
} | |
println(dict.values.foldLeft(0)(_ + _.size)) | |
} | |
} |
This file contains hidden or 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
Main-Class: GetLines | |
Class-Path: scala-library.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment