Spaces:
Sleeping
Sleeping
File size: 591 Bytes
afc7996 f8e0912 afc7996 4015ede afc7996 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
def word_and_char_counter(text):
words = text.split()
num_words = len(words)
num_chars = len(text.replace(" ", "")) # Remove spaces before counting characters
return f{num_words} words, {num_chars} characters
# Define your interface
interface = gr.Interface(
fn=word_and_char_counter,
inputs=gr.Textbox(lines=2, placeholder=Type something here...),
outputs=text,
title=Word and Character Counter,
description=Counts the words and non-space characters in your text.
)
# Launch the app
if __name__ == __main__
interface.launch()
|