情感認知技能 (v3)

情感技能 (v3) 會針對每個記錄評估非結構化文字,並根據服務在句子和檔層級找到的最高信賴分數,提供情感卷標(例如「負面」、「中性」和「正面」。 此技能會使用 Azure AI 服務中語言服務第 3 版所提供的機器學習模型。 它也會公開 意見採礦功能,其提供有關文字中產品或服務屬性相關意見的更細微資訊。

注意

此技能會系結至 Azure AI 服務,而且需要 每天超過每個索引器 20 份檔的計費資源 。 內建技能的執行會以現有的 Azure AI 服務隨用隨付價格收費。

@odata.type

Microsoft.Skills.Text.V3.SentimentSkill

資料限制

記錄的大小上限應為5000個字元,如所 String.Length測量。 如果您需要在將數據傳送至情感技能之前中斷數據,請使用 文字分割技能

技能參數

參數會區分大小寫。

參數名稱 描述
defaultLanguageCode (選擇性)要套用至未明確指定語言的文件的語言代碼。
查看支援語言的完整清單。
modelVersion (選擇性)指定 呼叫情感分析時要使用的模型 版本。 未指定時,它會預設為最新版本。 除非有必要,否則建議您不要指定此值。
includeOpinionMining 如果設定為 true,則會啟用 意見採礦功能,以允許將以層面為基礎的情感分析包含在您的輸出結果中。 預設為 false

技能輸入

輸入名稱 描述
text 要分析的文字。
languageCode (選擇性)字串,表示記錄的語言。 如果未指定此參數,預設值為 “en”。
查看支援語言的完整清單。

技能輸出

輸出名稱 描述
sentiment 字串值,表示整個已分析文字的情感標籤(正、中性或負數)。
confidenceScores 具有三個雙精度浮點數的複雜型別,一個用於正評等,一個用於中性評等,另一個用於負評等。 值範圍從 0 到 1.00,其中 1.00 代表指定標籤指派中可能最高的信賴度。
sentences 複雜類型的集合,可依句子細分文字句子的情感。 此外,如果 includeOpinionMining 設定 true為 ,則意見採礦結果會以目標和評量的形式傳回。

範例定義

{
    "@odata.type": "#Microsoft.Skills.Text.V3.SentimentSkill",
    "context": "/document",
    "includeOpinionMining": true,
    "inputs": [
        {
            "name": "text",
            "source": "/document/content"
        },
        {
            "name": "languageCode",
            "source": "/document/languageCode"
        }
    ],
    "outputs": [
        {
            "name": "sentiment",
            "targetName": "sentiment"
        },
        {
            "name": "confidenceScores",
            "targetName": "confidenceScores"
        },
        {
            "name": "sentences",
            "targetName": "sentences"
        }
    ]
}

範例輸入

{
    "values": [
        {
            "recordId": "1",
            "data": {
                "text": "I had a terrible time at the hotel. The staff was rude and the food was awful.",
                "languageCode": "en"
            }
        }
    ]
}

範例輸出

{
    "values": [
        {
            "recordId": "1",
            "data": {
                "sentiment": "negative",
                "confidenceScores": {
                    "positive": 0.0,
                    "neutral": 0.0,
                    "negative": 1.0
                },
                "sentences": [
                    {
                        "text": "I had a terrible time at the hotel.",
                        "sentiment": "negative",
                        "confidenceScores": {
                            "positive": 0.0,
                            "neutral": 0.0,
                            "negative": 1.0
                        },
                        "offset": 0,
                        "length": 35,
                        "targets": [],
                        "assessments": [],
                    },
                    {
                        "text": "The staff was rude and the food was awful.",
                        "sentiment": "negative",
                        "confidenceScores": {
                            "positive": 0.0,
                            "neutral": 0.0,
                            "negative": 1.0
                        },
                        "offset":36,
                        "length": 42,
                        "targets": [
                            {
                                "text": "staff",
                                "sentiment": "negative",
                                "confidenceScores": {
                                    "positive": 0.0,
                                    "neutral": 0.0,
                                    "negative": 1.0
                                },
                                "offset": 40,
                                "length": 5,
                                "relations": [
                                    {
                                        "relationType": "assessment",
                                        "ref": "#/documents/0/sentences/1/assessments/0",
                                    }
                                ]
                            },
                            {
                                "text": "food",
                                "sentiment": "negative",
                                "confidenceScores": {
                                    "positive": 0.0,
                                    "neutral": 0.0,
                                    "negative": 1.0
                                },
                                "offset": 63,
                                "length": 4,
                                "relations": [
                                    {
                                        "relationType": "assessment",
                                        "ref": "#/documents/0/sentences/1/assessments/1",
                                    }
                                ]
                            }
                        ],
                        "assessments": [
                            {
                                "text": "rude",
                                "sentiment": "negative",
                                "confidenceScores": {
                                    "positive": 0.0,
                                    "neutral": 0.0,
                                    "negative": 1.0
                                },
                                "offset": 50,
                                "length": 4,
                                "isNegated": false
                            },
                            {
                                "text": "awful",
                                "sentiment": "negative",
                                "confidenceScores": {
                                    "positive": 0.0,
                                    "neutral": 0.0,
                                    "negative": 1.0
                                },
                                "offset": 72,
                                "length": 5,
                                "isNegated": false
                            }
                        ],
                    }
                ]
            }
        }
    ]
}

警告案例

如果您的文字是空的,則會產生警告,而且不會傳回任何情感結果。 如果不支持語言,則會產生警告,而且不會傳回任何情感結果。

另請參閱