Spaces:
Running
Running
Update UI
Browse files
app.py
CHANGED
@@ -111,13 +111,40 @@ def categorize(url):
|
|
111 |
return {"error_message": error}
|
112 |
|
113 |
# Main App
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
if url:
|
117 |
result = categorize(url)
|
118 |
article_content = result.get('Article_Content')
|
119 |
st.text_area("Article Content", value=article_content, height=400) # render the article content as textarea element
|
|
|
120 |
st.json({
|
121 |
"Logistic": result.get("Logistic_Predicted"),
|
122 |
"SVC": result.get("SVM_Predicted")
|
123 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
return {"error_message": error}
|
112 |
|
113 |
# Main App
|
114 |
+
with st.expander("See explanation"): # Explain to user why this project is only worked for CNN domain
|
115 |
+
st.write(
|
116 |
+
'''
|
117 |
+
This project works best with CNN articles right now.
|
118 |
+
Our web crawler is like a special tool for CNN's website.
|
119 |
+
It can't quite understand other websites because they're built differently
|
120 |
+
'''
|
121 |
+
)
|
122 |
+
|
123 |
+
url = st.text_input("Paste your CNN Article's URL Here")
|
124 |
+
|
125 |
|
126 |
if url:
|
127 |
result = categorize(url)
|
128 |
article_content = result.get('Article_Content')
|
129 |
st.text_area("Article Content", value=article_content, height=400) # render the article content as textarea element
|
130 |
+
st.divider() # π Draws a horizontal rule
|
131 |
st.json({
|
132 |
"Logistic": result.get("Logistic_Predicted"),
|
133 |
"SVC": result.get("SVM_Predicted")
|
134 |
+
})
|
135 |
+
st.divider() # π Draws a horizontal rule
|
136 |
+
|
137 |
+
# Category labels and corresponding counts
|
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}")
|