Jake-seong commited on
Commit
1d79b3a
·
verified ·
1 Parent(s): 08950d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,23 +1,28 @@
1
  import gradio as gr
2
 
3
  def letter_counter(word, letter):
4
- """Count the occurrences of a specific letter in a word.
5
-
 
6
  Args:
7
- word: The word or phrase to analyze
8
- letter: The letter to count occurrences of
9
-
10
  Returns:
11
- The number of times the letter appears in the word
12
  """
13
- return word.lower().count(letter.lower())
 
 
 
14
 
15
  demo = gr.Interface(
16
  fn=letter_counter,
17
- inputs=["text", "text"],
18
  outputs="number",
19
  title="Letter Counter",
20
- description="Count how many times a letter appears in a word"
21
  )
22
 
23
- demo.launch(mcp_server=True)
 
 
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
  demo = gr.Interface(
20
  fn=letter_counter,
21
+ inputs=["textbox", "textbox"],
22
  outputs="number",
23
  title="Letter Counter",
24
+ description="Enter text and a letter to count how many times the letter appears in the text."
25
  )
26
 
27
+ if __name__ == "__main__":
28
+ demo.launch(mcp_server=True)