File size: 891 Bytes
522fb71
 
15a3e70
 
 
 
 
522fb71
 
 
15a3e70
522fb71
 
15a3e70
 
522fb71
 
15a3e70
 
522fb71
15a3e70
 
 
 
522fb71
 
 
 
 
 
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
import gradio as gr

def split_into_sentences(text, remove_whitespace):
    sentences = text.split('\n')
    if remove_whitespace:
        sentences = [s.strip() for s in sentences if s.strip() != '']
    return sentences

def main():
    with gr.Blocks() as demo:
        gr.Markdown("# Text to Sentences Splitter")

        with gr.Row():
            text_input = gr.Textbox(label="Enter or paste your text", lines=5)
            whitespace_checkbox = gr.Checkbox(label="Remove extra whitespace", value=True)

        with gr.Row():
            split_button = gr.Button("Split into Sentences")
            sentences_output = gr.Textbox(label="Sentences", lines=5)

        split_button.click(
            fn=split_into_sentences,
            inputs=[text_input, whitespace_checkbox],
            outputs=sentences_output
        )

    demo.launch()

if __name__ == "__main__":
    main()