Ejemplo n.º 1
0
def test():
    Marvin = ChatBot()
    results = []
    results.append("MODEL_TYPE: %s\n" % params.model_type)
    results.append("MODEL_SIZE: %d\n" % params.size)
    results.append("NUM_LAYERS: %d\n" % params.num_layers)
    results.append("VOCAB_SIZE: %d\n" % params.vocab_size)
    results.append("LEARNING_PATTERN: %d\n" %
                   params.learning_rate_decay_factor)
    results.append("TRAINING DATA: %s\n" % params.training_data)
    results.append("CHECKPOINT: %s\n" % params.restore_model.split('-')[-1])

    with open('test/test_template', 'r') as template_file:
        for line in template_file:
            results.append(line)
            if "PROMPT" in line:
                sentence = line.split(':')[-1].strip()
                response = Marvin.respond(sentence)
                results.append("RESPONSE: %s\n" % response)
    # template_file.close()

    with open(
            '{0}/{1}'.format(params.test_dir,
                             params.restore_model.split('-')[-1]),
            'w') as test_file:
        test_file.write("".join(results))
Ejemplo n.º 2
0
def decode():
  Marvin = ChatBot()
  sys.stdout.write("> ")
  sys.stdout.flush()
  sentence = sys.stdin.readline()
  while sentence:
    response = Marvin.respond(sentence)
    print(response)
    print("> ", end="")
    sys.stdout.flush()
    sentence = sys.stdin.readline()
Ejemplo n.º 3
0
def test():
  Marvin = ChatBot()
  results = []
  results.append("MODEL_TYPE: %s\n" % params.model_type)
  results.append("MODEL_SIZE: %d\n" % params.size)
  results.append("NUM_LAYERS: %d\n" % params.num_layers)
  results.append("VOCAB_SIZE: %d\n" % params.vocab_size)
  results.append("LEARNING_PATTERN: %d\n" % params.learning_rate_decay_factor)
  results.append("TRAINING DATA: %s\n" % params.training_data)
  results.append("CHECKPOINT: %s\n" % params.restore_model.split('-')[-1])

  with open('test/test_template', 'r') as template_file:
    for line in template_file:
      results.append(line)
      if "PROMPT" in line:
        sentence = line.split(':')[-1].strip()
        response = Marvin.respond(sentence)
        results.append("RESPONSE: %s\n" % response)

  with open('{0}/{1}'.format(params.test_dir, params.restore_model.split('-')[-1]), 'w') as test_file:
    test_file.write("".join(results))