From 074f34f4dd0a192cdef1c7aa8ade9cac89a9f3a3 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 31 Oct 2019 03:03:07 -0600 Subject: [PATCH 1/2] update --- story/story_manager.py | 2 +- story/utils.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/story/story_manager.py b/story/story_manager.py index 29cdce6..cb4f2b4 100644 --- a/story/story_manager.py +++ b/story/story_manager.py @@ -213,7 +213,7 @@ class CTRLStoryManager(ConstrainedStoryManager): for phrase in self.action_phrases: result = self.generate_action_result(self.story_context(), phrase, options=options) action_verb = result[0].split()[1] - print("blacklisted verb is ", action_verb) + options["word_blacklist"][0].append(action_verb) results.append(result) return results diff --git a/story/utils.py b/story/utils.py index 586550a..036fd56 100644 --- a/story/utils.py +++ b/story/utils.py @@ -188,5 +188,16 @@ def second_to_first_person(text): return capitalize_first_letters(text[1:]) if __name__ == '__main__': - text = 'You wake up in an old rundown hospital with no memory of how you got there. You look around and see a nurse standing over me. "Hey buddy, you okay?" she asks. She looks at me like I\'m crazy. ' - print(first_to_second_person(text)) \ No newline at end of file + + + result = 'The only thing they can tell you is, "We have nowhere else to…"' + result = result.replace('."', '".') + result = result.replace("#", "") + result = result.replace("*", "") + result = first_to_second_person(result) + result = remove_profanity(result) + + while ("\n \n \n " in result): + result = result.replace("\n \n \n ", "\n \n ") + + print(result) \ No newline at end of file From b69b1ce308e879eb99c5a58945180d8157c9941a Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 31 Oct 2019 03:05:27 -0600 Subject: [PATCH 2/2] update --- generator/ctrl/ctrl_generator.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index d325d5e..4be6f57 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -265,9 +265,6 @@ class CTRLGenerator(): tf.random.categorical(np.expand_dims(prompt_logits[_token][pruned_list], 0), num_samples=1).numpy()) idx = pruned_list[chosen_idx] - # assign the token for generation - tokens_generated[0][token + 1] = idx - return idx def generate(self, prompt, options=None): @@ -307,6 +304,8 @@ class CTRLGenerator(): idx = self.generate_next_token(token, tokens_generated, options, num_new_lines, token_num, first_token=first_token, forbid_newline=True) + # assign the token for generation + tokens_generated[0][token + 1] = idx if debug_print: print(repr(self.idx2word[idx]), end="_")