1- // Copyright 2022 Google LLC
1+ // Copyright 2023 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -34,7 +34,8 @@ service LanguageService {
3434 "https://www.googleapis.com/auth/cloud-platform" ;
3535
3636 // Analyzes the sentiment of the provided text.
37- rpc AnalyzeSentiment (AnalyzeSentimentRequest ) returns (AnalyzeSentimentResponse ) {
37+ rpc AnalyzeSentiment (AnalyzeSentimentRequest )
38+ returns (AnalyzeSentimentResponse ) {
3839 option (google.api.http ) = {
3940 post : "/v1beta2/documents:analyzeSentiment"
4041 body : "*"
@@ -46,7 +47,8 @@ service LanguageService {
4647 // Finds named entities (currently proper names and common nouns) in the text
4748 // along with entity types, salience, mentions for each entity, and
4849 // other properties.
49- rpc AnalyzeEntities (AnalyzeEntitiesRequest ) returns (AnalyzeEntitiesResponse ) {
50+ rpc AnalyzeEntities (AnalyzeEntitiesRequest )
51+ returns (AnalyzeEntitiesResponse ) {
5052 option (google.api.http ) = {
5153 post : "/v1beta2/documents:analyzeEntities"
5254 body : "*"
@@ -55,9 +57,12 @@ service LanguageService {
5557 option (google.api.method_signature ) = "document" ;
5658 }
5759
58- // Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text and analyzes
59- // sentiment associated with each entity and its mentions.
60- rpc AnalyzeEntitySentiment (AnalyzeEntitySentimentRequest ) returns (AnalyzeEntitySentimentResponse ) {
60+ // Finds entities, similar to
61+ // [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities]
62+ // in the text and analyzes sentiment associated with each entity and its
63+ // mentions.
64+ rpc AnalyzeEntitySentiment (AnalyzeEntitySentimentRequest )
65+ returns (AnalyzeEntitySentimentResponse ) {
6166 option (google.api.http ) = {
6267 post : "/v1beta2/documents:analyzeEntitySentiment"
6368 body : "*"
@@ -87,6 +92,15 @@ service LanguageService {
8792 option (google.api.method_signature ) = "document" ;
8893 }
8994
95+ // Moderates a document for harmful and sensitive categories.
96+ rpc ModerateText (ModerateTextRequest ) returns (ModerateTextResponse ) {
97+ option (google.api.http ) = {
98+ post : "/v1beta2/documents:moderateText"
99+ body : "*"
100+ };
101+ option (google.api.method_signature ) = "document" ;
102+ }
103+
90104 // A convenience method that provides all syntax, sentiment, entity, and
91105 // classification features in one call.
92106 rpc AnnotateText (AnnotateTextRequest ) returns (AnnotateTextResponse ) {
@@ -170,8 +184,8 @@ message Sentence {
170184 TextSpan text = 1 ;
171185
172186 // For calls to [AnalyzeSentiment][] or if
173- // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] is set to
174- // true, this field will contain the sentiment for the sentence.
187+ // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]
188+ // is set to true, this field will contain the sentiment for the sentence.
175189 Sentiment sentiment = 2 ;
176190}
177191
@@ -310,9 +324,9 @@ message Entity {
310324 repeated EntityMention mentions = 5 ;
311325
312326 // For calls to [AnalyzeEntitySentiment][] or if
313- // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
314- // true, this field will contain the aggregate sentiment expressed for this
315- // entity in the provided document.
327+ // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment]
328+ // is set to true, this field will contain the aggregate sentiment expressed
329+ // for this entity in the provided document.
316330 Sentiment sentiment = 6 ;
317331}
318332
@@ -960,9 +974,9 @@ message EntityMention {
960974 Type type = 2 ;
961975
962976 // For calls to [AnalyzeEntitySentiment][] or if
963- // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
964- // true, this field will contain the sentiment expressed for this mention of
965- // the entity in the provided document.
977+ // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment]
978+ // is set to true, this field will contain the sentiment expressed for this
979+ // mention of the entity in the provided document.
966980 Sentiment sentiment = 3 ;
967981}
968982
@@ -972,14 +986,15 @@ message TextSpan {
972986 string content = 1 ;
973987
974988 // The API calculates the beginning offset of the content in the original
975- // document according to the [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the API request.
989+ // document according to the
990+ // [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the
991+ // API request.
976992 int32 begin_offset = 2 ;
977993}
978994
979995// Represents a category returned from the text classifier.
980996message ClassificationCategory {
981- // The name of the category representing the document, from the [predefined
982- // taxonomy](https://cloud.google.com/natural-language/docs/categories).
997+ // The name of the category representing the document.
983998 string name = 1 ;
984999
9851000 // The classifier's confidence of the category. Number represents how certain
@@ -990,9 +1005,7 @@ message ClassificationCategory {
9901005// Model options available for classification requests.
9911006message ClassificationModelOptions {
9921007 // Options for the V1 model.
993- message V1Model {
994-
995- }
1008+ message V1Model {}
9961009
9971010 // Options for the V2 model.
9981011 message V2Model {
@@ -1043,7 +1056,8 @@ message AnalyzeSentimentResponse {
10431056
10441057 // The language of the text, which will be the same as the language specified
10451058 // in the request or, if not specified, the automatically-detected language.
1046- // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details.
1059+ // See [Document.language][google.cloud.language.v1beta2.Document.language]
1060+ // field for more details.
10471061 string language = 2 ;
10481062
10491063 // The sentiment for all the sentences in the document.
@@ -1066,7 +1080,8 @@ message AnalyzeEntitySentimentResponse {
10661080
10671081 // The language of the text, which will be the same as the language specified
10681082 // in the request or, if not specified, the automatically-detected language.
1069- // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details.
1083+ // See [Document.language][google.cloud.language.v1beta2.Document.language]
1084+ // field for more details.
10701085 string language = 2 ;
10711086}
10721087
@@ -1086,7 +1101,8 @@ message AnalyzeEntitiesResponse {
10861101
10871102 // The language of the text, which will be the same as the language specified
10881103 // in the request or, if not specified, the automatically-detected language.
1089- // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details.
1104+ // See [Document.language][google.cloud.language.v1beta2.Document.language]
1105+ // field for more details.
10901106 string language = 2 ;
10911107}
10921108
@@ -1109,7 +1125,8 @@ message AnalyzeSyntaxResponse {
11091125
11101126 // The language of the text, which will be the same as the language specified
11111127 // in the request or, if not specified, the automatically-detected language.
1112- // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details.
1128+ // See [Document.language][google.cloud.language.v1beta2.Document.language]
1129+ // field for more details.
11131130 string language = 3 ;
11141131}
11151132
@@ -1129,12 +1146,24 @@ message ClassifyTextResponse {
11291146 repeated ClassificationCategory categories = 1 ;
11301147}
11311148
1149+ // The document moderation request message.
1150+ message ModerateTextRequest {
1151+ // Required. Input document.
1152+ Document document = 1 [(google.api.field_behavior ) = REQUIRED ];
1153+ }
1154+
1155+ // The document moderation response message.
1156+ message ModerateTextResponse {
1157+ // Harmful and sensitive categories representing the input document.
1158+ repeated ClassificationCategory moderation_categories = 1 ;
1159+ }
1160+
11321161// The request message for the text annotation API, which can perform multiple
11331162// analysis types (sentiment, entities, and syntax) in one call.
11341163message AnnotateTextRequest {
11351164 // All available features for sentiment, syntax, and semantic analysis.
11361165 // Setting each one to true will enable that specific analysis for the input.
1137- // Next ID: 11
1166+ // Next ID: 12
11381167 message Features {
11391168 // Extract syntax information.
11401169 bool extract_syntax = 1 ;
@@ -1154,6 +1183,9 @@ message AnnotateTextRequest {
11541183 // taxonomy](https://cloud.google.com/natural-language/docs/categories).
11551184 bool classify_text = 6 ;
11561185
1186+ // Moderate the document for harmful and sensitive categories.
1187+ bool moderate_text = 11 ;
1188+
11571189 // The model options to use for classification. Defaults to v1 options
11581190 // if not specified. Only used if `classify_text` is set to true.
11591191 ClassificationModelOptions classification_model_options = 10 ;
@@ -1191,9 +1223,13 @@ message AnnotateTextResponse {
11911223
11921224 // The language of the text, which will be the same as the language specified
11931225 // in the request or, if not specified, the automatically-detected language.
1194- // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details.
1226+ // See [Document.language][google.cloud.language.v1beta2.Document.language]
1227+ // field for more details.
11951228 string language = 5 ;
11961229
11971230 // Categories identified in the input document.
11981231 repeated ClassificationCategory categories = 6 ;
1232+
1233+ // Harmful and sensitive categories identified in the input document.
1234+ repeated ClassificationCategory moderation_categories = 8 ;
11991235}
0 commit comments