gradio/demo/longest_word.py

19 lines
410 B
Python
Raw Normal View History

2020-10-22 20:07:43 +08:00
# Demo: (Textbox) -> (Label)
2020-09-24 03:37:52 +08:00
2020-10-22 20:07:43 +08:00
import gradio as gr
2020-09-24 03:37:52 +08:00
2020-09-21 22:54:34 +08:00
def longest_word(text):
words = text.split(" ")
lengths = [len(word) for word in words]
return max(lengths)
ex = "The quick brown fox jumped over the lazy dog."
2020-11-11 22:15:53 +08:00
iface = gr.Interface(longest_word, "textbox", "label",
interpretation="default", examples=[[ex]])
2020-09-21 22:54:34 +08:00
2020-11-11 22:15:53 +08:00
iface.test_launch()
if __name__ == "__main__":
2020-11-11 22:15:53 +08:00
iface.launch()