情绪认知技能Sentiment cognitive skill

情绪技能可沿着一个积极-消极连续统评估非结构化文本,对于每个记录,会返回一个介于 0 和 1 之间的数字评分。The Sentiment skill evaluates unstructured text along a positive-negative continuum, and for each record, returns a numeric score between 0 and 1. 评分接近 1 代表积极的情绪,评分接近 0 代表消极的情绪。Scores close to 1 indicate positive sentiment, and scores close to 0 indicate negative sentiment. 此技能使用认知服务中的文本分析提供的机器学习模型。This skill uses the machine learning models provided by Text Analytics in Cognitive Services.

备注

通过增大处理频率、添加更多文档或添加更多 AI 算法来扩大范围时,需要附加可计费的认知服务资源As you expand scope by increasing the frequency of processing, adding more documents, or adding more AI algorithms, you will need to attach a billable Cognitive Services resource. 调用认知服务中的 API 以及在 Azure 认知搜索中的文档破解阶段提取图像时,会产生费用。Charges accrue when calling APIs in Cognitive Services, and for image extraction as part of the document-cracking stage in Azure Cognitive Search. 提取文档中的文本不会产生费用。There are no charges for text extraction from documents.

当你行使内置技能时,我们会按现有的认知服务预付费价格收费。Execution of built-in skills is charged at the existing Cognitive Services pay-in-advance price. 图像提取定价如 Azure 认知搜索定价页所述。Image extraction pricing is described on the Azure Cognitive Search pricing page.

@odata.type

Microsoft.Skills.Text.SentimentSkillMicrosoft.Skills.Text.SentimentSkill

数据限制Data limits

记录的最大大小应为 5000 个字符,通过 String.Length 进行测量。The maximum size of a record should be 5000 characters as measured by String.Length. 如果需要在将数据发送到情绪分析器之前拆分数据,请使用文本拆分技能If you need to break up your data before sending it to the sentiment analyzer, use the Text Split skill.

技能参数Skill parameters

参数区分大小写。Parameters are case-sensitive.

参数名称Parameter Name 说明Description
defaultLanguageCode (可选)要应用到未显式指定语言的文档的语言代码。(optional) The language code to apply to documents that don't specify language explicitly.
请参阅支持的语言的完整列表See Full list of supported languages

技能输入Skill inputs

输入名称Input Name 说明Description
text 要分析的文本。The text to be analyzed.
languageCode (可选)表示记录的语言的字符串。(Optional) A string indicating the language of the records. 如果未指定此属性,则默认值为“en”。If this parameter is not specified, the default value is "en".
请参阅支持的语言的完整列表See Full list of supported languages.

技能输出Skill outputs

输出名称Output Name 说明Description
score 介于 0 和 1 之间的值,表示所分析的文本的情绪。A value between 0 and 1 that represents the sentiment of the analyzed text. 值接近 0 代表消极情绪,接近 0.5 代表中性情绪,接近 1 代表积极的情绪。Values close to 0 have negative sentiment, close to 0.5 have neutral sentiment, and values close to 1 have positive sentiment.

示例定义Sample definition

{
    "@odata.type": "#Microsoft.Skills.Text.SentimentSkill",
    "inputs": [
        {
            "name": "text",
            "source": "/document/content"
        },
        {
            "name": "languageCode",
            "source": "/document/languagecode"
        }
    ],
    "outputs": [
        {
            "name": "score",
            "targetName": "mySentiment"
        }
    ]
}

示例输入Sample input

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

示例输出Sample output

{
    "values": [
        {
            "recordId": "1",
            "data": {
                "score": 0.01
            }
        }
    ]
}

注释Notes

如果为空,则不为这些记录返回情绪分数。If empty, a sentiment score is not returned for those records.

错误案例Error cases

如果某种语言不受支持,则生成错误,并且不会返回情绪分数。If a language is not supported, an error is generated and no sentiment score is returned.

另请参阅See also