# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
#Example of how basic sentiment analysis for articles will work:
import newspaper
import transformers
from transformers import pipeline

#Example website
website = 'https://www.afp.com/en/news-hub'
source = newspaper.build(website, memoize_articles=False)


# +
#populate and return a list of articles
def create_text_corpus(site_source):
    article_list = []
    for article_object in site_source.articles:
        if 'www.afp.com/en/' in article_object.url:
            article_object.download()
            article_object.parse()
            article_list.append(article_object.text)
    return article_list

text_list = create_text_corpus(source)

# +
#download sentiment analysis model and run on list

nlp = pipeline('sentiment-analysis')

def sentiment_analysis(lst):
    return nlp()

StarcoderdataJupyterScriptsDedupFiltered