fixed bug

This commit is contained in:
Nick Walton
2019-11-18 17:50:50 -07:00
parent ed9c9ff9d2
commit 7dbc3181a4
2 changed files with 6 additions and 7 deletions
+4 -6
View File
@@ -9,11 +9,13 @@ def console_print(text, width=75):
while i < len(text):
if text[i] == "\n":
last_newline = 0
elif last_newline > width:
elif last_newline > width and text[i] == " ":
text = text[:i] + "\n" + text[i:]
last_newline = 0
else:
last_newline += 1
i += 1
print(text)
def play_unconstrained():
@@ -22,10 +24,7 @@ def play_unconstrained():
generator = GPT2Generator()
prompt = get_story_start("knight")
context = get_context("knight")
print("DEUBUG: Context is ", context)
print("DEBUG: Prompt is ", prompt)
story_manager = UnconstrainedStoryManager(generator)
print("Generating initial story.")
story_manager.start_new_story(prompt, context=context)
with open('opening.txt', 'r') as file:
@@ -34,8 +33,7 @@ def play_unconstrained():
print(starter)
print("\n")
console_print(context)
console_print(str(story_manager.story))
console_print(context + str(story_manager.story))
while True:
action = input("> ")
+2 -1
View File
@@ -72,6 +72,7 @@ class GPT2Generator:
result = result.replace('."', '".')
result = result.replace("#", "")
result = result.replace("*", "")
result = result.replace("\n\n", "\n")
#result = first_to_second_person(result)
result = remove_profanity(result)
@@ -86,7 +87,7 @@ class GPT2Generator:
def generate(self, prompt, options=None, seed=1):
debug_print = True
debug_print = False
prefix = self.prompt_replace(prompt)
if debug_print: