Skip to content

Instantly share code, notes, and snippets.

@EnverOsmanov
Created January 22, 2016 07:09
Show Gist options
  • Save EnverOsmanov/77b515cc70a78e286580 to your computer and use it in GitHub Desktop.
Save EnverOsmanov/77b515cc70a78e286580 to your computer and use it in GitHub Desktop.
import java.io.BufferedWriter
import java.nio.file.{Files, Paths}
import scala.collection.JavaConversions._
import scala.io.Source
/**
* Created by 4 on 21.01.2016.
*/
object TweetTweet {
def main (args: Array[String]) {
val badFile: BufferedWriter = Files.newBufferedWriter(Paths.get(s"C:/Users/4/Downloads/Compressed/bad_${System.currentTimeMillis}"))
val zeroFile = Files.newBufferedWriter(Paths.get(s"C:/Users/4/Downloads/Compressed/zero_${System.currentTimeMillis}"))
val posFile = Files.newBufferedWriter(Paths.get(s"C:/Users/4/Downloads/Compressed/pos_${System.currentTimeMillis}"))
def dialog(line: String): Unit = try {
scala.io.StdIn.readLine() match {
case "q" =>
posFile.write(line)
posFile.newLine()
case "a" =>
zeroFile.write(line)
zeroFile.newLine()
case "z" =>
badFile.write(line)
badFile.newLine()
case "no" => println("Did nothing")
case "save" =>
List(badFile, zeroFile, posFile).foreach(_.flush())
dialog(line)
}
}
catch {case e: MatchError => dialog(line)}
var i = 0
Files.newDirectoryStream(Paths.get("C:\\Users\\4/Downloads\\Compressed\\documents-export-2016-01-21")).foreach { path =>
Source.fromFile(path.toFile).getLines().foreach { line =>
line.split(",") match {
case Array(_, _, _, tweet) if tweet.trim.startsWith("RT") =>
case Array(_, _, _, tweet) =>
i += 1
println(s"$i: $tweet")
dialog(line)
case other => println(s"OTHER: => $other")
}
}
}
//Source.fromFile()
badFile.close()
zeroFile.close()
posFile.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment