From 5330ae93fc751f23a25df7cda0c870807d20d730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Sat, 23 Sep 2023 00:25:16 +0200 Subject: [PATCH] remove senticnet: API is down --- .../sentiment/basic/sentiment-basic.py | 2 +- senpy/plugins/sentiment/senticnet_plugin.py | 87 ------------------- 2 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 senpy/plugins/sentiment/senticnet_plugin.py diff --git a/senpy/plugins/sentiment/basic/sentiment-basic.py b/senpy/plugins/sentiment/basic/sentiment-basic.py index 60e2af2..b639e2d 100644 --- a/senpy/plugins/sentiment/basic/sentiment-basic.py +++ b/senpy/plugins/sentiment/basic/sentiment-basic.py @@ -39,7 +39,7 @@ class SentimentBasic(SentimentBox): pos_path = "unigram_spanish.pickle" maxPolarityValue = 1 minPolarityValue = -1 - nltk_resources = ['punkt','wordnet', 'omw'] + nltk_resources = ['punkt','wordnet', 'omw', 'omw-1.4'] with_polarity = False diff --git a/senpy/plugins/sentiment/senticnet_plugin.py b/senpy/plugins/sentiment/senticnet_plugin.py deleted file mode 100644 index 200634a..0000000 --- a/senpy/plugins/sentiment/senticnet_plugin.py +++ /dev/null @@ -1,87 +0,0 @@ -# -# Copyright 2014 Grupo de Sistemas Inteligentes (GSI) DIT, UPM -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests -import json - -from senpy.plugins import SentimentBox -from senpy import easy_test - -ENDPOINT = 'http://sentiment.gelbukh.com/sentiment/run.php' - - -class Senticnet(SentimentBox): - '''Connects to the SenticNet free polarity detection API: http://sentiment.gelbukh.com/sentiment/''' - - author = "@balkian" - version = '0.1' - url = "https://github.com/gsi-upm/senpy-plugins-community" - extra_params = { - } - - classes = ['marl:Positive', 'marl:Neutral', 'marl:Negative'] - binary = True - - def predict_one(self, features, activity): - text = ' '.join(features) - - res = requests.post(ENDPOINT, - data={'input': text}) - - if '-' not in res.text: - raise Exception('Invalid response from server: {}'.format(res.text)) - - label = res.text.split('-')[1].lower() - - if 'positive' in label: - return [1, 0, 0] - elif 'negative' in label: - return [0, 0, 1] - - return [0, 1, 0] - - test_cases = [ - { - 'entry': { - 'nif:isString': 'I love Titanic' - }, - 'params': {}, - 'expected': { - "nif:isString": "I love Titanic", - 'marl:hasOpinion': [ - { - 'marl:hasPolarity': 'marl:Positive', - } - ] - }, - }, { - 'entry': { - 'nif:isString': 'I hate my life' - }, - 'params': {}, - 'expected': { - "nif:isString": "I hate my life", - 'marl:hasOpinion': [ - { - 'marl:hasPolarity': 'marl:Negative', - } - ] - }, - }, - ] - -if __name__ == '__main__': - easy_test()