【问题标题】:IBM Watson NLU Bluemix API not working for entities.sentiment=trueIBM Watson NLU Bluemix API 不适用于 entity.sentiment=true
【发布时间】:2023-04-03 22:35:01
【问题描述】:

我正在使用 Watson NLU 服务按实体和关键字获取情绪,但输出只有文档情绪。

我不知道出了什么问题。我想知道关键字和实体的出现次数和情绪。

示例输出:

{
  "sentiment": {
    "document": {
      "score": 0.567576,
      "label": "positive"
    }
  },
  "language": "pt",
  "keywords": [
    {
      "text": "CNN teste",
      "relevance": 0.996733
    }
  ],
  "entities": [
    {
      "type": "Company",
      "text": "CNN",
      "relevance": 0.846667,
      "count": 3
    }
  ],
  "language": "pt"
}

【问题讨论】:

    标签: ibm-watson watson-nlu


    【解决方案1】:

    我认为这里没有问题,因为情绪结果取决于您发送到 API 的文本。我使用 Postman 和 Bluemix 中 NLU 服务的新凭证发出了这个请求。我收到了实体的情绪,但没有收到关键字。

    但是,如果您使用文档 (https://www.ibm.com/watson/developercloud/natural-language-understanding/api/v1/#post-analyze) 中所示的一些较长的示例文本提出请求,则返回的关键字确实会获得情绪分数。

    此外,如果您在问题中发送的参数中添加一些额外的文本,您会得到关键字的情绪。在这种情况下,我通过了:

    {"text":"CNN test, CNN test, ola tudo bem? This is another CNN test for IBM Watson"}
    

    并收到以下回复:

    {
      "sentiment": {
        "document": {
          "score": 0,
          "label": "neutral"
        }
      },
      "keywords": [
        {
          "text": "ola tudo bem",
          "sentiment": {
            "score": 0.35067
          },
          "relevance": 0.942955
        },
        {
          "text": "CNN test",
          "sentiment": {
            "score": 0
          },
          "relevance": 0.778042
        },
        {
          "text": "IBM Watson",
          "sentiment": {
            "score": 0
          },
          "relevance": 0.370733
        }
      ],
      "entities": [
        {
          "type": "Company",
          "text": "CNN",
          "sentiment": {
            "score": 0
          },
          "relevance": 0.932122,
          "disambiguation": {
            "subtype": [
              "Broadcast",
              "AwardWinner",
              "RadioNetwork",
              "TVNetwork"
            ],
            "name": "CNN",
            "dbpedia_resource": "http://dbpedia.org/resource/CNN"
          },
          "count": 3
        },
        {
          "type": "Company",
          "text": "IBM Watson",
          "sentiment": {
            "score": 0
          },
          "relevance": 0.302698,
          "count": 1
        }
      ],
      "language": "en"
    }
    

    您可以从上面的响应中看到关键字和实体现在正在返回一个情绪分数。

    我建议尝试使用更真实(re:更长)的文本参数对 API 进行另一次测试并确认结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      • 2018-11-10
      相关资源
      最近更新 更多