- Categories:
String & binary functions (AI Functions)
SENTIMENT (SNOWFLAKE.CORTEX)ΒΆ
Returns an overall sentiment score for the given English-language input text.
SyntaxΒΆ
SNOWFLAKE.CORTEX.SENTIMENT(<text>)
ArgumentsΒΆ
text
A string containing the text for which a sentiment score should be calculated.
ReturnsΒΆ
A floating-point number from -1 to 1 (inclusive) indicating the level of negative or positive sentiment in the text. Values around 0 indicate neutral sentiment. The chart below provides guidance on how to interpret the sentiment scores:
Sentiment |
Sentiment Score |
---|---|
Positive |
0.5 to 1 |
Neutral |
-0.5 to 0.5 |
Negative |
-0.5 to -1 |
Access control requirementsΒΆ
Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Required privileges for more information on this privilege.
ExamplesΒΆ
The following example uses SENTIMENT to get the sentiment classification of a food service review, which we can infer as modestly positive, given the score of 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. π°ππ');
Response:
0.5424458
In the following example, a table named reviews
contains a column named review_content
containing the text of reviews
submitted by users. The query returns a sentiment score for each review.
SELECT SNOWFLAKE.CORTEX.SENTIMENT(review_content), review_content FROM reviews LIMIT 10;
Legal noticesΒΆ
Refer to Snowflake AI and ML.
LimitationsΒΆ
Snowflake Cortex functions do not support dynamic tables.