2017-03-07 76 views
1

我使用Watson NLU服務來獲取實體和關鍵字的情感,但輸出僅具有文檔情感。IBM Watson NLU Bluemix API不能用於entities.sentiment = true

我不知道發生了什麼問題。我想知道關鍵字和實體的出現次數和情緒。

輸出示例:

{ 
    "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

我不認爲這是一個問題,這裏的情緒結果取決於你發送到API的文本。我使用郵遞員在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:long)文本參數嘗試API的另一個測試,並確認結果。