Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def letter_counter(word, letter):
|
4 |
+
"""
|
5 |
+
Count the number of occurrences of a letter in a word or text.
|
6 |
+
|
7 |
+
Args:
|
8 |
+
word (str): The input text to search through
|
9 |
+
letter (str): The letter to search for
|
10 |
+
|
11 |
+
Returns:
|
12 |
+
str: A message indicating how many times the letter appears
|
13 |
+
"""
|
14 |
+
word = word.lower()
|
15 |
+
letter = letter.lower()
|
16 |
+
count = word.count(letter)
|
17 |
+
return count
|
18 |
+
|
19 |
+
# Create and launch the Gradio interface
|
20 |
+
gr.Interface(
|
21 |
+
fn=letter_counter,
|
22 |
+
inputs=["textbox", "textbox"],
|
23 |
+
outputs="number",
|
24 |
+
title="Letter Counter",
|
25 |
+
description="Enter text and a letter to count how many times the letter appears in the text."
|
26 |
+
).launch(mcp_server=True)
|