mobrown commited on
Commit
25a5b44
·
verified ·
1 Parent(s): c1d8393

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -91
app.py DELETED
@@ -1,91 +0,0 @@
1
- import gradio as gr
2
-
3
- # Example texts
4
- example_texts = {
5
- "Basic Text": "Once in a small town, there was a lemonade stand run by a young girl named Mia. Her lemonade was famous for being the most refreshing drink on hot summer days. Her friend Joe asked if he could invest in her business. With Joe's funds, Mia was able to open 5 new stands.",
6
- "Nvidia Earnings": "Q4 was another record quarter. Revenue of $22.1 billion was up 22% sequentially and up to 265% year-on-year and well above our outlook of $20 billion. For fiscal 2024, revenue was $60.9 billion and up 126% from the prior year. Starting with data center. Data center revenue for the fiscal 2024 year was $47.5 billion, more than tripling from the prior year. The world has reached the tipping point of new computing era. The $1 trillion installed base of data center infrastructure is rapidly transitioning from general purpose to accelerated computing. As Moore's Law slows while computing demand continues to skyrocket, companies may accelerate every workload possible to drive future improvement in performance, TCO and energy efficiency."
7
- }
8
-
9
-
10
- def get_readability_level(fog_index):
11
- if fog_index < 2:
12
- return "First Grade Level"
13
- elif fog_index < 3:
14
- return "Second Grade Level"
15
- elif fog_index < 4:
16
- return "Third Grade Level"
17
- elif fog_index < 5:
18
- return "Fourth Grade Level"
19
- elif fog_index < 6:
20
- return "Fifth Grade Level"
21
- elif fog_index < 7:
22
- return "Sixth Grade Level"
23
- elif fog_index < 8:
24
- return "Seventh Grade Level"
25
- elif fog_index < 9:
26
- return "Eight Grade Level"
27
- elif fog_index < 10:
28
- return "High School Freshman Level"
29
- elif fog_index < 11:
30
- return "High School Sophomore Level"
31
- elif fog_index < 12:
32
- return "High School Junior Level"
33
- elif fog_index < 13:
34
- return "High School Senior Level"
35
- elif fog_index < 14:
36
- return "College Freshman Level"
37
- elif fog_index < 15:
38
- return "College Sophomore Level"
39
- elif fog_index < 16:
40
- return "College Junior Level"
41
- elif fog_index < 17:
42
- return "College Senior Level"
43
- else:
44
- return "Graduate School Level"
45
-
46
-
47
- def calculate_fog_index(text):
48
- if not text.strip(): # If the text is empty or only whitespace, return a placeholder
49
- return "Enter text to see the Fog Index and readability level."
50
- # Split text into sentences and words
51
- sentences = text.split('.')
52
- words = text.split()
53
- complex_words = [word for word in words if len(word) > 7] # Simplified definition for complex words
54
-
55
- # Calculate Gunning Fog Index
56
- average_sentence_length = len(words) / max(len(sentences), 1) # Avoid division by zero
57
- percentage_complex_words = (len(complex_words) / max(len(words), 1)) * 100 # Avoid division by zero
58
- fog_index = 0.4 * (average_sentence_length + percentage_complex_words)
59
-
60
- readability_level = get_readability_level(fog_index)
61
-
62
- return f"Fog Index: {fog_index:.2f}. Readability is at the {readability_level}."
63
-
64
-
65
- def update_text_area(choice):
66
- # Update the text area with the selected example text or clear it for custom text
67
- return example_texts.get(choice, "")
68
-
69
-
70
- css = ".label-chicago { text-align: right; width: 100%; font-size: 0.75em; margin-top: 20px; } \
71
- .instructions { font-size: 1.25em; font-weight: bold; }"
72
-
73
- with gr.Blocks(css=css) as app:
74
- gr.Markdown(
75
- "<div class='instructions'>"
76
- "Start by using the buttons to select a text sample or enter your custom text.<br>"
77
- "The Fog Index and readability level will update automatically."
78
- "</div>"
79
- )
80
- choice = gr.Radio(choices=["Basic Text", "Nvidia Earnings", "Custom Text"], label="Select Text", value="")
81
- analyze_text_area = gr.TextArea(label="Analyze Text", lines=10,
82
- placeholder="Select an example text or enter your custom text here.",
83
- interactive=True)
84
- fog_index_display = gr.Label()
85
-
86
- choice.change(update_text_area, inputs=[choice], outputs=[analyze_text_area])
87
- analyze_text_area.change(calculate_fog_index, inputs=[analyze_text_area], outputs=[fog_index_display])
88
-
89
- gr.Markdown("<div class='label-chicago'>App by Monika Brown</div>")
90
-
91
- app.launch(share=True)