<commit_before>package leo


import leo.agents.impl.ContextControlAgent
import leo.datastructures.blackboard.Blackboard
import leo.datastructures.blackboard.scheduler.Scheduler
import leo.datastructures.context.Context
import leo.modules.{Utility, SZSOutput, CLParameterParser}
import leo.modules.Utility._
import leo.modules.output.SZS_Timeout
import leo.modules.Phase._


/**
 * Entry Point for Leo-III as an executable to
 * proof a TPTP File
 *
 * @author <NAME>
 * @since 7/8/14
 */
object Main {

  /**
   *
   * Tries to proof a Given TPTP file in
   * a given Time.
   *
   * @param args - See [[Configuration]] for argument treatment
   */
  def main(args : Array[String]){
    try {
      Configuration.init(new CLParameterParser(args))
    } catch {
      case e:IllegalArgumentException => {
        Out.severe(e.getMessage)
        Configuration.help()
        return
      }
    }
    if (Configuration.HELP) {
      Configuration.help()
      return
    }

    val timeout = if (Configuration.TIMEOUT == 0) Double.PositiveInfinity else Configuration.TIMEOUT
    val interval = 10


    val deferredKill : DeferredKill = new DeferredKill(interval, timeout)
    deferredKill.start()

    ContextControlAgent.register()

    // Create Scheduler
    Scheduler(Configuration.THREADCOUNT)

    val it = getSplitFirst.iterator
    var r = true
    while(it.hasNext && r) {
      val phase = it.next()
      Out.info(s"\n [Phase]:\n  Starting ${phase.name}\n${phase.description}")
      r = phase.execute()
      Out.info(s"\n [Phase]:\n  Ended ${phase.name}")
    }
    deferredKill.kill()

    Out.output(s"%SZS Status ${Blackboard().getStatus(Context()).fold("Unkown")(_.output)} for ${Configuration.PROBLEMFILE}")
    if(Configuration.PROOF_OBJECT) Blackboard().getAll{p => p.clause.isEmpty}.foreach(Utility.printDerivation(_))
    //formulaContext()
  }



  /**
   * Thread to kill leo.
   *
   * TODO: Hook to let the kill Thread die.
   *
   * @param interval
   * @param timeout
   */
  private class DeferredKill(interval : Double, timeout : Double) extends Thread {

    var remain : Double = timeout
    var exit : Boolean = false

    def kill() : Unit = {
      synchronized{
        exit = true
        this.interrupt()
        Scheduler().killAll()
        Out.info("Scheduler killed before timeout.")
      }
    }

    override def run(): Unit = {
      //      println("Init delay kill.")
      synchronized{
        while(remain > 0 && !exit) {
          try {
            val w : Double = if (remain > interval) interval else remain
            wait((w * 1000).toInt)
          } catch {
            case e: InterruptedException => if(exit) return else Thread.interrupted()
            case _: Throwable => ()
          } finally {
            if(!exit) {
              Out.info("Leo is still alive.")
              agentStatus()
              remain -= interval
            }
          }
        }
        Out.output(SZSOutput(SZS_Timeout))
        Scheduler().killAll()
      }
    }
  }
}

<commit_msg>Switched to StdPhase since splitting is not doing anything atm<commit_after>package leo


import leo.agents.impl.ContextControlAgent
import leo.datastructures.blackboard.Blackboard
import leo.datastructures.blackboard.scheduler.Scheduler
import leo.datastructures.context.Context
import leo.modules.{Utility, SZSOutput, CLParameterParser}
import leo.modules.Utility._
import leo.modules.output.SZS_Timeout
import leo.modules.Phase._


/**
 * Entry Point for Leo-III as an executable to
 * proof a TPTP File
 *
 * @author <NAME>
 * @since 7/8/14
 */
object Main {

  /**
   *
   * Tries to proof a Given TPTP file in
   * a given Time.
   *
   * @param args - See [[Configuration]] for argument treatment
   */
  def main(args : Array[String]){
    try {
      Configuration.init(new CLParameterParser(args))
    } catch {
      case e:IllegalArgumentException => {
        Out.severe(e.getMessage)
        Configuration.help()
        return
      }
    }
    if (Configuration.HELP) {
      Configuration.help()
      return
    }

    val timeout = if (Configuration.TIMEOUT == 0) Double.PositiveInfinity else Configuration.TIMEOUT
    val interval = 10


    val deferredKill : DeferredKill = new DeferredKill(interval, timeout)
    deferredKill.start()

    ContextControlAgent.register()

    // Create Scheduler
    Scheduler(Configuration.THREADCOUNT)

    val it = getStdPhases.iterator
    var r = true
    while(it.hasNext && r) {
      val phase = it.next()
      Out.info(s"\n [Phase]:\n  Starting ${phase.name}\n${phase.description}")
      r = phase.execute()
      Out.info(s"\n [Phase]:\n  Ended ${phase.name}")
    }
    deferredKill.kill()

    Out.output(s"%SZS Status ${Blackboard().getStatus(Context()).fold("Unkown")(_.output)} for ${Configuration.PROBLEMFILE}")
    if(Configuration.PROOF_OBJECT) Blackboard().getAll{p => p.clause.isEmpty}.foreach(Utility.printDerivation(_))
    //formulaContext()
  }



  /**
   * Thread to kill leo.
   *
   * TODO: Hook to let the kill Thread die.
   *
   * @param interval
   * @param timeout
   */
  private class DeferredKill(interval : Double, timeout : Double) extends Thread {

    var remain : Double = timeout
    var exit : Boolean = false

    def kill() : Unit = {
      synchronized{
        exit = true
        this.interrupt()
        Scheduler().killAll()
        Out.info("Scheduler killed before timeout.")
      }
    }

    override def run(): Unit = {
      //      println("Init delay kill.")
      synchronized{
        while(remain > 0 && !exit) {
          try {
            val w : Double = if (remain > interval) interval else remain
            wait((w * 1000).toInt)
          } catch {
            case e: InterruptedException => if(exit) return else Thread.interrupted()
            case _: Throwable => ()
          } finally {
            if(!exit) {
              Out.info("Leo is still alive.")
              agentStatus()
              remain -= interval
            }
          }
        }
        Out.output(SZSOutput(SZS_Timeout))
        Scheduler().killAll()
      }
    }
  }
}


{'fraction_non_alphanumeric': 0.11776251226692837, 'fraction_numerical': 0.003925417075564278, 'mean_word_length': 2.3451859956236323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '494464', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1809, 'n_words': 435}