All Natural Language API code samples

This page contains code samples for Cloud Natural Language API. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.

Analyze entities in a Cloud Storage file

Inspect text in a file stored in Cloud Storage for known entities (proper nouns such as public figures, and landmarks), and return information about those entities.

View in documentation

Analyze entities in a string

Inspect text for known entities (proper nouns such as public figures and landmarks), and return information about those entities.

View in documentation

Analyze entity sentiment in a Cloud Storage file

Determine the sentiment (positive or negative) expressed about entities within the text from a file stored in Cloud Storage.

Analyze entity sentiment in a string

Determine the sentiment (positive or negative) expressed about entities within the text.

Analyze sentiment app

A basic Natural Language API application that performs sentiment analysis on text.

Analyze sentiment in a Cloud Storage file

Inspect a file stored in Cloud Storage and identify the prevailing emotional opinion within the text.

View in documentation

Analyze sentiment in a string

Inspect the given text and identify the prevailing emotional opinion.

View in documentation

Analyze syntax of a Cloud Storage file

Break up the text from a file stored in Cloud Storage into a series of sentences and tokens (generally, words) and provide linguistic information about those tokens.

View in documentation

Analyze syntax of a string

Break up the given text into a series of sentences and tokens (generally, words) and provide linguistic information about those tokens.

View in documentation

Classify content

Analyze a document and return a list of content categories that apply to the text found in the document.

Classify content of a Cloud Storage file

Analyze a file stored in Google Cloud Storage and return a list of content categories that apply to the text found in the document

Classify text

Analyze text and return a list of content categories that apply to the text.

Classify text files and write to the index file

Classify each text file in a directory and write the results to the index file.

Detect sentiment

Detect the sentiment of some sample text.

View in documentation

Query label

Find the indexed files that are the most similar to the query label.

Query text

Find the indexed files that are the most similar to the query text.