Christopherygk commited on
Commit
6622464
·
1 Parent(s): c13343f

Update README and mcp_server to reflect Gradio version 4.44.1 and enhance UI for text counting features

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. mcp_server.py +79 -14
  3. requirements.txt +1 -0
README.md CHANGED
@@ -4,8 +4,8 @@ emoji: 🔢
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: "4.0.0"
8
- app_file: mcp_server.py
9
  pinned: false
10
  ---
11
 
 
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: "4.44.1"
8
+ app_file: mcp_server.py
9
  pinned: false
10
  ---
11
 
mcp_server.py CHANGED
@@ -193,33 +193,98 @@ def count_syllables(word: str) -> int:
193
 
194
  with gr.Blocks() as demo:
195
  gr.Markdown("# Module for counting various text elements")
 
196
  with gr.Tab("Letter Counter"):
197
- gr.Interface(fn=count_letters, inputs="text", outputs="number")
 
 
 
 
 
198
  with gr.Tab("Word Counter"):
199
- gr.Interface(fn=count_words, inputs="text", outputs="number")
 
 
 
 
 
200
  with gr.Tab("Sentence Counter"):
201
- gr.Interface(fn=count_sentences, inputs="text", outputs="number")
 
 
 
 
 
202
  with gr.Tab("Paragraph Counter"):
203
- gr.Interface(fn=count_paragraphs, inputs="text", outputs="number")
 
 
 
 
 
204
  with gr.Tab("Vowel Counter"):
205
- gr.Interface(fn=count_vowels, inputs="text", outputs="number")
 
 
 
 
 
206
  with gr.Tab("Consonant Counter"):
207
- gr.Interface(fn=count_consonants, inputs="text", outputs="number")
 
 
 
 
 
208
  with gr.Tab("Special Character Counter"):
209
- gr.Interface(fn=count_special_characters, inputs="text", outputs="number")
 
 
 
 
 
210
  with gr.Tab("Digit Counter"):
211
- gr.Interface(fn=count_digits, inputs="text", outputs="number")
 
 
 
 
 
212
  with gr.Tab("Whitespace Counter"):
213
- gr.Interface(fn=count_whitespaces, inputs="text", outputs="number")
 
 
 
 
 
214
  with gr.Tab("Uppercase Letter Counter"):
215
- gr.Interface(fn=count_uppercase_letters, inputs="text", outputs="number")
 
 
 
 
 
216
  with gr.Tab("Lowercase Letter Counter"):
217
- gr.Interface(fn=count_lowercase_letters, inputs="text", outputs="number")
 
 
 
 
 
218
  with gr.Tab("Unique Word Counter"):
219
- gr.Interface(fn=count_unique_words, inputs="text", outputs="number")
 
 
 
 
 
220
  with gr.Tab("Syllable Counter"):
221
- gr.Interface(fn=count_syllables, inputs="text", outputs="number")
 
 
 
 
222
 
223
  if __name__ == "__main__":
224
- demo.launch(mcp_server=True)
225
 
 
193
 
194
  with gr.Blocks() as demo:
195
  gr.Markdown("# Module for counting various text elements")
196
+
197
  with gr.Tab("Letter Counter"):
198
+ with gr.Row():
199
+ text_input_1 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
200
+ result_output_1 = gr.Number(label="Letter Count")
201
+ count_btn_1 = gr.Button("Count Letters")
202
+ count_btn_1.click(fn=count_letters, inputs=text_input_1, outputs=result_output_1)
203
+
204
  with gr.Tab("Word Counter"):
205
+ with gr.Row():
206
+ text_input_2 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
207
+ result_output_2 = gr.Number(label="Word Count")
208
+ count_btn_2 = gr.Button("Count Words")
209
+ count_btn_2.click(fn=count_words, inputs=text_input_2, outputs=result_output_2)
210
+
211
  with gr.Tab("Sentence Counter"):
