This commit is contained in:
Nick Walton
2019-09-26 14:46:23 -06:00
parent d88c008287
commit dbd8132a54
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -20,7 +20,7 @@ def loss(labels, logits):
class CTRLGenerator():
def __init__(self, control_code="Horror Text: ", generate_num=80, temperature=0.3):
def __init__(self, control_code="Writing Text: ", generate_num=80, temperature=0.3):
self.generate_num=generate_num
model_dir = "generator/ctrl/model/seqlen256_v1.ckpt/"
@@ -158,7 +158,7 @@ class CTRLGenerator():
if prompt[-1] != " ":
prompt = prompt + " "
prompt = second_to_first_person(prompt)
#prompt = second_to_first_person(prompt)
prompt = self.control_code + prompt
# print("\n\nAFTER PROMPT_REPLACE")
@@ -172,7 +172,7 @@ class CTRLGenerator():
first_letter_capitalized = result[0].isupper()
result = result.replace("#", "")
result = result.replace("*", "")
result = first_to_second_person(result)
#result = first_to_second_person(result)
result = remove_profanity(result)
if not first_letter_capitalized:
+1 -1
View File
@@ -173,5 +173,5 @@ def second_to_first_person(text):
return capitalize_first_letters(text[1:])
if __name__ == '__main__':
text = '“Hey there, you okay?” She asks. I\'m not sure what to say, “I\'m fine, I\'m sorry.” I say'
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))