Spaces:
Sleeping
Sleeping
ansfarooq7
commited on
Commit
•
0bb105b
1
Parent(s):
cabc3db
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,7 @@ def get_line(prompt, inputs_len):
|
|
90 |
clean_up_tokenization_spaces=True,
|
91 |
return_full_text=False
|
92 |
)
|
93 |
-
return remove_punctuation(output[0]['generated_text'])
|
94 |
|
95 |
def get_rhyming_line(prompt, rhyming_word, inputs_len):
|
96 |
output = gpt2_pipeline(
|
@@ -100,7 +100,7 @@ def get_rhyming_line(prompt, rhyming_word, inputs_len):
|
|
100 |
clean_up_tokenization_spaces=True,
|
101 |
return_full_text=False
|
102 |
)
|
103 |
-
gpt2_sentence = remove_punctuation(output[0]['generated_text'])
|
104 |
while len(gpt2_sentence) == 0:
|
105 |
output = gpt2_pipeline(
|
106 |
prompt + ".",
|
@@ -109,9 +109,8 @@ def get_rhyming_line(prompt, rhyming_word, inputs_len):
|
|
109 |
clean_up_tokenization_spaces=True,
|
110 |
return_full_text=False
|
111 |
)
|
112 |
-
gpt2_sentence = remove_punctuation(output[0]['generated_text'])
|
113 |
|
114 |
-
gpt2_sentence = gpt2_sentence.replace("\n", "")
|
115 |
print(f"\nGetting rhyming line starting with '{gpt2_sentence}' and ending with rhyming word '{rhyming_word}'")
|
116 |
sentence = gpt2_sentence + " ___ ___ ___ " + rhyming_word
|
117 |
print(f"Original Sentence: {sentence}")
|
@@ -136,7 +135,7 @@ def gpt2_summary(topic):
|
|
136 |
clean_up_tokenization_spaces=True,
|
137 |
return_full_text=False
|
138 |
)
|
139 |
-
return remove_punctuation(output[0]['generated_text'])
|
140 |
|
141 |
def generate(topic, wiki=True):
|
142 |
if wiki:
|
|
|
90 |
clean_up_tokenization_spaces=True,
|
91 |
return_full_text=False
|
92 |
)
|
93 |
+
return remove_punctuation(output[0]['generated_text']).strip()
|
94 |
|
95 |
def get_rhyming_line(prompt, rhyming_word, inputs_len):
|
96 |
output = gpt2_pipeline(
|
|
|
100 |
clean_up_tokenization_spaces=True,
|
101 |
return_full_text=False
|
102 |
)
|
103 |
+
gpt2_sentence = remove_punctuation(output[0]['generated_text']).strip()
|
104 |
while len(gpt2_sentence) == 0:
|
105 |
output = gpt2_pipeline(
|
106 |
prompt + ".",
|
|
|
109 |
clean_up_tokenization_spaces=True,
|
110 |
return_full_text=False
|
111 |
)
|
112 |
+
gpt2_sentence = remove_punctuation(output[0]['generated_text']).strip()
|
113 |
|
|
|
114 |
print(f"\nGetting rhyming line starting with '{gpt2_sentence}' and ending with rhyming word '{rhyming_word}'")
|
115 |
sentence = gpt2_sentence + " ___ ___ ___ " + rhyming_word
|
116 |
print(f"Original Sentence: {sentence}")
|
|
|
135 |
clean_up_tokenization_spaces=True,
|
136 |
return_full_text=False
|
137 |
)
|
138 |
+
return remove_punctuation(output[0]['generated_text']).strip()
|
139 |
|
140 |
def generate(topic, wiki=True):
|
141 |
if wiki:
|