rioanggara commited on
Commit
afc7996
·
1 Parent(s): a21338b

Add application file

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def word_and_char_counter(text)
4
+ words = text.split()
5
+ num_words = len(words)
6
+ num_chars = len(text.replace( , )) # Remove spaces before counting characters
7
+ return f{num_words} words, {num_chars} characters
8
+
9
+ # Define your interface
10
+ interface = gr.Interface(
11
+ fn=word_and_char_counter,
12
+ inputs=gr.Textbox(lines=2, placeholder=Type something here...),
13
+ outputs=text,
14
+ title=Word and Character Counter,
15
+ description=Counts the words and non-space characters in your text.
16
+ )
17
+
18
+ # Launch the app
19
+ if __name__ == __main__
20
+ interface.launch()