在单独的列中获取 Aspect-Based-Sentiment-Analysis 的输出

问题描述

我正在运行基于方面的情绪分析。我也想在我的数据集上实现它,代码中的正上方只是一个句子的实现示例。我的数据集包括应该分配特定方面(价格、质量等)的评论 + 方面的情绪。我找到了“aspect_based_sentiment_analysis”模块,它对我的​​任务有很大帮助,我以这种形式收到输出

Sentiment.positive for "slack"

我想掌握这个输出消息 'Sentiment.positive for "slack"'(因为现在只有在我运行过程时才能看到它)并将其附加到我的数据集(所以数据集中的每一行都有自己的方面) + 情绪在单独的列中)。我该怎么做?使用什么工具?看看我的数据集,希望它有帮助:https://www.dropbox.com/scl/fi/43nu0yf45obbyzprzc86n/combined_file.xlsx?dl=0&rlkey=7j959kz0urjxflf6r536brppt

完整代码在这里

import pathlib
import aspect_based_sentiment_analysis as absa
from setuptools import setup
from setuptools import find_packages


###
nlp = absa.load()
text = ("We are great fans of Slack,but we wish the subscriptions "
        "were more accessible to small startups.")

slack,price = nlp(text,aspects=['slack','price'])
assert price.sentiment == absa.Sentiment.negative
assert slack.sentiment == absa.Sentiment.positive


###
recognizer = absa.aux_models.BasicPatternRecognizer()
nlp = absa.load(pattern_recognizer=recognizer)
completed_task = nlp(text=text,'price'])
slack,price = completed_task.examples

absa.summary(slack)
--Sentiment.positive for "slack"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)