snowflake.snowpark.functions.ai_sentiment¶
- snowflake.snowpark.functions.ai_sentiment(text: Union[Column, str], categories: Optional[List[str]] = None) Column[source]¶
Returns overall and category sentiment in the given input text.
- Parameters:
text – A string containing the text in which sentiment is detected.
categories – An array containing up to ten categories (also called entities or aspects) for which sentiment should be extracted. Each category is a string. For example, if extracting sentiment from a restaurant review, you might specify
['cost', 'quality', 'service', 'wait time']as the categories. Each category may be a maximum of 30 characters long. If you do not provide this argument, AI_SENTIMENT returns only the overall sentiment.
- Returns:
name: The name of the category. The category names match the categories specified in thecategoriesargument.sentiment: The sentiment of the category. Each sentiment result is one of the following strings.unknown: The category was not mentioned in the text.positive: The category was mentioned positively in the text.negative: The category was mentioned negatively in the text.neutral: The category was mentioned in the text, but neither positively nor negatively.mixed: The category was mentioned both positively and negatively in the text.
The
overallcategory record is always included and contains the overall sentiment of the text.- Return type:
An OBJECT value containing a
categoriesfield.categoriesis an array of category records. Each category includes these fields
Note
AI_SENTIMENT can analyze sentiment in English, French, German, Hindi, Italian, Spanish, and Portuguese. You can specify categories in the language of the text or in English.
Examples: