<commit_before>// chortle.js
// a quest for chortle

// ADDME: common verbs
var dictionary = {
  "yes": "UH",
  "no": "DT",

  "i": "PRP",
  "you": "PRP",
  "he": "PRP",
  "she": "PRP",
  "it": "PRP",
  "we": "PRP",
  "they": "PRP",
  "me": "PRP",
  "him": "PRP",
  "her": "PRP",
  "us": "PRP",
  "them": "PRP",
  "my": "PRP",
  "your": "PRP",
 
  "because": "IN",
  
  "eat": "VBP",
  "eats": "VBZ",
  "is": "VBZ",

  "salt": "NN",
}

var questions = [
  "what is your name?",
  "what is your favorite food?",
]

var learned = {}
var userResponses = new Array();

function init() {
  var commands = new Array();
  commands.push("PRP VBP|VBZ NN|UNKNOWN ... i eat cake");
  for (i = 0; i < commands.length; i++) {
    document.getElementById('command-list').innerHTML +=
      "<li>" + commands[i] + "</li>";
  }
  
  // first bot question
  var question = "hello, " + questions[0];
  output(question);
  logger(question);
}

function ask(question) {
  output(question);
  return question;
}

function botResponseLogic(input) {
  var botResponse = "";
  // check POS pattern input
  
  /*
      my  name        is  al
      PRP NN|UNKNOWN  VBZ NN|UNKNOWN
  */
  
  // TODO: find a way to use regexps to check inside pattern for matches (and, perhaps, crunch found pattern matches together)
  
  if (input.match(/PRP,NN|PRP,UNKNOWN/i)) {
    // PRP,NN|PRP,UNKNOWN (ex: my name)
    console.log("checking noun phrase");
  }

  if (input.match(/PRP(.*)VBZ/i)) {
    // join middles for now...
    console.log(input.match(/(PRP.*),VBZ/i)[1]);
    var generatedKeyList = Array();
    for (var i = 0; i < userResponses[userResponses.length-1].length-1; i++) {
      generatedKeyList.push(userResponses[userResponses.length-1][i].split("/")[1]);
    }
    console.log(generatedKeyList.join(" "));

    var item = new Object();
    item[generatedKeyList.join(" ")] = userResponses[userResponses.length-1][userResponses[userResponses.length-1].length-1].split("/")[1];
    learn(item);
  }

  if (input.match(/PRP,NN,VBZ|PRP,UNKNOWN,VBZ/i)) {
    if (userResponses[userResponses.length-1][2].split("/")[1] == "is") {
      var zero = userResponses[userResponses.length-1][0].split("/")[1];

      // convert to bot's perspective
      if (zero == "my") zero = "your";

      var one = userResponses[userResponses.length-1][1].split("/")[1];
/*
      var one = "";

      for (var i = 2; i < userResponses[userResponses.length-1].length; i++) {
        if (userResponses[userResponses.length-1][i] && (userResponses[userResponses.length-1][i].split("/")[0] == "NN" || userResponses[userResponses.length-1][i].split("/")[0] == "UNKNOWN")) {
          one += userResponses[userResponses.length-1][i].split("/")[1];
        }
      }
*/
      var comboKey = zero + " " + one;
      var item = new Object();

      //item[comboKey] = userResponses[userResponses.length-1][3].split("/")[1];
      learn(item);
    }
  }
  
  if (input.match(/PRP,VBP,NN|PRP,VBZ,NN|PRP,VBP,UNKNOWN|PRP,VBZ,UNKNOWN/i)) {<commit_msg>regex consolidation<commit_after>// chortle.js
// a quest for chortle

// ADDME: common verbs
var dictionary = {
  "yes": "UH",
  "no": "DT",

  "i": "PRP",
  "you": "PRP",
  "he": "PRP",
  "she": "PRP",
  "it": "PRP",
  "we": "PRP",
  "they": "PRP",
  "me": "PRP",
  "him": "PRP",
  "her": "PRP",
  "us": "PRP",
  "them": "PRP",
  "my": "PRP",
  "your": "PRP",
 
  "because": "IN",
  
  "eat": "VBP",
  "eats": "VBZ",
  "is": "VBZ",

  "salt": "NN",
}

var questions = [
  "what is your name?",
  "what is your favorite food?",
]

var learned = {}
var userResponses = new Array();

function init() {
  var commands = new Array();
  commands.push("PRP VBP|VBZ NN|UNKNOWN ... i eat cake");
  for (i = 0; i < commands.length; i++) {
    document.getElementById('command-list').innerHTML +=
      "<li>" + commands[i] + "</li>";
  }
  
  // first bot question
  var question = "hello, " + questions[0];
  output(question);
  logger(question);
}

function ask(question) {
  output(question);
  return question;
}

function botResponseLogic(input) {
  var botResponse = "";
  // check POS pattern input
  
  /*
      my  name        is  al
      PRP NN|UNKNOWN  VBZ NN|UNKNOWN
  */
  
  // TODO: find a way to use regexps to check inside pattern for matches (and, perhaps, crunch found pattern matches together)
  
  if (input.match(/PRP,NN|PRP,UNKNOWN/i)) {
    // PRP,NN|PRP,UNKNOWN (ex: my name)
    console.log("checking noun phrase");
  }

  if (input.match(/PRP(.*)VBZ/i)) {
    // join middles for now...
    console.log(input.match(/(PRP.*),VBZ/i)[1]);
    var generatedKeyList = Array();
    for (var i = 0; i < userResponses[userResponses.length-1].length-1; i++) {
      generatedKeyList.push(userResponses[userResponses.length-1][i].split("/")[1]);
    }
    console.log(generatedKeyList.join(" "));

    var item = new Object();
    item[generatedKeyList.join(" ")] = userResponses[userResponses.length-1][userResponses[userResponses.length-1].length-1].split("/")[1];
    learn(item);
  }
  
  if (input.match(/PRP,VBP,NN|PRP,VBZ,NN|PRP,VBP,UNKNOWN|PRP,VBZ,UNKNOWN/i)) {
{'fraction_non_alphanumeric': 0.20567375886524822, 'fraction_numerical': 0.008865248226950355, 'mean_word_length': 3.158067158067158, 'pattern_counts': {'":': 42, '<': 12, '<?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': '6017033', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1956, 'n_words': 407}