Demo entry 3938350

aa

   

Submitted by anonymous on Mar 08, 2016 at 10:50
Language: Scala. Code size: 997 Bytes.

import java.io.{PrintWriter, File}
import java.text.SimpleDateFormat
import java.util.Locale

import scala.io.Source

object Engine {

  def main(args: Array[String]) {
    //Read the file with all events indexed
    val eventIndex = Source.fromFile("EventIndex")
      .getLines()
      .map(_.split(","))
      .map(x => x(1) -> x(0).toInt)
      .toMap
    
    //Get and parse all events files then sort the events by timestamp
    val eventsFiles = getFiles(new File("L3P3/Totta_ES"))
    val events = eventsFiles
      .flatMap(x => parseEvents(x))
      .sortBy(_._1)
    val eventFiltered = events
      .groupBy(_._2)
      .filter(_._2.length>=10)
      .map(_._1).toList
      
    //For each time in the events, look 5 previous minutes and 5 next minutes 
    //and create the window with the events that occurs in those intervals
    val windows = events
      .flatMap(x=>List(x._1,x._1+299,x._1-300,x._1-1))
      .distinct
      .sorted
    .map(x=>

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).