Truong-Phuc Nguyen commited on
Commit
3188aec
·
verified ·
1 Parent(s): 69dfbe4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,7 +5,7 @@ import re
5
  st.set_page_config(layout='wide')
6
 
7
  def load_data():
8
- return pd.read_csv(filepath_or_buffer='./Legal_AbstractiveA.csv')
9
 
10
  df = load_data()
11
 
@@ -30,17 +30,17 @@ if btn_next:
30
 
31
  st.markdown(f"<h3 style='text-align: center;'>Sample: {st.session_state.idx+1}/{len(df)}</h3>", unsafe_allow_html=True)
32
 
33
- context = st.text_area(label='Your context: ', value=df['context'][st.session_state.idx], height=300)
34
- question = st.text_area(label='Your question: ', value=df['question'][st.session_state.idx], height=100)
35
- answer = st.text_area(label='Your answer: ', value=df['answer'][st.session_state.idx], height=100)
36
 
37
  if answer.strip() and context.strip():
38
  highlighted_context = re.sub(re.escape(answer), "<mark>" + answer + "</mark>", context, flags=re.IGNORECASE)
39
  st.markdown(highlighted_context, unsafe_allow_html=True)
40
 
41
  if btn_save:
42
- df.loc[st.session_state.idx, 'context'] = context
43
- df.loc[st.session_state.idx, 'question'] = question
44
- df.loc[st.session_state.idx, 'answer'] = answer
45
 
46
- df.to_csv('./Legal_AbstractiveA.csv', index=False)
 
5
  st.set_page_config(layout='wide')
6
 
7
  def load_data():
8
+ return pd.read_csv(filepath_or_buffer='./data.csv')
9
 
10
  df = load_data()
11
 
 
30
 
31
  st.markdown(f"<h3 style='text-align: center;'>Sample: {st.session_state.idx+1}/{len(df)}</h3>", unsafe_allow_html=True)
32
 
33
+ context = st.text_area(label='Your context: ', value=df['contexts'][st.session_state.idx], height=300)
34
+ question = st.text_area(label='Your question: ', value=df['questions'][st.session_state.idx], height=100)
35
+ answer = st.text_area(label='Your answer: ', value=df['answers'][st.session_state.idx], height=100)
36
 
37
  if answer.strip() and context.strip():
38
  highlighted_context = re.sub(re.escape(answer), "<mark>" + answer + "</mark>", context, flags=re.IGNORECASE)
39
  st.markdown(highlighted_context, unsafe_allow_html=True)
40
 
41
  if btn_save:
42
+ df.loc[st.session_state.idx, 'contexts'] = context
43
+ df.loc[st.session_state.idx, 'questions'] = question
44
+ df.loc[st.session_state.idx, 'answers'] = answer
45
 
46
+ df.to_csv('./data.csv', index=False)