【问题标题】:How to determine 'did' or 'did not' on something如何确定某事的“做了”或“没有”
【发布时间】:2021-12-12 00:58:23
【问题描述】:

区分这两者的直接方法是什么:

  1. the movie received critical acclaim
  2. the movie did not attain critical acclaim.

在我看来,nlp 的“情感分析”可以帮到我。所以我使用Textblobsentiment analysis。但是这两个句子的polarity 都是0.0

【问题讨论】:

  • 从机器学习的角度来看,类似于sentiment analysis。它们都是classification 问题,但请记住,您的标签传达不同的监督,它们显示动词是积极的还是消极的。
  • 解决这个问题的大致框架是什么?我目前正在从零开始学习 NLP 和“nltk”
  • 你能为你的任务提供标记数据吗? @kyw
  • 你是否也得到了 0.0subjectivity 的准确信息?这表明您的代码设置不正确,实际上并没有解析任何内容。
  • @meti 我没有任何类型的标记数据.. 听起来我必须训练一些模型?

标签: python nlp sentiment-analysis textblob


【解决方案1】:

对于您的情况simple,您可以使用基于 LSTM 模型的 flair,该模型将单词序列考虑在内进行预测.

1.安装天赋

!pip3 install flair

2.代码

import flair
flair_sentiment = flair.models.TextClassifier.load('en-sentiment')

sentence1 = 'the movie received critical acclaim'
sentence2 = 'the movie did not attain critical acclaim'

s1 = flair.data.Sentence(sentence1)
flair_sentiment.predict(s1)
s1_sentiment = s1.labels
print(s1_sentiment)

s2 = flair.data.Sentence(sentence2)
flair_sentiment.predict(s2)
s2_sentiment = s2.labels
print(s2_sentiment)

3.结果

print(s1_sentiment)
[POSITIVE (0.9995)]

print(s2_sentiment)
[NEGATIVE (0.9985)]

更多flair详情,可以访问this github repo

【讨论】:

    【解决方案2】:

    它需要否定处理能力。例如,wink-nlp 支持否定处理。您可以在runkit 处查看此示例的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 2018-06-05
      相关资源
      最近更新 更多