Method: documents.annotateText

A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.

HTTP request

POST https://language.googleapis.com/v1/documents:annotateText

The URL uses gRPC Transcoding syntax.

Request body

The request body contains data with the following structure:

JSON representation
 { 
 "document" 
 : 
 { 
 object (  Document 
 
) 
 } 
 , 
 "features" 
 : 
 { 
 object (  Features 
 
) 
 } 
 , 
 "encodingType" 
 : 
 enum (  EncodingType 
 
) 
 } 
Fields
document

object ( Document )

Required. Input document.

features

object ( Features )

Required. The enabled features.

encoding Type

enum ( EncodingType )

The encoding type used by the API to calculate offsets.

Response body

The text annotations response message.

If successful, the response body contains data with the following structure:

JSON representation
 { 
 "sentences" 
 : 
 [ 
 { 
 object (  Sentence 
 
) 
 } 
 ] 
 , 
 "tokens" 
 : 
 [ 
 { 
 object (  Token 
 
) 
 } 
 ] 
 , 
 "entities" 
 : 
 [ 
 { 
 object (  Entity 
 
) 
 } 
 ] 
 , 
 "documentSentiment" 
 : 
 { 
 object (  Sentiment 
 
) 
 } 
 , 
 "language" 
 : 
 string 
 , 
 "categories" 
 : 
 [ 
 { 
 object (  ClassificationCategory 
 
) 
 } 
 ] 
 , 
 "moderationCategories" 
 : 
 [ 
 { 
 object (  ClassificationCategory 
 
) 
 } 
 ] 
 } 
Fields
sentences[]

object ( Sentence )

Sentences in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_syntax .

tokens[]

object ( Token )

Tokens, along with their syntactic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_syntax .

entities[]

object ( Entity )

Entities, along with their semantic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_entities .

document Sentiment

object ( Sentiment )

The overall sentiment for the document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment .

language

string

The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for more details.

categories[]

object ( ClassificationCategory )

Categories identified in the input document.

moderation Categories[]

object ( ClassificationCategory )

Harmful and sensitive categories identified in the input document.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/cloud-language
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview .

Features

All available features for sentiment, syntax, and semantic analysis. Setting each one to true will enable that specific analysis for the input.

JSON representation
 { 
 "extractSyntax" 
 : 
 boolean 
 , 
 "extractEntities" 
 : 
 boolean 
 , 
 "extractDocumentSentiment" 
 : 
 boolean 
 , 
 "extractEntitySentiment" 
 : 
 boolean 
 , 
 "classifyText" 
 : 
 boolean 
 , 
 "moderateText" 
 : 
 boolean 
 , 
 "classificationModelOptions" 
 : 
 { 
 object (  ClassificationModelOptions 
 
) 
 } 
 } 
Fields
extract Syntax

boolean

Extract syntax information.

extract Entities

boolean

Extract entities.

extract Document Sentiment

boolean

Extract document-level sentiment.

extract Entity Sentiment

boolean

Extract entities and their associated sentiment.

classify Text

boolean

Classify the full document into categories.

moderate Text

boolean

Moderate the document for harmful and sensitive categories.

classification Model Options

object ( ClassificationModelOptions )

Optional. The model options to use for classification. Defaults to v1 options if not specified. Only used if classifyText is set to true.

Create a Mobile Website
View Site in Mobile | Classic
Share by: