liveBook · Manning

Sentiment analysis

As explained in Snowflake Data Engineering

Sentiment classification assigns text to categorical sentiment labels such as negative, neutral, or positive.

Sentiment analysis classifies customer reviews as negative, neutral, or positive by converting text into a sentiment score and then applying SQL thresholds. In a Snowflake review pipeline, Snowflake Cortex SENTIMENT augments stored customer reviews so employees can focus on selected feedback. section 7.0 section 7.3

A practical classification workflow:

  • Call SNOWFLAKE.CORTEX.SENTIMENT with each review as its input. section 7.3
  • Interpret the returned score on a scale from −1 to 1: lower values indicate negative sentiment, higher values positive sentiment, and values near the middle neutral sentiment. section 7.3
  • Map scores below −0.7 to Negative, scores below 0.4 to Neutral, and remaining scores to Positive; adjust the boundaries after reviewing results. section 7.3
  • Use the resulting class to filter reviews or track the distribution of positive and negative feedback over time. section 7.3

Classify reviews in SQL

Select each review, calculate its Snowflake Cortex sentiment score, and derive a categorical sentiment with CASE. For example, “The service was excellent!” produces 0.7691993, while “The bagel was stale.” produces a negative score. section 7.3

select 
  rating,
  time_created,
  customer_review,
  SNOWFLAKE.CORTEX.SENTIMENT(customer_review) as sentiment_score,
  case
    when sentiment_score < -0.7 then 'Negative'
    when sentiment_score < 0.4 then 'Neutral'
    else 'Positive'
  end as sentiment
from CUSTOMER_REVIEWS;

Runnable SQL combines review selection, Snowflake Cortex scoring, and CASE-based sentiment classification. section 7.3

How Snowflake Data Engineering covers it

How deep it goes
Defines score interpretation and SQL thresholding, but stops short of explaining the sentiment model’s internal operation.
Examples
Uses bakery delivery reviews and example phrases about excellent service, stale bagels, and an ordinary bakery visit.
What it assumes
Assumes Snowflake access and review data, while demonstrating the required Cortex role grant and database context.
What you can do after
Apply it via Snowflake Cortex and SQL to score reviews, assign classes, filter feedback, and track sentiment over time.
How it connects
Connects sentiment analysis with customer reviews, Snowflake Cortex, SQL CASE expressions, and large language models.

Also explained in

Compare how 12 books explain sentiment analysis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.