IBM Watson NLU Bluemix API不适用于entities.sentiment = true

时间:2017-03-07 19:59:02

标签: ibm-watson watson-nlu

我使用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"
}

1 个答案:

答案 0 :(得分: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测试并确认结果。