torileatherman's picture
Update app.py
378829d
raw
history blame
1.29 kB
import gradio as gr
import hopsworks
from datasets import load_dataset
import pandas as pd
project = hopsworks.login()
fs = project.get_feature_store()
dataset_api = project.get_dataset_api()
dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions")
predictions_df = pd.DataFrame(dataset,columns=['Headlines_seq', 'URL','Headline_str','Predictions'])
predictions_df_url0 = predictions_df['URL'].iloc[1]
predictions_df_url1 = predictions_df['URL'].iloc[2]
predictions_df_url2 = predictions_df['URL'].iloc[3]
def article_selection(sentiment):
if sentiment == "Positive":
return predictions_df_url0, predictions_df_url1, predictions_df_url2 #f"""The sentence you requested is Positive!"""
elif sentiment == "Negative":
return f"""The sentence you requested is Negative!"""
else:
return f"""The sentence you requested is Neutral!"""
demo = gr.Interface(
fn=article_selection,
inputs = gr.Dropdown(["Positive","Negative","Neutral"], label="What type of news articles would you like recommended?"),
outputs = [gr.Textbox(label="Sentiment of News Articles")],
)
#TODO
#demo = gr.TabbedInterface([url_demo, voice_demo], ["Swedish YouTube Video to English Text", "Swedish Audio to English Text"])
demo.launch()