Upload simple_generation_player.py
Browse files- simple_generation_player.py +21 -2
simple_generation_player.py
CHANGED
|
@@ -127,7 +127,23 @@ def decoder_helper(type, user_input):
|
|
| 127 |
if type=="FORCED":
|
| 128 |
return model.generate_forced(user_input, tokenizer, sample=True, device=device)
|
| 129 |
|
| 130 |
-
help = f"Current setting is {generation} generating.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
print("Welcome to simple czech strophe generation.", help)
|
| 133 |
|
|
@@ -156,10 +172,13 @@ while True:
|
|
| 156 |
user_input = user_input.strip()
|
| 157 |
user_reqs = model.analyze_prompt(user_input)
|
| 158 |
|
| 159 |
-
if "RHYME" not in user_reqs.keys() and generation == "BASIC":
|
| 160 |
print("BASIC generation can't work with imputed format.", help)
|
| 161 |
print("User input is substituted for #")
|
| 162 |
user_input = '#'
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
generated_poem:str = decoder_helper(generation, user_input)
|
| 165 |
|
|
|
|
| 127 |
if type=="FORCED":
|
| 128 |
return model.generate_forced(user_input, tokenizer, sample=True, device=device)
|
| 129 |
|
| 130 |
+
help = f"""Current setting is {generation} generating.
|
| 131 |
+
Change it by writing FORCED/BASIC to input.
|
| 132 |
+
Type HELP for HELP.
|
| 133 |
+
Type EXIT to exit.
|
| 134 |
+
|
| 135 |
+
Supported input consist of:
|
| 136 |
+
# RHYME_SCHEMA # YEAR
|
| 137 |
+
METER # NUM_SYLLABLES # ENDING #
|
| 138 |
+
|
| 139 |
+
FORCED generation supports incomplete verse input of
|
| 140 |
+
J # 13 #
|
| 141 |
+
D # 11 # na #
|
| 142 |
+
|
| 143 |
+
Each verse parameter must be followed by # to be properly analyzed.
|
| 144 |
+
|
| 145 |
+
IMPORTANT! After inputing prompt (Excluding HELP/EXIT/FORCED/BASIC), user MUST input empty line to finish the prompt!
|
| 146 |
+
"""
|
| 147 |
|
| 148 |
print("Welcome to simple czech strophe generation.", help)
|
| 149 |
|
|
|
|
| 172 |
user_input = user_input.strip()
|
| 173 |
user_reqs = model.analyze_prompt(user_input)
|
| 174 |
|
| 175 |
+
if "RHYME" not in user_reqs.keys() and generation == "BASIC" and user_input:
|
| 176 |
print("BASIC generation can't work with imputed format.", help)
|
| 177 |
print("User input is substituted for #")
|
| 178 |
user_input = '#'
|
| 179 |
+
if not user_input:
|
| 180 |
+
print("No input, reverting to #")
|
| 181 |
+
user_input = '#'
|
| 182 |
|
| 183 |
generated_poem:str = decoder_helper(generation, user_input)
|
| 184 |
|