From dd91ff7e681e7247e7c049d552edae715d16b31f Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 24 Sep 2019 16:00:01 -0600 Subject: [PATCH] update --- generator/ctrl/ctrl_generator.py | 8 +++----- story/utils.py | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index f9a2550..99e94c8 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -22,7 +22,7 @@ def loss(labels, logits): class CTRLGenerator(): - def __init__(self, control_code="Horror Text: ", generate_num=100, temperature=0.3): + def __init__(self, control_code="Horror Text: ", generate_num=64, temperature=0.3): self.generate_num=generate_num model_dir = "generator/ctrl/model/seqlen256_v1.ckpt/" @@ -30,7 +30,7 @@ class CTRLGenerator(): vocab_file = 'generator/ctrl/model/vocab' code_file = 'generator/ctrl/model/codes' - self.max_new_lines=5 + self.max_new_lines = 5 # load the vocabulary from file vocab = open(vocab_file, encoding='utf-8').read().split('\n') @@ -217,8 +217,6 @@ class CTRLGenerator(): # but I don't do that # if it prints too many new lines instead of continuing generating text, # you might want to comment this out - if self.idx2word[generated_token] == '\n': - continue if generated_token in penalized_so_far: continue penalized_so_far.add(generated_token) @@ -324,7 +322,7 @@ class CTRLGenerator(): if self.idx2word[idx] is "\n": num_new_lines += 1 - print("Generated token is ", self.idx2word[idx]) + #print("Generated token is ", repr(self.idx2word[idx])) tokens_generated_so_far = ' '.join([self.idx2word[c] for c in tokens_generated[0][len(text):].squeeze()[:token + 2]]) tokens_generated_so_far = re.sub('(@@ )', '', string=tokens_generated_so_far) diff --git a/story/utils.py b/story/utils.py index 5c42171..1609c56 100644 --- a/story/utils.py +++ b/story/utils.py @@ -76,6 +76,7 @@ first_to_second_mappings = [ ("I ", "you "), ("I've ", "You've "), ("my ", "your "), + (" my ", " your "), ("My ", "Your "), ("we ","you "), ("We ","You "), @@ -92,6 +93,7 @@ second_to_first_mappings = [ ("you're ", "I'm "), ("Your ", "My "), ("your ", "my "), + (" your ", " my "), ("you are ", "I am "), ("You are ", "I am "), ("You ", "I "),