wordcounter / app.py
rioanggara's picture
Fix syntax error in app.py
4015ede
raw
history blame
591 Bytes
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()