SitwalaM commited on
Commit
ab89c99
·
1 Parent(s): 2b61efd

first commit

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