Update app.py
Browse files
app.py
CHANGED
|
@@ -68,6 +68,7 @@ def gen_template(crime_descrip, element, tag):
|
|
| 68 |
template = blurb + '\n' + descript + '\n' + element + '\n' + tag + '\n' + end
|
| 69 |
return template
|
| 70 |
|
|
|
|
| 71 |
js_download = '''function downloadFile(result, filename) {
|
| 72 |
//藉型別陣列建構的 blob 來建立 URL
|
| 73 |
let fileName = filename;
|
|
@@ -113,19 +114,18 @@ with gr.Blocks() as demo:
|
|
| 113 |
with gr.Row():
|
| 114 |
with gr.Column():
|
| 115 |
btn = gr.Button("隨機選擇")
|
| 116 |
-
with gr.Column():
|
| 117 |
with gr.Row():
|
| 118 |
element = gr.components.Textbox(lines=2, label="構成要件要素")
|
| 119 |
-
tag = gr.Dropdown(
|
| 120 |
-
choices = [("被告(犯罪主體)","<LEO_SOC>"), ("主觀犯意", "<LEO_SLE>"), ("不法行為","<LEO_ACT>"), ("因果關係","<LEO_CAU>"),
|
| 121 |
("被害人/告訴人","<LEO_VIC>"), ("危害結果","<LEO_ROH>"), ("未遂","<LEO_ATP>"), ("既遂","<LEO_ACC>"),
|
| 122 |
("中止","<LEO_ABA>"), ("預備","<LEO_PRP>")],
|
| 123 |
label="標籤", info="構成要件要素的標籤", type='value')
|
|
|
|
|
|
|
| 124 |
with gr.Row():
|
| 125 |
with gr.Column():
|
| 126 |
btn2 = gr.Button("產生標註語料內容")
|
| 127 |
-
|
| 128 |
-
btn3 = gr.Button("下載")
|
| 129 |
btn.click(random_next, inputs=[], outputs=[courtName, caseNo, prompt, filename])
|
| 130 |
btn2.click(gen_template, inputs=[prompt, element, tag], outputs=[result])
|
| 131 |
btn3.click(None, inputs=[result, filename], _js=js_download)
|
|
|
|
| 68 |
template = blurb + '\n' + descript + '\n' + element + '\n' + tag + '\n' + end
|
| 69 |
return template
|
| 70 |
|
| 71 |
+
# 用來產生下載檔案按鈕用的 JavaScript
|
| 72 |
js_download = '''function downloadFile(result, filename) {
|
| 73 |
//藉型別陣列建構的 blob 來建立 URL
|
| 74 |
let fileName = filename;
|
|
|
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column():
|
| 116 |
btn = gr.Button("隨機選擇")
|
|
|
|
| 117 |
with gr.Row():
|
| 118 |
element = gr.components.Textbox(lines=2, label="構成要件要素")
|
| 119 |
+
tag = gr.Dropdown(choices = [("被告(犯罪主體)","<LEO_SOC>"), ("主觀犯意", "<LEO_SLE>"), ("不法行為","<LEO_ACT>"), ("因果關係","<LEO_CAU>"),
|
|
|
|
| 120 |
("被害人/告訴人","<LEO_VIC>"), ("危害結果","<LEO_ROH>"), ("未遂","<LEO_ATP>"), ("既遂","<LEO_ACC>"),
|
| 121 |
("中止","<LEO_ABA>"), ("預備","<LEO_PRP>")],
|
| 122 |
label="標籤", info="構成要件要素的標籤", type='value')
|
| 123 |
+
with gr.Column():
|
| 124 |
+
result = gr.components.Textbox(lines=5, label="語料內容", show_copy_button=True)
|
| 125 |
with gr.Row():
|
| 126 |
with gr.Column():
|
| 127 |
btn2 = gr.Button("產生標註語料內容")
|
| 128 |
+
btn3 = gr.Button("下載")
|
|
|
|
| 129 |
btn.click(random_next, inputs=[], outputs=[courtName, caseNo, prompt, filename])
|
| 130 |
btn2.click(gen_template, inputs=[prompt, element, tag], outputs=[result])
|
| 131 |
btn3.click(None, inputs=[result, filename], _js=js_download)
|