MINHCT commited on
Commit
4604f63
β€’
1 Parent(s): 22da72a
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -111,13 +111,40 @@ def categorize(url):
111
  return {"error_message": error}
112
 
113
  # Main App
114
- url = st.text_input("enter your CNN's URL here")
 
 
 
 
 
 
 
 
 
 
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}")