Merge pull request #7 from yiiiq/pr-yi
Browse filesfix: handle Chrome/Kaleido dependency gracefully and correct README path
- README.md +5 -5
- src/streamlit_app.py +22 -4
README.md
CHANGED
|
@@ -67,19 +67,19 @@ For quick sentiment analysis:
|
|
| 67 |
|
| 68 |
```bash
|
| 69 |
# Basic usage
|
| 70 |
-
python cli_demo.py
|
| 71 |
|
| 72 |
# Custom search query
|
| 73 |
-
python cli_demo.py --query "ChatGPT" --days 3
|
| 74 |
|
| 75 |
# Filter to specific sources
|
| 76 |
-
python cli_demo.py --sources "techcrunch,wired" --max-articles 5
|
| 77 |
|
| 78 |
# Show only positive articles
|
| 79 |
-
python cli_demo.py --positive-only
|
| 80 |
|
| 81 |
# Show detailed sentiment analysis
|
| 82 |
-
python cli_demo.py --sentiment-only
|
| 83 |
```
|
| 84 |
|
| 85 |
#### CLI Options
|
|
|
|
| 67 |
|
| 68 |
```bash
|
| 69 |
# Basic usage
|
| 70 |
+
python src/cli_demo.py
|
| 71 |
|
| 72 |
# Custom search query
|
| 73 |
+
python src/cli_demo.py --query "ChatGPT" --days 3
|
| 74 |
|
| 75 |
# Filter to specific sources
|
| 76 |
+
python src/cli_demo.py --sources "techcrunch,wired" --max-articles 5
|
| 77 |
|
| 78 |
# Show only positive articles
|
| 79 |
+
python src/cli_demo.py --positive-only
|
| 80 |
|
| 81 |
# Show detailed sentiment analysis
|
| 82 |
+
python src/cli_demo.py --sentiment-only
|
| 83 |
```
|
| 84 |
|
| 85 |
#### CLI Options
|
src/streamlit_app.py
CHANGED
|
@@ -242,7 +242,13 @@ def main():
|
|
| 242 |
buf = io.BytesIO()
|
| 243 |
dist_fig.update_layout(template="plotly_white")
|
| 244 |
dist_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 设置白底
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
st.download_button("📷 Download Distribution Chart as PNG", buf.getvalue(),
|
| 247 |
"distribution_chart.png", mime="image/png")
|
| 248 |
st.download_button("🌐 Download Distribution Chart as HTML",
|
|
@@ -256,7 +262,13 @@ def main():
|
|
| 256 |
buf = io.BytesIO()
|
| 257 |
source_fig.update_layout(template="plotly_white")
|
| 258 |
source_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 白底
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
st.download_button("📷 Download Source Chart as PNG", buf.getvalue(),
|
| 261 |
"source_chart.png", mime="image/png")
|
| 262 |
st.download_button("🌐 Download Source Chart as HTML",
|
|
@@ -264,13 +276,19 @@ def main():
|
|
| 264 |
mime="text/html")
|
| 265 |
|
| 266 |
# Polarity Distribution
|
| 267 |
-
polarity_fig = create_polarity_distribution(df)
|
| 268 |
if polarity_fig:
|
| 269 |
st.plotly_chart(polarity_fig, use_container_width=True, key="polarity_fig")
|
| 270 |
buf = io.BytesIO()
|
| 271 |
polarity_fig.update_layout(template="plotly_white")
|
| 272 |
polarity_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 白底
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
st.download_button("📷 Download Polarity Chart as PNG", buf.getvalue(),
|
| 275 |
"polarity_chart.png", mime="image/png")
|
| 276 |
st.download_button("🌐 Download Polarity Chart as HTML",
|
|
|
|
| 242 |
buf = io.BytesIO()
|
| 243 |
dist_fig.update_layout(template="plotly_white")
|
| 244 |
dist_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 设置白底
|
| 245 |
+
try:
|
| 246 |
+
dist_fig.write_image(buf, format="png", engine="kaleido")
|
| 247 |
+
except RuntimeError:
|
| 248 |
+
# Fallback if Chrome/Kaleido not available
|
| 249 |
+
html_buf = io.StringIO()
|
| 250 |
+
dist_fig.write_html(html_buf)
|
| 251 |
+
buf = io.BytesIO(html_buf.getvalue().encode('utf-8'))
|
| 252 |
st.download_button("📷 Download Distribution Chart as PNG", buf.getvalue(),
|
| 253 |
"distribution_chart.png", mime="image/png")
|
| 254 |
st.download_button("🌐 Download Distribution Chart as HTML",
|
|
|
|
| 262 |
buf = io.BytesIO()
|
| 263 |
source_fig.update_layout(template="plotly_white")
|
| 264 |
source_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 白底
|
| 265 |
+
try:
|
| 266 |
+
source_fig.write_image(buf, format="png", engine="kaleido")
|
| 267 |
+
except RuntimeError:
|
| 268 |
+
# Fallback if Chrome/Kaleido not available
|
| 269 |
+
html_buf = io.StringIO()
|
| 270 |
+
source_fig.write_html(html_buf)
|
| 271 |
+
buf = io.BytesIO(html_buf.getvalue().encode('utf-8'))
|
| 272 |
st.download_button("📷 Download Source Chart as PNG", buf.getvalue(),
|
| 273 |
"source_chart.png", mime="image/png")
|
| 274 |
st.download_button("🌐 Download Source Chart as HTML",
|
|
|
|
| 276 |
mime="text/html")
|
| 277 |
|
| 278 |
# Polarity Distribution
|
| 279 |
+
polarity_fig = create_polarity_distribution(df, 0.1)
|
| 280 |
if polarity_fig:
|
| 281 |
st.plotly_chart(polarity_fig, use_container_width=True, key="polarity_fig")
|
| 282 |
buf = io.BytesIO()
|
| 283 |
polarity_fig.update_layout(template="plotly_white")
|
| 284 |
polarity_fig.update_layout(plot_bgcolor='white', paper_bgcolor='white') # 白底
|
| 285 |
+
try:
|
| 286 |
+
polarity_fig.write_image(buf, format="png", engine="kaleido")
|
| 287 |
+
except RuntimeError:
|
| 288 |
+
# Fallback if Chrome/Kaleido not available
|
| 289 |
+
html_buf = io.StringIO()
|
| 290 |
+
polarity_fig.write_html(html_buf)
|
| 291 |
+
buf = io.BytesIO(html_buf.getvalue().encode('utf-8'))
|
| 292 |
st.download_button("📷 Download Polarity Chart as PNG", buf.getvalue(),
|
| 293 |
"polarity_chart.png", mime="image/png")
|
| 294 |
st.download_button("🌐 Download Polarity Chart as HTML",
|