Skip to content

Commit

Permalink
feat: get data and run sentiment
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Feb 7, 2024
1 parent 19434d2 commit a9ef0b7
Showing 1 changed file with 258 additions and 0 deletions.
258 changes: 258 additions & 0 deletions News API/News_API_Run_sentiment_analysis.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "formed-general",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"<img width=\"8%\" alt=\"Newsapi.png\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Newsapi.png\" style=\"border-radius: 15%\">"
]
},
{
"cell_type": "markdown",
"id": "immune-senator",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"# News API - Run sentiment analysis\n",
"<a href=\"https://app.naas.ai/user-redirect/naas/downloader?url=https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/Newsapi/Newsapi_Run_sentiment_analysis.ipynb\" target=\"_parent\"><img src=\"https://naasai-public.s3.eu-west-3.amazonaws.com/Open_in_Naas_Lab.svg\"/></a><br><br><a href=\"https://bit.ly/3JyWIk6\">Give Feedback</a> | <a href=\"https://github.com/jupyter-naas/awesome-notebooks/issues/new?assignees=&labels=bug&template=bug_report.md&title=Newsapi+-+Run+sentiment+analysis:+Error+short+description\">Bug report</a>"
]
},
{
"cell_type": "markdown",
"id": "aac8c98b-f9bc-42c7-aac6-f15611775fd2",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Tags:** #newsapi #news #sentimentanalysis #ai #opendata #dataframe"
]
},
{
"cell_type": "markdown",
"id": "naas-author",
"metadata": {
"papermill": {},
"tags": [
"naas"
]
},
"source": [
"**Author:** [Jeremy Ravenel](https://www.linkedin.com/in/ACoAAAJHE7sB5OxuKHuzguZ9L6lfDHqw--cdnJg/)"
]
},
{
"cell_type": "markdown",
"id": "e52ca3be-7ea8-414a-ac4b-8adc780de3ec",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Last update:** 2024-02-07 (Created: 2021-05-10)"
]
},
{
"cell_type": "markdown",
"id": "naas-description",
"metadata": {
"papermill": {},
"tags": [
"description"
]
},
"source": [
"**Description:** This notebook uses News API to analyze the sentiment of news articles."
]
},
{
"cell_type": "markdown",
"id": "input_cell",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "import_cell",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "confirmed-stability",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"from naas_drivers import newsapi, sentiment"
]
},
{
"cell_type": "markdown",
"id": "model_cell",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Model"
]
},
{
"cell_type": "markdown",
"id": "836b1730-0a70-4917-9ac8-3e99ef20413b",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Connect to newsAPI and get the data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "european-greensboro",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"data = newsapi.connect().get(\n",
" \"bitcoin\",\n",
" fields=[\"title\", \"image\", \"link\", \"description\"]\n",
")"
]
},
{
"cell_type": "markdown",
"id": "44162e80-99b4-46d4-9ae7-c80f9ff6fdf7",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Get sentiment analysis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "characteristic-loading",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"sentiment = sentiment.get(data, column_name=\"title\")"
]
},
{
"cell_type": "markdown",
"id": "output_cell",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Output"
]
},
{
"cell_type": "markdown",
"id": "display_cell",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Display results"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "direct-saver",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "likely-citizenship",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"sentiment"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
},
"naas": {
"notebook_id": "8c7a4d82d6c655fc8c32095c16c53da8d6a524084ffa01fc55f762ffe5e37c8b",
"notebook_path": "Newsapi/Newsapi_Run_sentiment_analysis.ipynb"
},
"papermill": {
"default_parameters": {},
"environment_variables": {},
"parameters": {},
"version": "2.3.3"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit a9ef0b7

Please sign in to comment.