news-analyzer / app.py
elozano's picture
First Model Version
d6a25c5
raw
history blame
1.22 kB
import streamlit as st
from news_pipeline import NewsPipeline
CATEGORY_EMOJIS = {
"Automobile": "πŸš—",
"Entertainment": "🍿",
"Politics": "βš–οΈ",
"Science": "πŸ§ͺ",
"Sports": "πŸ€",
"Technology": "πŸ’»",
"World": "🌍",
}
FAKE_EMOJIS = {"Fake": "πŸ‘»", "Real": "πŸ‘"}
CLICKBAIT_EMOJIS = {"Clickbait": "🎣", "Normal": "βœ…"}
def app():
news_pipe = NewsPipeline()
st.title("πŸ“° News Analyzer")
headline = st.text_input("Article headline:")
content = st.text_area("Article content:")
button = st.button("Analyze")
if button:
with st.spinner("Analyzing article..."):
prediction = news_pipe(headline, content)
st.success("Article successfully analyzed!")
st.markdown(
f"{CATEGORY_EMOJIS[prediction['category']]} **Category**: {prediction['category']}"
)
st.markdown(
f"{FAKE_EMOJIS[prediction['fake']]} **Fake**: {'Yes' if prediction['fake'] == 'Fake' else 'No'}"
)
st.markdown(
f"{CLICKBAIT_EMOJIS[prediction['clickbait']]} **Clickbait**: {'Yes' if prediction['clickbait'] == 'Clickbait' else 'No'}"
)
if __name__ == "__main__":
app()