new-space / app.py
pyerlock's picture
initial commit
dcb09fa verified
import gradio as gr
with gr.Blocks() as demo:
textbox = gr.Textbox(value=['Booking.com', 'Uber', 'Maarkplaats'])
textbox_2 = gr.Textbox()
@gr.on([], inputs=[textbox], outputs=[textbox_2])
def fn_1(textbox):
from collections import Counter
if isinstance(textbox, str):
text = textbox
elif hasattr(textbox, 'text') and callable(textbox.text):
text = textbox.text()
else:
raise ValueError("Unsupported type for textbox")
char_count = Counter(text)
sorted_char_count = sorted(char_count.items(), key=lambda item: item[1], reverse=True)
return sorted_char_count
demo.launch()