Spaces:
Running
Running
Truong-Phuc Nguyen
commited on
Update app.py
Browse files
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='./
|
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['
|
34 |
-
question = st.text_area(label='Your question: ', value=df['
|
35 |
-
answer = st.text_area(label='Your answer: ', value=df['
|
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, '
|
43 |
-
df.loc[st.session_state.idx, '
|
44 |
-
df.loc[st.session_state.idx, '
|
45 |
|
46 |
-
df.to_csv('./
|
|
|
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)
|