Spaces:
Configuration error
Configuration error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -55,6 +55,14 @@ def count_pattern(text, pattern):
|
|
| 55 |
return "0"
|
| 56 |
return str(len(re.findall(pattern, text)))
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
with gr.Blocks(title="Text Analyzer", theme=gr.themes.Soft()) as demo:
|
| 59 |
gr.Markdown("# ๐ Text Analyzer & Processing Tool")
|
| 60 |
gr.Markdown("Analyze, process, and extract insights from your text.")
|
|
@@ -94,10 +102,6 @@ with gr.Blocks(title="Text Analyzer", theme=gr.themes.Soft()) as demo:
|
|
| 94 |
gr.Markdown("---")
|
| 95 |
gr.Markdown("### ๐ Sample Texts")
|
| 96 |
|
| 97 |
-
sample1 = "The quick brown fox jumps over the lazy dog. This is a great example of text analysis. The fox is very quick and agile."
|
| 98 |
-
sample2 = "I love programming! Python is amazing and wonderful. The best language ever created."
|
| 99 |
-
sample3 = "This is terrible and awful. I hate this so much. The worst experience of my life."
|
| 100 |
-
|
| 101 |
with gr.Row():
|
| 102 |
sample_btn1 = gr.Button("Load Sample 1")
|
| 103 |
sample_btn2 = gr.Button("Load Sample 2")
|
|
@@ -121,9 +125,9 @@ with gr.Blocks(title="Text Analyzer", theme=gr.themes.Soft()) as demo:
|
|
| 121 |
outputs=[pattern_output]
|
| 122 |
)
|
| 123 |
|
| 124 |
-
sample_btn1.click(fn=lambda:
|
| 125 |
-
sample_btn2.click(fn=lambda:
|
| 126 |
-
sample_btn3.click(fn=lambda:
|
| 127 |
|
| 128 |
if __name__ == "__main__":
|
| 129 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 55 |
return "0"
|
| 56 |
return str(len(re.findall(pattern, text)))
|
| 57 |
|
| 58 |
+
def load_sample(sample_num):
|
| 59 |
+
samples = {
|
| 60 |
+
1: "The quick brown fox jumps over the lazy dog. This is a great example of text analysis. The fox is very quick and agile.",
|
| 61 |
+
2: "I love programming! Python is amazing and wonderful. The best language ever created.",
|
| 62 |
+
3: "This is terrible and awful. I hate this so much. The worst experience of my life."
|
| 63 |
+
}
|
| 64 |
+
return samples.get(sample_num, "")
|
| 65 |
+
|
| 66 |
with gr.Blocks(title="Text Analyzer", theme=gr.themes.Soft()) as demo:
|
| 67 |
gr.Markdown("# ๐ Text Analyzer & Processing Tool")
|
| 68 |
gr.Markdown("Analyze, process, and extract insights from your text.")
|
|
|
|
| 102 |
gr.Markdown("---")
|
| 103 |
gr.Markdown("### ๐ Sample Texts")
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
with gr.Row():
|
| 106 |
sample_btn1 = gr.Button("Load Sample 1")
|
| 107 |
sample_btn2 = gr.Button("Load Sample 2")
|
|
|
|
| 125 |
outputs=[pattern_output]
|
| 126 |
)
|
| 127 |
|
| 128 |
+
sample_btn1.click(fn=lambda: load_sample(1), outputs=[text_input])
|
| 129 |
+
sample_btn2.click(fn=lambda: load_sample(2), outputs=[text_input])
|
| 130 |
+
sample_btn3.click(fn=lambda: load_sample(3), outputs=[text_input])
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|