From c6f739bb448ccc15e2e1e1402d3a304f32939c1e Mon Sep 17 00:00:00 2001 From: hasseekman Date: Wed, 16 Apr 2025 15:48:01 +0200 Subject: [PATCH 1/5] Create final_project --- final_project | 1 + 1 file changed, 1 insertion(+) create mode 100644 final_project diff --git a/final_project b/final_project new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/final_project @@ -0,0 +1 @@ + From b6477ee5882ecaec51402d5230e66d14cb132940 Mon Sep 17 00:00:00 2001 From: hasseekman Date: Wed, 16 Apr 2025 16:00:20 +0200 Subject: [PATCH 2/5] Delete final_project --- final_project | 1 - 1 file changed, 1 deletion(-) delete mode 100644 final_project diff --git a/final_project b/final_project deleted file mode 100644 index 8b1378917..000000000 --- a/final_project +++ /dev/null @@ -1 +0,0 @@ - From e59d0c9dc5ed7c4196e110ac61520eb63435a9d9 Mon Sep 17 00:00:00 2001 From: hasseekman Date: Wed, 16 Apr 2025 16:02:26 +0200 Subject: [PATCH 3/5] Create README.md --- final_project/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 final_project/README.md diff --git a/final_project/README.md b/final_project/README.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/final_project/README.md @@ -0,0 +1 @@ + From 42906e119a0cb003db0749b201d4558164f53ae2 Mon Sep 17 00:00:00 2001 From: hasseekman Date: Wed, 16 Apr 2025 16:11:33 +0200 Subject: [PATCH 4/5] Create emotion_detection.py --- final_project/emotion_detection.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 final_project/emotion_detection.py diff --git a/final_project/emotion_detection.py b/final_project/emotion_detection.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/final_project/emotion_detection.py @@ -0,0 +1 @@ + From bbaeb3f5abf0965cd197e4d18bc0c01d5d6e0034 Mon Sep 17 00:00:00 2001 From: hasseekman Date: Wed, 16 Apr 2025 17:33:29 +0200 Subject: [PATCH 5/5] Update emotion_detection.py --- final_project/emotion_detection.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/final_project/emotion_detection.py b/final_project/emotion_detection.py index 8b1378917..47a20e472 100644 --- a/final_project/emotion_detection.py +++ b/final_project/emotion_detection.py @@ -1 +1,16 @@ +import requests +def emotion_detector(text_to_analyze): + url = 'https://sn-watson-emotion.labs.skills.network/v1/watson.runtime.nlp.v1/NlpService/EmotionPredict' + headers = { + "Content-Type": "application/json", + "grpc-metadata-mm-model-id": "emotion_aggregated-workflow_lang_en_stock" + } + input_json = { "raw_document": { "text": text_to_analyze } } + + response = requests.post(url, json=input_json, headers=headers) + if response.status_code == 200: + result = response.json() + return result['emotionPredictions'][0]['emotion'] + else: + return f"Request failed with status code: {response.status_code}"