This commit is contained in:
nickwalton
2019-10-31 12:26:20 -06:00
parent 6b09c9fe00
commit 0bb9bfff3e
2 changed files with 10 additions and 30 deletions
+8 -29
View File
@@ -34,6 +34,14 @@ def play_unconstrained():
action = input("> ")
if action != "":
if action[-1] == "." or action[-1] == "?" or action[-1] == "!":
action = action[:-1]
if "you " == action.lower()[0:4]:
action = action[4:]
if "i " == action.lower()[0:2]:
action = action[2:]
action = " You " + action + ". "
action = first_to_second_person(action)
@@ -91,35 +99,6 @@ def play_cached():
console_print(result)
def play_cached_hospital():
print("\n")
generator = CTRLGenerator()
story_start = "haunted"
prompt = get_story_start(story_start)
story_manager = CTRLStoryManager(generator)
story_manager.enable_caching(CRED_FILE, bucket_name="haunted-hospital")
story_manager.start_new_story(prompt)
console_print("\n")
console_print(str(story_manager.story))
possible_actions = story_manager.get_possible_actions()
while (True):
console_print("\nOptions:")
for i, action in enumerate(possible_actions):
console_print(str(i) + ") " + action)
result = None
while (result == None):
action_choice = input("Which action do you choose? ")
if action_choice is "print story":
print(story_manager.story)
continue
print("\n")
result, possible_actions = story_manager.act(action_choice)
console_print(result)
if __name__ == '__main__':
play_unconstrained()
+2 -1
View File
@@ -220,7 +220,8 @@ class CTRLGenerator():
forbidden_tokens = ['<unk>', 'Sco@@', "&amp@@", "1]@@", "2]@@", "3]@@", "4]@@", "https://www.@@", "[@@", ":@@",
"Edit", "&@@", "2:","1:", ":", "Edit@@", "EDI@@", "EDIT@@", "edit", "TL@@", "tl@@", ";@@",
'**', "http://@@", "Redd@@", "UP@@", "mom", "Up@@", "Me:", "Update", "mom@@", "Part",
"http://www.@@", "edit@@", "*@@", "Writing", "Text@@", "\\@@", "<br>@@", "<div", "|@@", '...', '..']
"http://www.@@", "edit@@", "*@@", "Writing", "Text@@", "\\@@", "<br>@@", "<div", "|@@", '...',
'..', 'https://@@]
for forbidden_token in forbidden_tokens:
prompt_logits[_token][self.word2idx[forbidden_token]] = -1e8