Update app.py
Browse files
app.py
CHANGED
@@ -65,11 +65,16 @@ def find_rhymes_for_phrase(phrase, syllable_count=1):
|
|
65 |
else:
|
66 |
rhyming_options.append([f"{word} (No rhymes found)"])
|
67 |
|
|
|
68 |
combined_results = list(itertools.product(*rhyming_options))
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
result_str = f"Rhyming combinations for '{phrase}':\n"
|
72 |
-
result_str += "\n".join(
|
73 |
return result_str
|
74 |
else:
|
75 |
return f"No rhyming combinations found for '{phrase}'"
|
@@ -82,7 +87,7 @@ iface = gr.Interface(
|
|
82 |
gr.Slider(1, 3, step=1, label="Number of Syllables")
|
83 |
],
|
84 |
outputs="text",
|
85 |
-
description="Enter a phrase with any number of words to find multisyllabic rhyming combinations
|
86 |
)
|
87 |
|
88 |
if __name__ == "__main__":
|
|
|
65 |
else:
|
66 |
rhyming_options.append([f"{word} (No rhymes found)"])
|
67 |
|
68 |
+
# Generate all possible combinations of rhyming words
|
69 |
combined_results = list(itertools.product(*rhyming_options))
|
70 |
|
71 |
+
# Remove duplicates
|
72 |
+
unique_results = set(" ".join(combination) for combination in combined_results)
|
73 |
+
|
74 |
+
# Format combined results as rhyming lines
|
75 |
+
if unique_results:
|
76 |
result_str = f"Rhyming combinations for '{phrase}':\n"
|
77 |
+
result_str += "\n".join(unique_results)
|
78 |
return result_str
|
79 |
else:
|
80 |
return f"No rhyming combinations found for '{phrase}'"
|
|
|
87 |
gr.Slider(1, 3, step=1, label="Number of Syllables")
|
88 |
],
|
89 |
outputs="text",
|
90 |
+
description="Enter a phrase with any number of words to find multisyllabic rhyming combinations."
|
91 |
)
|
92 |
|
93 |
if __name__ == "__main__":
|