类别:

字符串和二进制函数 (AI Functions)

SENTIMENT (SNOWFLAKE.CORTEX)

返回给定英文输入文本的总体情绪分数。

语法

SNOWFLAKE.CORTEX.SENTIMENT(<text>)
Copy

实参

text

一个字符串,包含应计算情绪分数的文本。

返回

A floating-point number from -1 to 1 (inclusive) indicating the model's level of certainty of any detected sentiment. A score close to 0 indicates that the function could not determine a clear sentiment in the text; this result can be considered neutral. A score close to 1 indicates positive sentiment, while a score close to -1 indicates negative sentiment. The chart below provides guidance on how to interpret the sentiment scores:

情绪

情绪分数

正面

0.5 至 1

中性

-0.5 至 0.5

负面

-0.5 至 -1

结果 并不 表示情绪的强度,而是极性(正面、中立或负面)和确定性。

访问控制要求

Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Cortex LLM privileges for more information on this privilege.

示例

以下示例使用 SENTIMENT 获取餐饮服务评价的情绪分类,鉴于分数为 0.54,可以推断该分类为轻度正面。

SELECT SNOWFLAKE.CORTEX.SENTIMENT('A tourist\'s delight, in low urban light,
  Recommended gem, a pizza night sight. Swift arrival, a pleasure so right,
  Yet, pockets felt lighter, a slight pricey bite. 💰🍕🚀');
Copy

响应:

0.5424458

在以下示例中,一个名为 reviews 的表包含一个名为 review_content 的列,该列包含用户提交的评论文本。该查询返回每条评论的情绪分数。

SELECT SNOWFLAKE.CORTEX.SENTIMENT(review_content), review_content FROM reviews LIMIT 10;
Copy

限制

Snowflake Cortex 函数不支持动态表。

语言: 中文