Latin_Ann / app.py
bestroi's picture
Update app.py
cdd0e3d
raw
history blame contribute delete
894 Bytes
import streamlit as st
import pandas as pd
# Title of the app
st.title('Text Annotation App')
# Define labels
labels = ['Label 1', 'Label 2', 'Label 3']
# Input text
user_input = st.text_area("Enter some sentences (one sentence per line)")
# Split the user input into sentences
sentences = user_input.split('\n')
# Placeholder for annotations
annotations = []
# Iterate over sentences
for i, sentence in enumerate(sentences):
if sentence: # if the sentence is not empty
# Select label
label = st.selectbox(f'Choose a label for the following sentence: "{sentence}"', labels, key=i)
# Save annotation
annotations.append({'Sentence': sentence, 'Label': label})
# Save annotations to a CSV file
if st.button('Save Annotations'):
df = pd.DataFrame(annotations)
df.to_csv('annotations.csv', index=False)
st.write('Annotations saved.')