Spaces:
Running
Running
Update UI
Browse files
app.py
CHANGED
@@ -111,7 +111,53 @@ def categorize(url):
|
|
111 |
return {"error_message": error}
|
112 |
|
113 |
# Main App
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
st.write(
|
116 |
'''
|
117 |
This project works best with CNN articles right now.
|
@@ -120,8 +166,9 @@ with st.expander("See explanation"): # Explain to user why this project is only
|
|
120 |
'''
|
121 |
)
|
122 |
|
123 |
-
url = st.text_input("
|
124 |
|
|
|
125 |
|
126 |
if url:
|
127 |
result = categorize(url)
|
@@ -138,13 +185,13 @@ st.divider() # π Draws a horizontal rule
|
|
138 |
categories = ["Sport", "Health", "Entertainment", "Politics", "Business"]
|
139 |
counts = [5638, 4547, 2658, 2461, 1362]
|
140 |
|
141 |
-
# Create the bar chart
|
142 |
-
st.bar_chart(data=dict(zip(categories, counts)))
|
143 |
-
|
144 |
# Optional: Add a chart title
|
145 |
st.title("Training Data Category Distribution")
|
146 |
|
147 |
# Optional: Display additional information
|
148 |
st.write("Here's a breakdown of the number of articles in each category:")
|
149 |
for category, count in zip(categories, counts):
|
150 |
-
st.write(f"- {category}: {count}")
|
|
|
|
|
|
|
|
111 |
return {"error_message": error}
|
112 |
|
113 |
# Main App
|
114 |
+
st.header('Classification Project')
|
115 |
+
st.subheader
|
116 |
+
(
|
117 |
+
'''
|
118 |
+
Unsure what category a CNN article belongs to?
|
119 |
+
Our clever tool can help!
|
120 |
+
Paste the URL below and press Enter. We'll sort it into one of our 5 categories in a flash! β‘οΈ
|
121 |
+
'''
|
122 |
+
)
|
123 |
+
|
124 |
+
# Define category information (modify content and bullet points as needed)
|
125 |
+
categories = {
|
126 |
+
"Business": [
|
127 |
+
"Analyze market trends and investment opportunities.",
|
128 |
+
"Gain insights into company performance and industry news.",
|
129 |
+
"Stay informed about economic developments and regulations."
|
130 |
+
],
|
131 |
+
"Health": [
|
132 |
+
"Discover healthy recipes and exercise tips.",
|
133 |
+
"Learn about the latest medical research and advancements.",
|
134 |
+
"Find resources for managing chronic conditions and improving well-being."
|
135 |
+
],
|
136 |
+
"Sport": [
|
137 |
+
"Follow your favorite sports teams and athletes.",
|
138 |
+
"Explore news and analysis from various sports categories.",
|
139 |
+
"Stay updated on upcoming games and competitions."
|
140 |
+
],
|
141 |
+
"Politics": [
|
142 |
+
"Get informed about current political events and policies.",
|
143 |
+
"Understand different perspectives on political issues.",
|
144 |
+
"Engage in discussions and debates about politics."
|
145 |
+
],
|
146 |
+
"Entertainment": [
|
147 |
+
"Find recommendations for movies, TV shows, and music.",
|
148 |
+
"Explore reviews and insights from entertainment critics.",
|
149 |
+
"Stay updated on celebrity news and cultural trends."
|
150 |
+
]
|
151 |
+
}
|
152 |
+
# Create expanders contain list of category can be classified
|
153 |
+
for category, content in categories.items():
|
154 |
+
with st.expander(category, expanded=True):
|
155 |
+
# Display content as bullet points
|
156 |
+
for item in content:
|
157 |
+
st.write(f"- {item}")
|
158 |
+
|
159 |
+
# Explain to user why this project is only worked for CNN domain
|
160 |
+
with st.expander("Tips", expanded=True):
|
161 |
st.write(
|
162 |
'''
|
163 |
This project works best with CNN articles right now.
|
|
|
166 |
'''
|
167 |
)
|
168 |
|
169 |
+
url = st.text_input("Find your favorite CNN story! Paste the URL here.", placeholder='Ex: https://edition.cnn.com/2012/01/31/health/frank-njenga-mental-health/index.html')
|
170 |
|
171 |
+
st.divider() # π Draws a horizontal rule
|
172 |
|
173 |
if url:
|
174 |
result = categorize(url)
|
|
|
185 |
categories = ["Sport", "Health", "Entertainment", "Politics", "Business"]
|
186 |
counts = [5638, 4547, 2658, 2461, 1362]
|
187 |
|
|
|
|
|
|
|
188 |
# Optional: Add a chart title
|
189 |
st.title("Training Data Category Distribution")
|
190 |
|
191 |
# Optional: Display additional information
|
192 |
st.write("Here's a breakdown of the number of articles in each category:")
|
193 |
for category, count in zip(categories, counts):
|
194 |
+
st.write(f"- {category}: {count}")
|
195 |
+
|
196 |
+
# Create the bar chart
|
197 |
+
st.bar_chart(data=dict(zip(categories, counts)))
|