fix issue with odd baits
Browse files
app.py
CHANGED
@@ -58,9 +58,9 @@ def analyze(poem):
|
|
58 |
|
59 |
def generate(inputs, top_p = 3):
|
60 |
baits = inputs.split('\n')
|
61 |
-
|
|
|
62 |
poem = ' '.join(['<|bsep|> '+baits[i]+' <|vsep|> '+baits[i+1]+' </|bsep|>' for i in range(0, len(baits), 2)])
|
63 |
-
print(poem)
|
64 |
prompt = f"""
|
65 |
{meter_to_token[meter]} {qafiyah} {theme_to_token[theme]}
|
66 |
<|psep|>
|
@@ -101,13 +101,11 @@ examples = [
|
|
101 |
],
|
102 |
[
|
103 |
"""ุฑู
ุชู ุงููุคุงุฏู ู
ููุญุฉ ุนุฐุฑุงุกู
|
104 |
-
ุจุณูุงู
ู ูุญุธู ู
ุง ููููู ุฏูุงุกู
|
105 |
-
"""
|
106 |
],
|
107 |
[
|
108 |
"""ุฃุฐูููู ุงูุญูุฑูุตู ูุงูุทููู
ูุนู ุงูุฑูููุงุจูุง
|
109 |
-
ูููุฏ ููุนูู ุงูููุฑูู
ูุ ุฅุฐุง ุงุณุชูุฑูุงุจูุง
|
110 |
-
"""
|
111 |
]
|
112 |
]
|
113 |
|
@@ -142,4 +140,5 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
142 |
trg_btn.click(generate, inputs = inputs, outputs=textbox_output)
|
143 |
inp_btn.click(analyze, inputs = inputs, outputs=html_output)
|
144 |
|
|
|
145 |
demo.launch()
|
|
|
58 |
|
59 |
def generate(inputs, top_p = 3):
|
60 |
baits = inputs.split('\n')
|
61 |
+
if len(baits) % 2 !=0:
|
62 |
+
baits = baits[:-1]
|
63 |
poem = ' '.join(['<|bsep|> '+baits[i]+' <|vsep|> '+baits[i+1]+' </|bsep|>' for i in range(0, len(baits), 2)])
|
|
|
64 |
prompt = f"""
|
65 |
{meter_to_token[meter]} {qafiyah} {theme_to_token[theme]}
|
66 |
<|psep|>
|
|
|
101 |
],
|
102 |
[
|
103 |
"""ุฑู
ุชู ุงููุคุงุฏู ู
ููุญุฉ ุนุฐุฑุงุกู
|
104 |
+
ุจุณูุงู
ู ูุญุธู ู
ุง ููููู ุฏูุงุกู"""
|
|
|
105 |
],
|
106 |
[
|
107 |
"""ุฃุฐูููู ุงูุญูุฑูุตู ูุงูุทููู
ูุนู ุงูุฑูููุงุจูุง
|
108 |
+
ูููุฏ ููุนูู ุงูููุฑูู
ูุ ุฅุฐุง ุงุณุชูุฑูุงุจูุง"""
|
|
|
109 |
]
|
110 |
]
|
111 |
|
|
|
140 |
trg_btn.click(generate, inputs = inputs, outputs=textbox_output)
|
141 |
inp_btn.click(analyze, inputs = inputs, outputs=html_output)
|
142 |
|
143 |
+
# demo.launch(server_name = '0.0.0.0', share=True)
|
144 |
demo.launch()
|