Executing black over all jupyter notebook (#190)

Reverting black for the jupyter notebooks gets old. Can we just run
black over all of them?
This commit is contained in:
2023-10-04 20:03:47 +02:00
committed by GitHub
parent 030ad00c7d
commit 41f2c9f995
15 changed files with 658 additions and 487 deletions

View File

@ -82,7 +82,7 @@
"# Download the lexicon\n",
"nltk.download(\"vader_lexicon\")\n",
"\n",
"# Import the lexicon \n",
"# Import the lexicon\n",
"from nltk.sentiment.vader import SentimentIntensityAnalyzer\n",
"\n",
"# Create an instance of SentimentIntensityAnalyzer\n",
@ -132,12 +132,22 @@
"text_df = pd.DataFrame(\n",
" [\n",
" {\"text\": \"Microsoft fails to hit profit expectations.\"},\n",
" {\"text\": \"Confidence continues to prevail on the stock market, as the performance of the DAX shows.\"},\n",
" {\n",
" \"text\": \"Confidence continues to prevail on the stock market, as the performance of the DAX shows.\"\n",
" },\n",
" {\"text\": \"Stocks rallied and the British pound gained.\"},\n",
" {\"text\": \"Meyer Burger now serves Australian market and presents itself at Smart Energy Expo in Sydney.\"},\n",
" {\"text\": \"Meyer Burger enters Australian market and exhibits at Smart Energy Expo in Sydney.\"},\n",
" {\"text\": \"J&T Express Vietnam helps local craft villages increase their reach.\"},\n",
" {\"text\": \"7 experts recommend the stock for purchase, 1 expert recommends holding the stock.\"},\n",
" {\n",
" \"text\": \"Meyer Burger now serves Australian market and presents itself at Smart Energy Expo in Sydney.\"\n",
" },\n",
" {\n",
" \"text\": \"Meyer Burger enters Australian market and exhibits at Smart Energy Expo in Sydney.\"\n",
" },\n",
" {\n",
" \"text\": \"J&T Express Vietnam helps local craft villages increase their reach.\"\n",
" },\n",
" {\n",
" \"text\": \"7 experts recommend the stock for purchase, 1 expert recommends holding the stock.\"\n",
" },\n",
" {\"text\": \"Microsoft share falls.\"},\n",
" {\"text\": \"Microsoft share is rising.\"},\n",
" ]\n",
@ -262,22 +272,21 @@
],
"source": [
"def format_output(output_dict):\n",
" \n",
" polarity = \"neutral\"\n",
" polarity = \"neutral\"\n",
"\n",
" if(output_dict['compound']>= 0.05):\n",
" polarity = \"positive\"\n",
" if output_dict[\"compound\"] >= 0.05:\n",
" polarity = \"positive\"\n",
"\n",
" elif(output_dict['compound']<= -0.05):\n",
" polarity = \"negative\"\n",
" elif output_dict[\"compound\"] <= -0.05:\n",
" polarity = \"negative\"\n",
"\n",
" return polarity\n",
" return polarity\n",
"\n",
"\n",
"def predict_sentiment(text):\n",
" \n",
" output_dict = sent_analyzer.polarity_scores(text)\n",
" return output_dict\n",
" output_dict = sent_analyzer.polarity_scores(text)\n",
" return output_dict\n",
"\n",
"\n",
"# Run the predictions\n",
"text_df[\"vader_prediction\"] = text_df[\"text\"].apply(predict_sentiment)\n",