Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions judgement-text-annotator/__init__.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. __init__模块一般写导入信息,不会有业务代码,放在__main__.py模块更佳。
  2. judgement-text-annotator/judgement_text_annotator/__main__.py,在项目根目录下运行时python -m judgement_text_annotator

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def extract_info_from_judgment(judgment_text):

def mark_judgment(judgment_text):
global mark_judgment_info
if judgment_text == "":
return []
info_dict = extract_info_from_judgment(judgment_text)
mark_judgment_info = [[key, value] for key, value in info_dict.items()]
return mark_judgment_info
Expand All @@ -118,7 +120,7 @@ def download_csv():
return file_path

def clear_input():
return ""
return "", []

def read_docx(file):
doc = Document(file.name)
Expand Down Expand Up @@ -167,7 +169,7 @@ def main():

upload_file.change(fn=read_uploaded_file, inputs=upload_file, outputs=input_text)
submit_btn.click(fn=mark_judgment, inputs=input_text, outputs=output_boxes)
clear_btn.click(fn=clear_input, outputs=input_text)
clear_btn.click(fn=clear_input, outputs=[input_text, output_boxes])
download_btn.click(fn=download_csv, outputs=gr.File(label="CSV文件"))

demo.launch()
Expand Down