fixthethe

This commit is contained in:
nickwalton
2019-10-31 13:22:13 -06:00
parent cc450d1fdc
commit 0c7fd6d9b3
2 changed files with 8 additions and 8 deletions
+5 -7
View File
@@ -166,8 +166,8 @@ class CTRLGenerator():
return prompt
def result_replace(self, result):
# print("\n\nBEFORE RESULT_REPLACE:")
# print(repr(result))
print("\n\nBEFORE RESULT_REPLACE:")
print(repr(result))
result = cut_trailing_sentence(result)
first_letter_capitalized = result[0].isupper()
@@ -180,11 +180,9 @@ class CTRLGenerator():
if not first_letter_capitalized:
result = result[0].lower() + result[1:]
while("\n \n \n " in result):
result = result.replace("\n \n \n ", "\n \n ")
# print("\n\nAFTER RESULT_REPLACE:")
# print(repr(result))
print("\n\nAFTER RESULT_REPLACE:")
print(repr(result))
return result
@@ -221,7 +219,7 @@ class CTRLGenerator():
"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", "|@@", '...',
'..','', 'https://@@']
'..','', 'https://@@', '...@@']
for forbidden_token in forbidden_tokens:
prompt_logits[_token][self.word2idx[forbidden_token]] = -1e8
+3 -1
View File
@@ -75,6 +75,7 @@ def split_first_sentence(text):
def cut_trailing_sentence(text):
text = standardize_punctuation(text)
last_punc = max(text.rfind('.'), text.rfind("!"), text.rfind("?"))
if last_punc > 0:
@@ -84,6 +85,7 @@ def cut_trailing_sentence(text):
def replace_outside_quotes(text, current_word, repl_word):
text = standardize_punctuation(text)
reg_expr = re.compile(current_word + '(?=([^"]*"[^"]*")*[^"]*$)')
@@ -104,7 +106,7 @@ def mapping_variation_pairs(mapping):
# Change you it's before a punctuation
if mapping[0] is "you":
mapping = ("you", "me")
mapping_list.append((" " + mapping[0]+"\,", " " + mapping[1]+","))
mapping_list.append((" " + mapping[0]+",", " " + mapping[1]+","))
mapping_list.append((" " + mapping[0]+"\?", " " + mapping[1]+"\?"))
mapping_list.append((" " + mapping[0]+"\!", " " + mapping[1]+"\!"))
mapping_list.append((" " + mapping[0] + "\.", " " + mapping[1] + "."))