Spaces:
Sleeping
Sleeping
Truong-Phuc Nguyen
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ st.set_page_config(page_icon='🍃', page_title='MRC for Legal Document Dataset
|
|
6 |
|
7 |
st.markdown("<h2 style='text-align: center;'>Investigation Legal Dataset checker for Machine Reading Comprehension</h2>", unsafe_allow_html=True)
|
8 |
|
9 |
-
df = pd.read_csv(filepath_or_buffer='./
|
10 |
|
11 |
if 'idx' not in st.session_state:
|
12 |
st.session_state.idx = 0
|
@@ -18,12 +18,24 @@ col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10 = st.colum
|
|
18 |
btn_previous = col_1.button(label=':arrow_backward: Previous sample', use_container_width=True)
|
19 |
btn_next = col_2.button(label='Next sample :arrow_forward:', use_container_width=True)
|
20 |
btn_save = col_3.button(label=':heavy_check_mark: Save change', use_container_width=True)
|
|
|
|
|
21 |
|
22 |
if len(df) != 0:
|
23 |
-
|
|
|
24 |
txt_question = st.text_area(height=100, label='Your question:', value=df['question'][st.session_state.idx])
|
25 |
txt_answer = st.text_area(height=100, label='Your answer:', value=df['answer'][st.session_state.idx])
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
if txt_answer.strip() and txt_context.strip():
|
28 |
highlighted_context = re.sub(re.escape(txt_answer), "<mark>" + txt_answer + "</mark>", txt_context, flags=re.IGNORECASE)
|
29 |
st.markdown(highlighted_context, unsafe_allow_html=True)
|
@@ -46,5 +58,13 @@ if len(df) != 0:
|
|
46 |
df['context'][st.session_state.idx] = txt_context
|
47 |
df['question'][st.session_state.idx] = txt_question
|
48 |
df['answer'][st.session_state.idx] = txt_answer
|
|
|
|
|
|
|
|
|
49 |
btn_download = col_4.download_button(data=df.to_csv(), label=':arrow_down_small: Download file', use_container_width=True, file_name="checked.csv", mime="text/csv")
|
50 |
-
df.to_csv(path_or_buf='./
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
st.markdown("<h2 style='text-align: center;'>Investigation Legal Dataset checker for Machine Reading Comprehension</h2>", unsafe_allow_html=True)
|
8 |
|
9 |
+
df = pd.read_csv(filepath_or_buffer='./Legal_AbstractiveA.csv')
|
10 |
|
11 |
if 'idx' not in st.session_state:
|
12 |
st.session_state.idx = 0
|
|
|
18 |
btn_previous = col_1.button(label=':arrow_backward: Previous sample', use_container_width=True)
|
19 |
btn_next = col_2.button(label='Next sample :arrow_forward:', use_container_width=True)
|
20 |
btn_save = col_3.button(label=':heavy_check_mark: Save change', use_container_width=True)
|
21 |
+
txt_goto = col_5.selectbox(label='Sample', label_visibility='collapsed', options=list(range(1, len(df) + 1)))
|
22 |
+
btn_goto = col_6.button(label=':fast_forward: Move to', use_container_width=True)
|
23 |
|
24 |
if len(df) != 0:
|
25 |
+
col_x1, col_x2 = st.columns([8.5, 1.5])
|
26 |
+
txt_context = col_x1.text_area(height=300, label='Your context:', value=df['context'][st.session_state.idx])
|
27 |
txt_question = st.text_area(height=100, label='Your question:', value=df['question'][st.session_state.idx])
|
28 |
txt_answer = st.text_area(height=100, label='Your answer:', value=df['answer'][st.session_state.idx])
|
29 |
|
30 |
+
options = ['Never been evaluated', 'Bad', 'Acceptable', 'Good']
|
31 |
+
criteria_1_value = df['criteria_1'][st.session_state.idx] if 'criteria_1' in df.columns else 'Never been evaluated'
|
32 |
+
criteria_2_value = df['criteria_2'][st.session_state.idx] if 'criteria_2' in df.columns else 'Never been evaluated'
|
33 |
+
criteria_3_value = df['criteria_3'][st.session_state.idx] if 'criteria_3' in df.columns else 'Never been evaluated'
|
34 |
+
|
35 |
+
criteria_1 = col_x2.selectbox(label='Are the questions natural, comprehensive, and appropriate to the content?', options=['Never been evaluated', 'Bad', 'Acceptable', 'Good'], index=options.index(criteria_1_value))
|
36 |
+
criteria_2 = col_x2.selectbox(label='Is the answer correct, clear, and fluent?', options=['Never been evaluated', 'Bad', 'Acceptable', 'Good'], index=options.index(criteria_2_value))
|
37 |
+
criteria_3 = col_x2.selectbox(label='Do the question and answer pairs match each other?', options=['Never been evaluated', 'Bad', 'Acceptable', 'Good'], index=options.index(criteria_3_value))
|
38 |
+
|
39 |
if txt_answer.strip() and txt_context.strip():
|
40 |
highlighted_context = re.sub(re.escape(txt_answer), "<mark>" + txt_answer + "</mark>", txt_context, flags=re.IGNORECASE)
|
41 |
st.markdown(highlighted_context, unsafe_allow_html=True)
|
|
|
58 |
df['context'][st.session_state.idx] = txt_context
|
59 |
df['question'][st.session_state.idx] = txt_question
|
60 |
df['answer'][st.session_state.idx] = txt_answer
|
61 |
+
|
62 |
+
df['criteria_1'][st.session_state.idx] = criteria_1
|
63 |
+
df['criteria_2'][st.session_state.idx] = criteria_2
|
64 |
+
df['criteria_3'][st.session_state.idx] = criteria_3
|
65 |
btn_download = col_4.download_button(data=df.to_csv(), label=':arrow_down_small: Download file', use_container_width=True, file_name="checked.csv", mime="text/csv")
|
66 |
+
df.to_csv(path_or_buf='./Legal_AbstractiveA.csv', index=None)
|
67 |
+
|
68 |
+
if btn_goto:
|
69 |
+
st.session_state.idx = txt_goto - 1
|
70 |
+
st.rerun()
|