“情绪”技能 (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
                            }
                        ],
                    }
                ]
            }
        }
    ]
}
警告情况
如果文本为空,则会生成警告,且不返回情绪结果。 如果某语言不受支持,则会生成警告,且不返回情绪结果。