<commit_before>package appletui
import java.awt._, java.awt.event._, javax.swing._
import scala.collection.immutable.List


class MainGameState(game: GameContainer) extends GameState(game) {
  setLayout(new BorderLayout)

  val responseLbl = new GameLabel("")
  val inputPanel = new GamePanel(new BorderLayout)
  val promptLbl = new GameLabel("> ")
  promptLbl.setForeground(Color.GREEN)
  val inputBox = new GameField()
  inputBox.setText("--")
  inputBox.requestFocus()
  for (x <- List(responseLbl, inputPanel)) {
    x.setBorder(BorderFactory.createEmptyBorder(50,50,50,50))
  }
  add(responseLbl, BorderLayout.CENTER)
  inputPanel.add(promptLbl, BorderLayout.WEST)
  inputPanel.add(inputBox, BorderLayout.CENTER)
  add(inputPanel, BorderLayout.SOUTH)

  inputBox.setAction(new AbstractAction {
    override def actionPerformed(e: ActionEvent) {
      submit(inputBox.getText())
    }
  })

  import dreamer.concept._, dreamer.context._, dreamer.conceptnet._
  import dreamer.conversation._, dreamer.lang.html_en._
  import GameUtil._

  var context = Context(MentalMap(upstream=Some(new ConceptNet)))
  val conversation = Conversation(new HTMLEnglish)

  var firstSubmit = true
  def submit(text: String) {
    inputBox.setEditable(false)
    inputBox.setForeground(Color.GRAY)
    responseLbl.colored(Color.CYAN, "Thinking...")

    spawn("Thinking") {
      val (newCtx, response) = conversation.query(text)(context)
      context = newCtx
      
      swingThread {
        inputBox.setForeground(Color.WHITE)
        inputBox.setEditable(true)
        inputBox.requestFocus()
        updateDisplay(
          response=Some(response),
          awake=Some(Context.isAwake(context)))

        if (firstSubmit) {
          inputBox.setText("help")
          firstSubmit = false
        } else {
          inputBox.setText("")
        }
      }
    }
  }

  def updateDisplay(
      response: Option[String]=None,
      awake: Option[Boolean]=None) {

    response.map{x =>
      responseLbl.html(x)
    }
  }

  // start the game:
  submit("go to sleep")
}
<commit_msg>Put response text at the bottom of the output panel.<commit_after>package appletui
import java.awt._, java.awt.event._, javax.swing._
import scala.collection.immutable.List


class MainGameState(game: GameContainer) extends GameState(game) {
  setLayout(new BorderLayout)

  val responseLbl = new GameLabel("")
  val inputPanel = new GamePanel(new BorderLayout)
  val outputPanel = new GamePanel(new BorderLayout)
  val promptLbl = new GameLabel("> ")
  promptLbl.setForeground(Color.GREEN)
  val inputBox = new GameField()
  inputBox.setText("--")
  inputBox.requestFocus()
  for (x <- List(responseLbl, inputPanel)) {
    x.setBorder(BorderFactory.createEmptyBorder(50,50,50,50))
  }
  outputPanel.add(responseLbl, BorderLayout.SOUTH)
  inputPanel.add(promptLbl, BorderLayout.WEST)
  inputPanel.add(inputBox, BorderLayout.CENTER)
  add(inputPanel, BorderLayout.SOUTH)
  add(outputPanel, BorderLayout.CENTER)

  inputBox.setAction(new AbstractAction {
    override def actionPerformed(e: ActionEvent) {
      submit(inputBox.getText())
    }
  })

  import dreamer.concept._, dreamer.context._, dreamer.conceptnet._
  import dreamer.conversation._, dreamer.lang.html_en._
  import GameUtil._

  var context = Context(MentalMap(upstream=Some(new ConceptNet)))
  val conversation = Conversation(new HTMLEnglish)

  var firstSubmit = true
  def submit(text: String) {
    inputBox.setEditable(false)
    inputBox.setForeground(Color.GRAY)
    responseLbl.colored(Color.CYAN, "Thinking...")

    spawn("Thinking") {
      val (newCtx, response) = conversation.query(text)(context)
      context = newCtx
      
      swingThread {
        inputBox.setForeground(Color.WHITE)
        inputBox.setEditable(true)
        inputBox.requestFocus()
        updateDisplay(
          response=Some(response),
          awake=Some(Context.isAwake(context)))

        if (firstSubmit) {
          inputBox.setText("help")
          firstSubmit = false
        } else {
          inputBox.setText("")
        }
      }
    }
  }

  def updateDisplay(
      response: Option[String]=None,
      awake: Option[Boolean]=None) {

    response.map{x =>
      responseLbl.html(x)
    }
  }

  // start the game:
  submit("go to sleep")
}

{'fraction_non_alphanumeric': 0.11393289841565704, 'fraction_numerical': 0.003727865796831314, 'mean_word_length': 3.3583756345177664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6618630', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1352, 'n_words': 250}