212
+ with gr.Row():
213
+ text_input_3 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
214
+ result_output_3 = gr.Number(label="Sentence Count")
215
+ count_btn_3 = gr.Button("Count Sentences")
216
+ count_btn_3.click(fn=count_sentences, inputs=text_input_3, outputs=result_output_3)
217
+
218
  with gr.Tab("Paragraph Counter"):
219
+ with gr.Row():
220
+ text_input_4 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
221
+ result_output_4 = gr.Number(label="Paragraph Count")
222
+ count_btn_4 = gr.Button("Count Paragraphs")
223
+ count_btn_4.click(fn=count_paragraphs, inputs=text_input_4, outputs=result_output_4)
224
+
225
  with gr.Tab("Vowel Counter"):
226
+ with gr.Row():
227
+ text_input_5 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
228
+ result_output_5 = gr.Number(label="Vowel Count")
229
+ count_btn_5 = gr.Button("Count Vowels")
230
+ count_btn_5.click(fn=count_vowels, inputs=text_input_5, outputs=result_output_5)
231
+
232
  with gr.Tab("Consonant Counter"):
233
+ with gr.Row():
234
+ text_input_6 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
235
+ result_output_6 = gr.Number(label="Consonant Count")
236
+ count_btn_6 = gr.Button("Count Consonants")
237
+ count_btn_6.click(fn=count_consonants, inputs=text_input_6, outputs=result_output_6)
238
+
239
  with gr.Tab("Special Character Counter"):
240
+ with gr.Row():
241
+ text_input_7 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
242
+ result_output_7 = gr.Number(label="Special Character Count")
243
+ count_btn_7 = gr.Button("Count Special Characters")
244
+ count_btn_7.click(fn=count_special_characters, inputs=text_input_7, outputs=result_output_7)
245
+
246
  with gr.Tab("Digit Counter"):
247
+ with gr.Row():
248
+ text_input_8 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
249
+ result_output_8 = gr.Number(label="Digit Count")
250
+ count_btn_8 = gr.Button("Count Digits")
251
+ count_btn_8.click(fn=count_digits, inputs=text_input_8, outputs=result_output_8)
252
+
253
  with gr.Tab("Whitespace Counter"):
254
+ with gr.Row():
255
+ text_input_9 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
256
+ result_output_9 = gr.Number(label="Whitespace Count")
257
+ count_btn_9 = gr.Button("Count Whitespaces")
258
+ count_btn_9.click(fn=count_whitespaces, inputs=text_input_9, outputs=result_output_9)
259
+
260
  with gr.Tab("Uppercase Letter Counter"):
261
+ with gr.Row():
262
+ text_input_10 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
263
+ result_output_10 = gr.Number(label="Uppercase Letter Count")
264
+ count_btn_10 = gr.Button("Count Uppercase Letters")
265
+ count_btn_10.click(fn=count_uppercase_letters, inputs=text_input_10, outputs=result_output_10)
266
+
267
  with gr.Tab("Lowercase Letter Counter"):
268
+ with gr.Row():
269
+ text_input_11 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
270
+ result_output_11 = gr.Number(label="Lowercase Letter Count")
271
+ count_btn_11 = gr.Button("Count Lowercase Letters")
272
+ count_btn_11.click(fn=count_lowercase_letters, inputs=text_input_11, outputs=result_output_11)
273
+
274
  with gr.Tab("Unique Word Counter"):
275
+ with gr.Row():
276
+ text_input_12 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
277
+ result_output_12 = gr.Number(label="Unique Word Count")
278
+ count_btn_12 = gr.Button("Count Unique Words")
279
+ count_btn_12.click(fn=count_unique_words, inputs=text_input_12, outputs=result_output_12)
280
+
281
  with gr.Tab("Syllable Counter"):
282
+ with gr.Row():
283
+ text_input_13 = gr.Textbox(label="Enter text", placeholder="Type your text here...")
284
+ result_output_13 = gr.Number(label="Syllable Count")
285
+ count_btn_13 = gr.Button("Count Syllables")
286
+ count_btn_13.click(fn=count_syllables, inputs=text_input_13, outputs=result_output_13)
287
 
288
  if __name__ == "__main__":
289
+ demo.launch()
290
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio>=4.44.1