|
import os |
|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
auth_token = os.environ.get("TOKEN_FROM_SECRET") or True |
|
|
|
pipe = pipeline("text-classification", model="ogozcelik/bert-base-turkish-fake-news", token=auth_token) |
|
|
|
st.title("Turkish Fake News Detector") |
|
st.markdown( |
|
""" |
|
This application determines the accuracy of claims shared on social media since 2020 through Turkish Twitter texts. |
|
When you test facts that are already known to be true (such as the Earth being round), you may get misleading answers. |
|
""" |
|
) |
|
st.write("\n\n") |
|
|
|
|
|
def print_result(user_input): |
|
result = pipe(user_input) |
|
veracity = result[0]["label"] |
|
confidence = result[0]["score"] |
|
return veracity, confidence |
|
|
|
st.markdown("Enter a tweet or short statement to detect its truthfulness:") |
|
user_input = st.text_input("") |
|
|
|
if st.button('Predict Truthfulness'): |
|
with st.spinner('Processing...'): |
|
veracity, confidence = print_result(user_input) |
|
st.success(f"Truthfulness: {veracity}") |
|
st.write(f"Confidence: The model is {(confidence*100):.2f}% sure about the result.") |