mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
fixed bug
This commit is contained in:
+4
-6
@@ -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("> ")
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user