Spaces:
Sleeping
Sleeping
File size: 1,212 Bytes
ab89c99 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import streamlit as st
from dolma.core.utils import split_paragraphs, split_sentences
# Title of the Streamlit app
st.title('Text Splitter: Paragraphs and Sentences')
# Text input from user
sample_text = st.text_area("Paste your text below", height=300)
if sample_text:
# Split the text into paragraphs
paragraphs = split_paragraphs(sample_text)
# Split the text into sentences
sentences = split_sentences(sample_text)
# Show number of paragraphs and sentences
st.write(f"Number of paragraphs: {len(paragraphs)}")
st.write(f"Number of sentences: {len(sentences)}")
# Create two columns for separate views
col1, col2 = st.columns(2)
# Display paragraphs in the left column
with col1:
st.header("Paragraphs")
for i, paragraph in enumerate(paragraphs):
st.subheader(f"Paragraph {i + 1}")
st.write(paragraph.text)
# Display sentences in the right column
with col2:
st.header("Sentences")
for i, sentence in enumerate(sentences):
st.subheader(f"Sentence {i + 1}")
st.write(sentence.text)
else:
st.write("Please paste your text to split it into paragraphs and sentences.")
|