Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
README.md
pom.xml

README.md

Maven Central

Sentiment Analysis

The SENTIMENT UDF uses the Google Cloud Natural Language API to detect sentiment in a string of text.

Prerequisites

  • Create or select a GCP project from Google Cloud Console
  • Enable Cloud Natural Language API
  • Create a service account
  • Download the private key (JSON). you will need this for the configuration step (see below)

Once you've completed this list of prequisites, you can install the SENTIMENT analysis UDF (see below).

Configuration

The following configs should be added to your KSQL server.properties file.

  • ksql.functions.sentiment.credentials.file: a path to the file containing your GCP service account credentials

Installation

Download the JAR from Maven Central and copy it to the KSQL extension directory (see here for more details).

Authentication

Set the following environment variable wherever your KSQL server instances are running.

$ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/privatekey.json

Example usage

SELECT SENTIMENT(my_column) FROM SOME_STREAM ;

# sample output
{score=0.8999999761581421, magnitude=0.8999999761581421}
You can’t perform that action at this time.