budhil commited on
Commit
ecf4c8b
·
1 Parent(s): 25c4256

Initial Gradio text analyzer app

Browse files
Files changed (3) hide show
  1. README.md +10 -1
  2. app.py +37 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -10,4 +10,13 @@ pinned: false
10
  license: mit
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
10
  license: mit
11
  ---
12
 
13
+ # 📝 Text Analyzer
14
+
15
+ A simple Gradio app deployed on Hugging Face Spaces.
16
+
17
+ ## Features
18
+ - Word count
19
+ - Character count
20
+ - Estimated reading time
21
+
22
+ Built with ❤️ using Gradio.
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def analyze_text(text):
4
+ if not text.strip():
5
+ return 0, 0, "0 min"
6
+
7
+ words = len(text.split())
8
+ characters = len(text)
9
+ reading_time_minutes = max(1, words // 200) # ~200 wpm
10
+
11
+ return words, characters, f"{reading_time_minutes} min"
12
+
13
+
14
+ with gr.Blocks(title="Text Analyzer") as demo:
15
+ gr.Markdown("# 📝 Text Analyzer")
16
+ gr.Markdown("Analyze your text instantly using Gradio + Hugging Face Spaces.")
17
+
18
+ text_input = gr.Textbox(
19
+ label="Enter your text",
20
+ placeholder="Paste or type your text here...",
21
+ lines=6
22
+ )
23
+
24
+ analyze_btn = gr.Button("Analyze")
25
+
26
+ with gr.Row():
27
+ word_count = gr.Number(label="Word Count")
28
+ char_count = gr.Number(label="Character Count")
29
+ read_time = gr.Textbox(label="Estimated Reading Time")
30
+
31
+ analyze_btn.click(
32
+ fn=analyze_text,
33
+ inputs=text_input,
34
+ outputs=[word_count, char_count, read_time]
35
+ )
36
+
37
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==6.5.1