| import streamlit as st |
| import feedparser |
| from transformers import pipeline |
|
|
| st.set_page_config(page_title="๐ฎ๐ณ BharatPulse", layout="wide") |
|
|
| |
| @st.cache_resource |
| def load_summarizer(): |
| return pipeline("summarization", model="facebook/bart-large-cnn") |
|
|
| summarizer = load_summarizer() |
|
|
| |
| NEWS_FEEDS = { |
| "NDTV": "https://feeds.feedburner.com/ndtvnews-top-stories", |
| "India Today": "https://www.indiatoday.in/rss/home", |
| "The Hindu": "https://www.thehindu.com/news/national/feeder/default.rss" |
| } |
|
|
| |
| st.title("๐ฎ๐ณ BharatPulse") |
| st.subheader("Live News Feeds & Public Sentiment Collector (MVP)") |
|
|
| |
| source = st.selectbox("๐ฐ Choose News Source", list(NEWS_FEEDS.keys())) |
| feed = feedparser.parse(NEWS_FEEDS[source]) |
|
|
| st.markdown("### ๐๏ธ Latest News Headlines from India") |
| for entry in feed.entries[:5]: |
| st.write(f"**๐๏ธ {entry.title}**") |
| st.write(entry.published) |
| st.markdown(f"[Read more]({entry.link})", unsafe_allow_html=True) |
| if st.button(f"๐ Summarize: {entry.title}"): |
| with st.spinner("Summarizing..."): |
| summary = summarizer(entry.summary[:1024], max_length=100, min_length=30, do_sample=False)[0]['summary_text'] |
| st.success(summary) |
| st.markdown("---") |
|
|
| |
| st.markdown("## ๐ฃ Share Your Voice โ Public Sentiment Collector") |
| with st.form("sentiment_form"): |
| name = st.text_input("Your Name (Optional)", "") |
| region = st.text_input("Your Region / State") |
| language = st.text_input("Language") |
| topic = st.text_input("Topic") |
| sentiment = st.radio("Sentiment", ["Positive", "Negative", "Neutral"]) |
| message = st.text_area("Your Message (in your local language or English)") |
| submitted = st.form_submit_button("Submit") |
|
|
| if submitted: |
| st.success("โ
Thank you for sharing your opinion!") |
| st.markdown(f"**Name:** {name or 'Anonymous'}") |
| st.markdown(f"**Region:** {region}, **Language:** {language}, **Topic:** {topic}") |
| st.markdown(f"**Sentiment:** {sentiment}") |
| st.markdown(f"**Message:** {message}") |
|
|