Constants
LanguageService_AnalyzeSentiment_FullMethodName, LanguageService_AnalyzeEntities_FullMethodName, LanguageService_ClassifyText_FullMethodName, LanguageService_ModerateText_FullMethodName, LanguageService_AnnotateText_FullMethodName
const (
LanguageService_AnalyzeSentiment_FullMethodName = "/google.cloud.language.v2.LanguageService/AnalyzeSentiment"
LanguageService_AnalyzeEntities_FullMethodName = "/google.cloud.language.v2.LanguageService/AnalyzeEntities"
LanguageService_ClassifyText_FullMethodName = "/google.cloud.language.v2.LanguageService/ClassifyText"
LanguageService_ModerateText_FullMethodName = "/google.cloud.language.v2.LanguageService/ModerateText"
LanguageService_AnnotateText_FullMethodName = "/google.cloud.language.v2.LanguageService/AnnotateText"
)Variables
EncodingType_name, EncodingType_value
var (
EncodingType_name = map[int32]string{
0: "NONE",
1: "UTF8",
2: "UTF16",
3: "UTF32",
}
EncodingType_value = map[string]int32{
"NONE": 0,
"UTF8": 1,
"UTF16": 2,
"UTF32": 3,
}
)Enum value maps for EncodingType.
Document_Type_name, Document_Type_value
var (
Document_Type_name = map[int32]string{
0: "TYPE_UNSPECIFIED",
1: "PLAIN_TEXT",
2: "HTML",
}
Document_Type_value = map[string]int32{
"TYPE_UNSPECIFIED": 0,
"PLAIN_TEXT": 1,
"HTML": 2,
}
)Enum value maps for Document_Type.
Entity_Type_name, Entity_Type_value
var (
Entity_Type_name = map[int32]string{
0: "UNKNOWN",
1: "PERSON",
2: "LOCATION",
3: "ORGANIZATION",
4: "EVENT",
5: "WORK_OF_ART",
6: "CONSUMER_GOOD",
7: "OTHER",
9: "PHONE_NUMBER",
10: "ADDRESS",
11: "DATE",
12: "NUMBER",
13: "PRICE",
}
Entity_Type_value = map[string]int32{
"UNKNOWN": 0,
"PERSON": 1,
"LOCATION": 2,
"ORGANIZATION": 3,
"EVENT": 4,
"WORK_OF_ART": 5,
"CONSUMER_GOOD": 6,
"OTHER": 7,
"PHONE_NUMBER": 9,
"ADDRESS": 10,
"DATE": 11,
"NUMBER": 12,
"PRICE": 13,
}
)Enum value maps for Entity_Type.
EntityMention_Type_name, EntityMention_Type_value
var (
EntityMention_Type_name = map[int32]string{
0: "TYPE_UNKNOWN",
1: "PROPER",
2: "COMMON",
}
EntityMention_Type_value = map[string]int32{
"TYPE_UNKNOWN": 0,
"PROPER": 1,
"COMMON": 2,
}
)Enum value maps for EntityMention_Type.
ModerateTextRequest_ModelVersion_name, ModerateTextRequest_ModelVersion_value
var (
ModerateTextRequest_ModelVersion_name = map[int32]string{
0: "MODEL_VERSION_UNSPECIFIED",
1: "MODEL_VERSION_1",
2: "MODEL_VERSION_2",
}
ModerateTextRequest_ModelVersion_value = map[string]int32{
"MODEL_VERSION_UNSPECIFIED": 0,
"MODEL_VERSION_1": 1,
"MODEL_VERSION_2": 2,
}
)Enum value maps for ModerateTextRequest_ModelVersion.
File_google_cloud_language_v2_language_service_proto
var File_google_cloud_language_v2_language_service_proto protoreflect.FileDescriptorLanguageService_ServiceDesc
var LanguageService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "google.cloud.language.v2.LanguageService",
HandlerType: (*LanguageServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AnalyzeSentiment",
Handler: _LanguageService_AnalyzeSentiment_Handler,
},
{
MethodName: "AnalyzeEntities",
Handler: _LanguageService_AnalyzeEntities_Handler,
},
{
MethodName: "ClassifyText",
Handler: _LanguageService_ClassifyText_Handler,
},
{
MethodName: "ModerateText",
Handler: _LanguageService_ModerateText_Handler,
},
{
MethodName: "AnnotateText",
Handler: _LanguageService_AnnotateText_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "google/cloud/language/v2/language_service.proto",
}LanguageService_ServiceDesc is the grpc.ServiceDesc for LanguageService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions
func RegisterLanguageServiceServer
func RegisterLanguageServiceServer(s grpc.ServiceRegistrar, srv LanguageServiceServer)AnalyzeEntitiesRequest
type AnalyzeEntitiesRequest struct {
// Required. Input document.
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
// The encoding type used by the API to calculate offsets.
EncodingType EncodingType `protobuf:"varint,2,opt,name=encoding_type,json=encodingType,proto3,enum=google.cloud.language.v2.EncodingType" json:"encoding_type,omitempty"`
// contains filtered or unexported fields
}The entity analysis request message.
func (*AnalyzeEntitiesRequest) Descriptor
func (*AnalyzeEntitiesRequest) Descriptor() ([]byte, []int)Deprecated: Use AnalyzeEntitiesRequest.ProtoReflect.Descriptor instead.
func (*AnalyzeEntitiesRequest) GetDocument
func (x *AnalyzeEntitiesRequest) GetDocument() *Documentfunc (*AnalyzeEntitiesRequest) GetEncodingType
func (x *AnalyzeEntitiesRequest) GetEncodingType() EncodingTypefunc (*AnalyzeEntitiesRequest) ProtoMessage
func (*AnalyzeEntitiesRequest) ProtoMessage()func (*AnalyzeEntitiesRequest) ProtoReflect
func (x *AnalyzeEntitiesRequest) ProtoReflect() protoreflect.Messagefunc (*AnalyzeEntitiesRequest) Reset
func (x *AnalyzeEntitiesRequest) Reset()func (*AnalyzeEntitiesRequest) String
func (x *AnalyzeEntitiesRequest) String() stringAnalyzeEntitiesResponse
type AnalyzeEntitiesResponse struct {
// The recognized entities in the input document.
Entities []*Entity `protobuf:"bytes,1,rep,name=entities,proto3" json:"entities,omitempty"`
// 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.
LanguageCode string `protobuf:"bytes,2,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// Whether the language is officially supported. The API may still return a
// response when the language is not supported, but it is on a best effort
// basis.
LanguageSupported bool `protobuf:"varint,3,opt,name=language_supported,json=languageSupported,proto3" json:"language_supported,omitempty"`
// contains filtered or unexported fields
}The entity analysis response message.
func (*AnalyzeEntitiesResponse) Descriptor
func (*AnalyzeEntitiesResponse) Descriptor() ([]byte, []int)Deprecated: Use AnalyzeEntitiesResponse.ProtoReflect.Descriptor instead.
func (*AnalyzeEntitiesResponse) GetEntities
func (x *AnalyzeEntitiesResponse) GetEntities() []*Entityfunc (*AnalyzeEntitiesResponse) GetLanguageCode
func (x *AnalyzeEntitiesResponse) GetLanguageCode() stringfunc (*AnalyzeEntitiesResponse) GetLanguageSupported
func (x *AnalyzeEntitiesResponse) GetLanguageSupported() boolfunc (*AnalyzeEntitiesResponse) ProtoMessage
func (*AnalyzeEntitiesResponse) ProtoMessage()func (*AnalyzeEntitiesResponse) ProtoReflect
func (x *AnalyzeEntitiesResponse) ProtoReflect() protoreflect.Messagefunc (*AnalyzeEntitiesResponse) Reset
func (x *AnalyzeEntitiesResponse) Reset()func (*AnalyzeEntitiesResponse) String
func (x *AnalyzeEntitiesResponse) String() stringAnalyzeSentimentRequest
type AnalyzeSentimentRequest struct {
// Required. Input document.
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
// The encoding type used by the API to calculate sentence offsets.
EncodingType EncodingType `protobuf:"varint,2,opt,name=encoding_type,json=encodingType,proto3,enum=google.cloud.language.v2.EncodingType" json:"encoding_type,omitempty"`
// contains filtered or unexported fields
}The sentiment analysis request message.
func (*AnalyzeSentimentRequest) Descriptor
func (*AnalyzeSentimentRequest) Descriptor() ([]byte, []int)Deprecated: Use AnalyzeSentimentRequest.ProtoReflect.Descriptor instead.
func (*AnalyzeSentimentRequest) GetDocument
func (x *AnalyzeSentimentRequest) GetDocument() *Documentfunc (*AnalyzeSentimentRequest) GetEncodingType
func (x *AnalyzeSentimentRequest) GetEncodingType() EncodingTypefunc (*AnalyzeSentimentRequest) ProtoMessage
func (*AnalyzeSentimentRequest) ProtoMessage()func (*AnalyzeSentimentRequest) ProtoReflect
func (x *AnalyzeSentimentRequest) ProtoReflect() protoreflect.Messagefunc (*AnalyzeSentimentRequest) Reset
func (x *AnalyzeSentimentRequest) Reset()func (*AnalyzeSentimentRequest) String
func (x *AnalyzeSentimentRequest) String() stringAnalyzeSentimentResponse
type AnalyzeSentimentResponse struct {
// The overall sentiment of the input document.
DocumentSentiment *Sentiment `protobuf:"bytes,1,opt,name=document_sentiment,json=documentSentiment,proto3" json:"document_sentiment,omitempty"`
// 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.
LanguageCode string `protobuf:"bytes,2,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// The sentiment for all the sentences in the document.
Sentences []*Sentence `protobuf:"bytes,3,rep,name=sentences,proto3" json:"sentences,omitempty"`
// Whether the language is officially supported. The API may still return a
// response when the language is not supported, but it is on a best effort
// basis.
LanguageSupported bool `protobuf:"varint,4,opt,name=language_supported,json=languageSupported,proto3" json:"language_supported,omitempty"`
// contains filtered or unexported fields
}The sentiment analysis response message.
func (*AnalyzeSentimentResponse) Descriptor
func (*AnalyzeSentimentResponse) Descriptor() ([]byte, []int)Deprecated: Use AnalyzeSentimentResponse.ProtoReflect.Descriptor instead.
func (*AnalyzeSentimentResponse) GetDocumentSentiment
func (x *AnalyzeSentimentResponse) GetDocumentSentiment() *Sentimentfunc (*AnalyzeSentimentResponse) GetLanguageCode
func (x *AnalyzeSentimentResponse) GetLanguageCode() stringfunc (*AnalyzeSentimentResponse) GetLanguageSupported
func (x *AnalyzeSentimentResponse) GetLanguageSupported() boolfunc (*AnalyzeSentimentResponse) GetSentences
func (x *AnalyzeSentimentResponse) GetSentences() []*Sentencefunc (*AnalyzeSentimentResponse) ProtoMessage
func (*AnalyzeSentimentResponse) ProtoMessage()func (*AnalyzeSentimentResponse) ProtoReflect
func (x *AnalyzeSentimentResponse) ProtoReflect() protoreflect.Messagefunc (*AnalyzeSentimentResponse) Reset
func (x *AnalyzeSentimentResponse) Reset()func (*AnalyzeSentimentResponse) String
func (x *AnalyzeSentimentResponse) String() stringAnnotateTextRequest
type AnnotateTextRequest struct {
// Required. Input document.
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
// Required. The enabled features.
Features *AnnotateTextRequest_Features `protobuf:"bytes,2,opt,name=features,proto3" json:"features,omitempty"`
// The encoding type used by the API to calculate offsets.
EncodingType EncodingType `protobuf:"varint,3,opt,name=encoding_type,json=encodingType,proto3,enum=google.cloud.language.v2.EncodingType" json:"encoding_type,omitempty"`
// contains filtered or unexported fields
}The request message for the text annotation API, which can perform multiple analysis types in one call.
func (*AnnotateTextRequest) Descriptor
func (*AnnotateTextRequest) Descriptor() ([]byte, []int)Deprecated: Use AnnotateTextRequest.ProtoReflect.Descriptor instead.
func (*AnnotateTextRequest) GetDocument
func (x *AnnotateTextRequest) GetDocument() *Documentfunc (*AnnotateTextRequest) GetEncodingType
func (x *AnnotateTextRequest) GetEncodingType() EncodingTypefunc (*AnnotateTextRequest) GetFeatures
func (x *AnnotateTextRequest) GetFeatures() *AnnotateTextRequest_Featuresfunc (*AnnotateTextRequest) ProtoMessage
func (*AnnotateTextRequest) ProtoMessage()func (*AnnotateTextRequest) ProtoReflect
func (x *AnnotateTextRequest) ProtoReflect() protoreflect.Messagefunc (*AnnotateTextRequest) Reset
func (x *AnnotateTextRequest) Reset()func (*AnnotateTextRequest) String
func (x *AnnotateTextRequest) String() stringAnnotateTextRequest_Features
type AnnotateTextRequest_Features struct {
// Optional. Extract entities.
ExtractEntities bool `protobuf:"varint,1,opt,name=extract_entities,json=extractEntities,proto3" json:"extract_entities,omitempty"`
// Optional. Extract document-level sentiment.
ExtractDocumentSentiment bool `protobuf:"varint,2,opt,name=extract_document_sentiment,json=extractDocumentSentiment,proto3" json:"extract_document_sentiment,omitempty"`
// Optional. Classify the full document into categories.
ClassifyText bool `protobuf:"varint,4,opt,name=classify_text,json=classifyText,proto3" json:"classify_text,omitempty"`
// Optional. Moderate the document for harmful and sensitive categories.
ModerateText bool `protobuf:"varint,5,opt,name=moderate_text,json=moderateText,proto3" json:"moderate_text,omitempty"`
// contains filtered or unexported fields
}All available features. Setting each one to true will enable that specific analysis for the input.
func (*AnnotateTextRequest_Features) Descriptor
func (*AnnotateTextRequest_Features) Descriptor() ([]byte, []int)Deprecated: Use AnnotateTextRequest_Features.ProtoReflect.Descriptor instead.
func (*AnnotateTextRequest_Features) GetClassifyText
func (x *AnnotateTextRequest_Features) GetClassifyText() boolfunc (*AnnotateTextRequest_Features) GetExtractDocumentSentiment
func (x *AnnotateTextRequest_Features) GetExtractDocumentSentiment() boolfunc (*AnnotateTextRequest_Features) GetExtractEntities
func (x *AnnotateTextRequest_Features) GetExtractEntities() boolfunc (*AnnotateTextRequest_Features) GetModerateText
func (x *AnnotateTextRequest_Features) GetModerateText() boolfunc (*AnnotateTextRequest_Features) ProtoMessage
func (*AnnotateTextRequest_Features) ProtoMessage()func (*AnnotateTextRequest_Features) ProtoReflect
func (x *AnnotateTextRequest_Features) ProtoReflect() protoreflect.Messagefunc (*AnnotateTextRequest_Features) Reset
func (x *AnnotateTextRequest_Features) Reset()func (*AnnotateTextRequest_Features) String
func (x *AnnotateTextRequest_Features) String() stringAnnotateTextResponse
type AnnotateTextResponse struct {
// Sentences in the input document. Populated if the user enables
// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
Sentences []*Sentence `protobuf:"bytes,1,rep,name=sentences,proto3" json:"sentences,omitempty"`
// Entities, along with their semantic information, in the input document.
// Populated if the user enables
// [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities]
// or
// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment].
Entities []*Entity `protobuf:"bytes,2,rep,name=entities,proto3" json:"entities,omitempty"`
// The overall sentiment for the document. Populated if the user enables
// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
DocumentSentiment *Sentiment `protobuf:"bytes,3,opt,name=document_sentiment,json=documentSentiment,proto3" json:"document_sentiment,omitempty"`
// 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.
LanguageCode string `protobuf:"bytes,4,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// Categories identified in the input document.
Categories []*ClassificationCategory `protobuf:"bytes,5,rep,name=categories,proto3" json:"categories,omitempty"`
// Harmful and sensitive categories identified in the input document.
ModerationCategories []*ClassificationCategory `protobuf:"bytes,6,rep,name=moderation_categories,json=moderationCategories,proto3" json:"moderation_categories,omitempty"`
// Whether the language is officially supported by all requested features.
// The API may still return a response when the language is not supported, but
// it is on a best effort basis.
LanguageSupported bool `protobuf:"varint,7,opt,name=language_supported,json=languageSupported,proto3" json:"language_supported,omitempty"`
// contains filtered or unexported fields
}The text annotations response message.
func (*AnnotateTextResponse) Descriptor
func (*AnnotateTextResponse) Descriptor() ([]byte, []int)Deprecated: Use AnnotateTextResponse.ProtoReflect.Descriptor instead.
func (*AnnotateTextResponse) GetCategories
func (x *AnnotateTextResponse) GetCategories() []*ClassificationCategoryfunc (*AnnotateTextResponse) GetDocumentSentiment
func (x *AnnotateTextResponse) GetDocumentSentiment() *Sentimentfunc (*AnnotateTextResponse) GetEntities
func (x *AnnotateTextResponse) GetEntities() []*Entityfunc (*AnnotateTextResponse) GetLanguageCode
func (x *AnnotateTextResponse) GetLanguageCode() stringfunc (*AnnotateTextResponse) GetLanguageSupported
func (x *AnnotateTextResponse) GetLanguageSupported() boolfunc (*AnnotateTextResponse) GetModerationCategories
func (x *AnnotateTextResponse) GetModerationCategories() []*ClassificationCategoryfunc (*AnnotateTextResponse) GetSentences
func (x *AnnotateTextResponse) GetSentences() []*Sentencefunc (*AnnotateTextResponse) ProtoMessage
func (*AnnotateTextResponse) ProtoMessage()func (*AnnotateTextResponse) ProtoReflect
func (x *AnnotateTextResponse) ProtoReflect() protoreflect.Messagefunc (*AnnotateTextResponse) Reset
func (x *AnnotateTextResponse) Reset()func (*AnnotateTextResponse) String
func (x *AnnotateTextResponse) String() stringClassificationCategory
type ClassificationCategory struct {
// The name of the category representing the document.
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The classifier's confidence of the category. Number represents how certain
// the classifier is that this category represents the given text.
Confidence float32 `protobuf:"fixed32,2,opt,name=confidence,proto3" json:"confidence,omitempty"`
// Optional. The classifier's severity of the category. This is only present
// when the ModerateTextRequest.ModelVersion is set to MODEL_VERSION_2, and
// the corresponding category has a severity score.
Severity float32 `protobuf:"fixed32,3,opt,name=severity,proto3" json:"severity,omitempty"`
// contains filtered or unexported fields
}Represents a category returned from the text classifier.
func (*ClassificationCategory) Descriptor
func (*ClassificationCategory) Descriptor() ([]byte, []int)Deprecated: Use ClassificationCategory.ProtoReflect.Descriptor instead.
func (*ClassificationCategory) GetConfidence
func (x *ClassificationCategory) GetConfidence() float32func (*ClassificationCategory) GetName
func (x *ClassificationCategory) GetName() stringfunc (*ClassificationCategory) GetSeverity
func (x *ClassificationCategory) GetSeverity() float32func (*ClassificationCategory) ProtoMessage
func (*ClassificationCategory) ProtoMessage()func (*ClassificationCategory) ProtoReflect
func (x *ClassificationCategory) ProtoReflect() protoreflect.Messagefunc (*ClassificationCategory) Reset
func (x *ClassificationCategory) Reset()func (*ClassificationCategory) String
func (x *ClassificationCategory) String() stringClassifyTextRequest
type ClassifyTextRequest struct {
// Required. Input document.
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
// contains filtered or unexported fields
}The document classification request message.
func (*ClassifyTextRequest) Descriptor
func (*ClassifyTextRequest) Descriptor() ([]byte, []int)Deprecated: Use ClassifyTextRequest.ProtoReflect.Descriptor instead.
func (*ClassifyTextRequest) GetDocument
func (x *ClassifyTextRequest) GetDocument() *Documentfunc (*ClassifyTextRequest) ProtoMessage
func (*ClassifyTextRequest) ProtoMessage()func (*ClassifyTextRequest) ProtoReflect
func (x *ClassifyTextRequest) ProtoReflect() protoreflect.Messagefunc (*ClassifyTextRequest) Reset
func (x *ClassifyTextRequest) Reset()func (*ClassifyTextRequest) String
func (x *ClassifyTextRequest) String() stringClassifyTextResponse
type ClassifyTextResponse struct {
// Categories representing the input document.
Categories []*ClassificationCategory `protobuf:"bytes,1,rep,name=categories,proto3" json:"categories,omitempty"`
// 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.
LanguageCode string `protobuf:"bytes,2,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// Whether the language is officially supported. The API may still return a
// response when the language is not supported, but it is on a best effort
// basis.
LanguageSupported bool `protobuf:"varint,3,opt,name=language_supported,json=languageSupported,proto3" json:"language_supported,omitempty"`
// contains filtered or unexported fields
}The document classification response message.
func (*ClassifyTextResponse) Descriptor
func (*ClassifyTextResponse) Descriptor() ([]byte, []int)Deprecated: Use ClassifyTextResponse.ProtoReflect.Descriptor instead.
func (*ClassifyTextResponse) GetCategories
func (x *ClassifyTextResponse) GetCategories() []*ClassificationCategoryfunc (*ClassifyTextResponse) GetLanguageCode
func (x *ClassifyTextResponse) GetLanguageCode() stringfunc (*ClassifyTextResponse) GetLanguageSupported
func (x *ClassifyTextResponse) GetLanguageSupported() boolfunc (*ClassifyTextResponse) ProtoMessage
func (*ClassifyTextResponse) ProtoMessage()func (*ClassifyTextResponse) ProtoReflect
func (x *ClassifyTextResponse) ProtoReflect() protoreflect.Messagefunc (*ClassifyTextResponse) Reset
func (x *ClassifyTextResponse) Reset()func (*ClassifyTextResponse) String
func (x *ClassifyTextResponse) String() stringDocument
type Document struct {
// Required. If the type is not set or is `TYPE_UNSPECIFIED`,
// returns an `INVALID_ARGUMENT` error.
Type Document_Type `protobuf:"varint,1,opt,name=type,proto3,enum=google.cloud.language.v2.Document_Type" json:"type,omitempty"`
// The source of the document: a string containing the content or a
// Google Cloud Storage URI.
//
// Types that are assignable to Source:
//
// *Document_Content
// *Document_GcsContentUri
Source isDocument_Source `protobuf_oneof:"source"`
// Optional. The language of the document (if not specified, the language is
// automatically detected). Both ISO and BCP-47 language codes are
// accepted.
// [Language
// Support](https://cloud.google.com/natural-language/docs/languages) lists
// currently supported languages for each API method. If the language (either
// specified by the caller or automatically detected) is not supported by the
// called API method, an `INVALID_ARGUMENT` error is returned.
LanguageCode string `protobuf:"bytes,4,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// contains filtered or unexported fields
}Represents the input to API methods.
func (*Document) Descriptor
Deprecated: Use Document.ProtoReflect.Descriptor instead.
func (*Document) GetContent
func (*Document) GetGcsContentUri
func (*Document) GetLanguageCode
func (*Document) GetSource
func (m *Document) GetSource() isDocument_Sourcefunc (*Document) GetType
func (x *Document) GetType() Document_Typefunc (*Document) ProtoMessage
func (*Document) ProtoMessage()func (*Document) ProtoReflect
func (x *Document) ProtoReflect() protoreflect.Messagefunc (*Document) Reset
func (x *Document) Reset()func (*Document) String
Document_Content
type Document_Content struct {
// The content of the input in string format.
// Cloud audit logging exempt since it is based on user data.
Content string `protobuf:"bytes,2,opt,name=content,proto3,oneof"`
}Document_GcsContentUri
type Document_GcsContentUri struct {
// The Google Cloud Storage URI where the file content is located.
// This URI must be of the form: gs://bucket_name/object_name. For more
// details, see https://cloud.google.com/storage/docs/reference-uris.
// NOTE: Cloud Storage object versioning is not supported.
GcsContentUri string `protobuf:"bytes,3,opt,name=gcs_content_uri,json=gcsContentUri,proto3,oneof"`
}Document_Type
type Document_Type int32The document types enum.
Document_TYPE_UNSPECIFIED, Document_PLAIN_TEXT, Document_HTML
const (
// The content type is not specified.
Document_TYPE_UNSPECIFIED Document_Type = 0
// Plain text
Document_PLAIN_TEXT Document_Type = 1
// HTML
Document_HTML Document_Type = 2
)func (Document_Type) Descriptor
func (Document_Type) Descriptor() protoreflect.EnumDescriptorfunc (Document_Type) Enum
func (x Document_Type) Enum() *Document_Typefunc (Document_Type) EnumDescriptor
func (Document_Type) EnumDescriptor() ([]byte, []int)Deprecated: Use Document_Type.Descriptor instead.
func (Document_Type) Number
func (x Document_Type) Number() protoreflect.EnumNumberfunc (Document_Type) String
func (x Document_Type) String() stringfunc (Document_Type) Type
func (Document_Type) Type() protoreflect.EnumTypeEncodingType
type EncodingType int32Represents the text encoding that the caller uses to process the output.
Providing an EncodingType is recommended because the API provides the
beginning offsets for various outputs, such as tokens and mentions, and
languages that natively use different text encodings may access offsets
differently.
EncodingType_NONE, EncodingType_UTF8, EncodingType_UTF16, EncodingType_UTF32
const (
// If `EncodingType` is not specified, encoding-dependent information (such as
// `begin_offset`) will be set at `-1`.
EncodingType_NONE EncodingType = 0
// Encoding-dependent information (such as `begin_offset`) is calculated based
// on the UTF-8 encoding of the input. C++ and Go are examples of languages
// that use this encoding natively.
EncodingType_UTF8 EncodingType = 1
// Encoding-dependent information (such as `begin_offset`) is calculated based
// on the UTF-16 encoding of the input. Java and JavaScript are examples of
// languages that use this encoding natively.
EncodingType_UTF16 EncodingType = 2
// Encoding-dependent information (such as `begin_offset`) is calculated based
// on the UTF-32 encoding of the input. Python is an example of a language
// that uses this encoding natively.
EncodingType_UTF32 EncodingType = 3
)func (EncodingType) Descriptor
func (EncodingType) Descriptor() protoreflect.EnumDescriptorfunc (EncodingType) Enum
func (x EncodingType) Enum() *EncodingTypefunc (EncodingType) EnumDescriptor
func (EncodingType) EnumDescriptor() ([]byte, []int)Deprecated: Use EncodingType.Descriptor instead.
func (EncodingType) Number
func (x EncodingType) Number() protoreflect.EnumNumberfunc (EncodingType) String
func (x EncodingType) String() stringfunc (EncodingType) Type
func (EncodingType) Type() protoreflect.EnumTypeEntity
type Entity struct {
// The representative name for the entity.
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The entity type.
Type Entity_Type `protobuf:"varint,2,opt,name=type,proto3,enum=google.cloud.language.v2.Entity_Type" json:"type,omitempty"`
// Metadata associated with the entity.
//
// For the metadata
// associated with other entity types, see the Type table below.
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// The mentions of this entity in the input document. The API currently
// supports proper noun mentions.
Mentions []*EntityMention `protobuf:"bytes,5,rep,name=mentions,proto3" json:"mentions,omitempty"`
// For calls to [AnalyzeEntitySentiment][] or if
// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
// is set to true, this field will contain the aggregate sentiment expressed
// for this entity in the provided document.
Sentiment *Sentiment `protobuf:"bytes,6,opt,name=sentiment,proto3" json:"sentiment,omitempty"`
// contains filtered or unexported fields
}Represents a phrase in the text that is a known entity, such as a person, an organization, or location. The API associates information, such as probability and mentions, with entities.
func (*Entity) Descriptor
Deprecated: Use Entity.ProtoReflect.Descriptor instead.
func (*Entity) GetMentions
func (x *Entity) GetMentions() []*EntityMentionfunc (*Entity) GetMetadata
func (*Entity) GetName
func (*Entity) GetSentiment
func (*Entity) GetType
func (x *Entity) GetType() Entity_Typefunc (*Entity) ProtoMessage
func (*Entity) ProtoMessage()func (*Entity) ProtoReflect
func (x *Entity) ProtoReflect() protoreflect.Messagefunc (*Entity) Reset
func (x *Entity) Reset()func (*Entity) String
EntityMention
type EntityMention struct {
// The mention text.
Text *TextSpan `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
// The type of the entity mention.
Type EntityMention_Type `protobuf:"varint,2,opt,name=type,proto3,enum=google.cloud.language.v2.EntityMention_Type" json:"type,omitempty"`
// For calls to [AnalyzeEntitySentiment][] or if
// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
// is set to true, this field will contain the sentiment expressed for this
// mention of the entity in the provided document.
Sentiment *Sentiment `protobuf:"bytes,3,opt,name=sentiment,proto3" json:"sentiment,omitempty"`
// Probability score associated with the entity.
//
// The score shows the probability of the entity mention being the entity
// type. The score is in (0, 1] range.
Probability float32 `protobuf:"fixed32,4,opt,name=probability,proto3" json:"probability,omitempty"`
// contains filtered or unexported fields
}Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
func (*EntityMention) Descriptor
func (*EntityMention) Descriptor() ([]byte, []int)Deprecated: Use EntityMention.ProtoReflect.Descriptor instead.
func (*EntityMention) GetProbability
func (x *EntityMention) GetProbability() float32func (*EntityMention) GetSentiment
func (x *EntityMention) GetSentiment() *Sentimentfunc (*EntityMention) GetText
func (x *EntityMention) GetText() *TextSpanfunc (*EntityMention) GetType
func (x *EntityMention) GetType() EntityMention_Typefunc (*EntityMention) ProtoMessage
func (*EntityMention) ProtoMessage()func (*EntityMention) ProtoReflect
func (x *EntityMention) ProtoReflect() protoreflect.Messagefunc (*EntityMention) Reset
func (x *EntityMention) Reset()func (*EntityMention) String
func (x *EntityMention) String() stringEntityMention_Type
type EntityMention_Type int32The supported types of mentions.
EntityMention_TYPE_UNKNOWN, EntityMention_PROPER, EntityMention_COMMON
const (
// Unknown
EntityMention_TYPE_UNKNOWN EntityMention_Type = 0
// Proper name
EntityMention_PROPER EntityMention_Type = 1
// Common noun (or noun compound)
EntityMention_COMMON EntityMention_Type = 2
)func (EntityMention_Type) Descriptor
func (EntityMention_Type) Descriptor() protoreflect.EnumDescriptorfunc (EntityMention_Type) Enum
func (x EntityMention_Type) Enum() *EntityMention_Typefunc (EntityMention_Type) EnumDescriptor
func (EntityMention_Type) EnumDescriptor() ([]byte, []int)Deprecated: Use EntityMention_Type.Descriptor instead.
func (EntityMention_Type) Number
func (x EntityMention_Type) Number() protoreflect.EnumNumberfunc (EntityMention_Type) String
func (x EntityMention_Type) String() stringfunc (EntityMention_Type) Type
func (EntityMention_Type) Type() protoreflect.EnumTypeEntity_Type
type Entity_Type int32The type of the entity. The table below lists the associated fields for entities that have different metadata.
Entity_UNKNOWN, Entity_PERSON, Entity_LOCATION, Entity_ORGANIZATION, Entity_EVENT, Entity_WORK_OF_ART, Entity_CONSUMER_GOOD, Entity_OTHER, Entity_PHONE_NUMBER, Entity_ADDRESS, Entity_DATE, Entity_NUMBER, Entity_PRICE
const (
// Unknown
Entity_UNKNOWN Entity_Type = 0
// Person
Entity_PERSON Entity_Type = 1
// Location
Entity_LOCATION Entity_Type = 2
// Organization
Entity_ORGANIZATION Entity_Type = 3
// Event
Entity_EVENT Entity_Type = 4
// Artwork
Entity_WORK_OF_ART Entity_Type = 5
// Consumer product
Entity_CONSUMER_GOOD Entity_Type = 6
// Other types of entities
Entity_OTHER Entity_Type = 7
// Phone number
//
// The metadata lists the phone number, formatted according to local
// convention, plus whichever additional elements appear in the text:
//
// * `number` - the actual number, broken down into sections as per local
// convention
// * `national_prefix` - country code, if detected
// * `area_code` - region or area code, if detected
// * `extension` - phone extension (to be dialed after connection), if
// detected
Entity_PHONE_NUMBER Entity_Type = 9
// Address
//
// The metadata identifies the street number and locality plus whichever
// additional elements appear in the text:
//
// * `street_number` - street number
// * `locality` - city or town
// * `street_name` - street/route name, if detected
// * `postal_code` - postal code, if detected
// * `country` - country, if detected
// * `broad_region` - administrative area, such as the state, if detected
// * `narrow_region` - smaller administrative area, such as county, if
// detected
// * `sublocality` - used in Asian addresses to demark a district within a
// city, if detected
Entity_ADDRESS Entity_Type = 10
// Date
//
// The metadata identifies the components of the date:
//
// * `year` - four digit year, if detected
// * `month` - two digit month number, if detected
// * `day` - two digit day number, if detected
Entity_DATE Entity_Type = 11
// Number
//
// The metadata is the number itself.
Entity_NUMBER Entity_Type = 12
// Price
//
// The metadata identifies the `value` and `currency`.
Entity_PRICE Entity_Type = 13
)func (Entity_Type) Descriptor
func (Entity_Type) Descriptor() protoreflect.EnumDescriptorfunc (Entity_Type) Enum
func (x Entity_Type) Enum() *Entity_Typefunc (Entity_Type) EnumDescriptor
func (Entity_Type) EnumDescriptor() ([]byte, []int)Deprecated: Use Entity_Type.Descriptor instead.
func (Entity_Type) Number
func (x Entity_Type) Number() protoreflect.EnumNumberfunc (Entity_Type) String
func (x Entity_Type) String() stringfunc (Entity_Type) Type
func (Entity_Type) Type() protoreflect.EnumTypeLanguageServiceClient
type LanguageServiceClient interface {
// Analyzes the sentiment of the provided text.
AnalyzeSentiment(ctx context.Context, in *AnalyzeSentimentRequest, opts ...grpc.CallOption) (*AnalyzeSentimentResponse, error)
// Finds named entities (currently proper names and common nouns) in the text
// along with entity types, probability, mentions for each entity, and
// other properties.
AnalyzeEntities(ctx context.Context, in *AnalyzeEntitiesRequest, opts ...grpc.CallOption) (*AnalyzeEntitiesResponse, error)
// Classifies a document into categories.
ClassifyText(ctx context.Context, in *ClassifyTextRequest, opts ...grpc.CallOption) (*ClassifyTextResponse, error)
// Moderates a document for harmful and sensitive categories.
ModerateText(ctx context.Context, in *ModerateTextRequest, opts ...grpc.CallOption) (*ModerateTextResponse, error)
// A convenience method that provides all features in one call.
AnnotateText(ctx context.Context, in *AnnotateTextRequest, opts ...grpc.CallOption) (*AnnotateTextResponse, error)
}LanguageServiceClient is the client API for LanguageService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewLanguageServiceClient
func NewLanguageServiceClient(cc grpc.ClientConnInterface) LanguageServiceClientLanguageServiceServer
type LanguageServiceServer interface {
// Analyzes the sentiment of the provided text.
AnalyzeSentiment(context.Context, *AnalyzeSentimentRequest) (*AnalyzeSentimentResponse, error)
// Finds named entities (currently proper names and common nouns) in the text
// along with entity types, probability, mentions for each entity, and
// other properties.
AnalyzeEntities(context.Context, *AnalyzeEntitiesRequest) (*AnalyzeEntitiesResponse, error)
// Classifies a document into categories.
ClassifyText(context.Context, *ClassifyTextRequest) (*ClassifyTextResponse, error)
// Moderates a document for harmful and sensitive categories.
ModerateText(context.Context, *ModerateTextRequest) (*ModerateTextResponse, error)
// A convenience method that provides all features in one call.
AnnotateText(context.Context, *AnnotateTextRequest) (*AnnotateTextResponse, error)
}LanguageServiceServer is the server API for LanguageService service. All implementations should embed UnimplementedLanguageServiceServer for forward compatibility
ModerateTextRequest
type ModerateTextRequest struct {
// Required. Input document.
Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"`
// Optional. The model version to use for ModerateText.
ModelVersion ModerateTextRequest_ModelVersion `protobuf:"varint,2,opt,name=model_version,json=modelVersion,proto3,enum=google.cloud.language.v2.ModerateTextRequest_ModelVersion" json:"model_version,omitempty"`
// contains filtered or unexported fields
}The document moderation request message.
func (*ModerateTextRequest) Descriptor
func (*ModerateTextRequest) Descriptor() ([]byte, []int)Deprecated: Use ModerateTextRequest.ProtoReflect.Descriptor instead.
func (*ModerateTextRequest) GetDocument
func (x *ModerateTextRequest) GetDocument() *Documentfunc (*ModerateTextRequest) GetModelVersion
func (x *ModerateTextRequest) GetModelVersion() ModerateTextRequest_ModelVersionfunc (*ModerateTextRequest) ProtoMessage
func (*ModerateTextRequest) ProtoMessage()func (*ModerateTextRequest) ProtoReflect
func (x *ModerateTextRequest) ProtoReflect() protoreflect.Messagefunc (*ModerateTextRequest) Reset
func (x *ModerateTextRequest) Reset()func (*ModerateTextRequest) String
func (x *ModerateTextRequest) String() stringModerateTextRequest_ModelVersion
type ModerateTextRequest_ModelVersion int32The model version to use for ModerateText.
ModerateTextRequest_MODEL_VERSION_UNSPECIFIED, ModerateTextRequest_MODEL_VERSION_1, ModerateTextRequest_MODEL_VERSION_2
const (
// The default model version.
ModerateTextRequest_MODEL_VERSION_UNSPECIFIED ModerateTextRequest_ModelVersion = 0
// Use the v1 model, this model is used by default when not provided.
// The v1 model only returns probability (confidence) score for each
// category.
ModerateTextRequest_MODEL_VERSION_1 ModerateTextRequest_ModelVersion = 1
// Use the v2 model.
// The v2 model only returns probability (confidence) score for each
// category, and returns severity score for a subset of the categories.
ModerateTextRequest_MODEL_VERSION_2 ModerateTextRequest_ModelVersion = 2
)func (ModerateTextRequest_ModelVersion) Descriptor
func (ModerateTextRequest_ModelVersion) Descriptor() protoreflect.EnumDescriptorfunc (ModerateTextRequest_ModelVersion) Enum
func (x ModerateTextRequest_ModelVersion) Enum() *ModerateTextRequest_ModelVersionfunc (ModerateTextRequest_ModelVersion) EnumDescriptor
func (ModerateTextRequest_ModelVersion) EnumDescriptor() ([]byte, []int)Deprecated: Use ModerateTextRequest_ModelVersion.Descriptor instead.
func (ModerateTextRequest_ModelVersion) Number
func (x ModerateTextRequest_ModelVersion) Number() protoreflect.EnumNumberfunc (ModerateTextRequest_ModelVersion) String
func (x ModerateTextRequest_ModelVersion) String() stringfunc (ModerateTextRequest_ModelVersion) Type
func (ModerateTextRequest_ModelVersion) Type() protoreflect.EnumTypeModerateTextResponse
type ModerateTextResponse struct {
// Harmful and sensitive categories representing the input document.
ModerationCategories []*ClassificationCategory `protobuf:"bytes,1,rep,name=moderation_categories,json=moderationCategories,proto3" json:"moderation_categories,omitempty"`
// 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.
LanguageCode string `protobuf:"bytes,2,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
// Whether the language is officially supported. The API may still return a
// response when the language is not supported, but it is on a best effort
// basis.
LanguageSupported bool `protobuf:"varint,3,opt,name=language_supported,json=languageSupported,proto3" json:"language_supported,omitempty"`
// contains filtered or unexported fields
}The document moderation response message.
func (*ModerateTextResponse) Descriptor
func (*ModerateTextResponse) Descriptor() ([]byte, []int)Deprecated: Use ModerateTextResponse.ProtoReflect.Descriptor instead.
func (*ModerateTextResponse) GetLanguageCode
func (x *ModerateTextResponse) GetLanguageCode() stringfunc (*ModerateTextResponse) GetLanguageSupported
func (x *ModerateTextResponse) GetLanguageSupported() boolfunc (*ModerateTextResponse) GetModerationCategories
func (x *ModerateTextResponse) GetModerationCategories() []*ClassificationCategoryfunc (*ModerateTextResponse) ProtoMessage
func (*ModerateTextResponse) ProtoMessage()func (*ModerateTextResponse) ProtoReflect
func (x *ModerateTextResponse) ProtoReflect() protoreflect.Messagefunc (*ModerateTextResponse) Reset
func (x *ModerateTextResponse) Reset()func (*ModerateTextResponse) String
func (x *ModerateTextResponse) String() stringSentence
type Sentence struct {
// The sentence text.
Text *TextSpan `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
// For calls to [AnalyzeSentiment][] or if
// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]
// is set to true, this field will contain the sentiment for the sentence.
Sentiment *Sentiment `protobuf:"bytes,2,opt,name=sentiment,proto3" json:"sentiment,omitempty"`
// contains filtered or unexported fields
}Represents a sentence in the input document.
func (*Sentence) Descriptor
Deprecated: Use Sentence.ProtoReflect.Descriptor instead.
func (*Sentence) GetSentiment
func (*Sentence) GetText
func (*Sentence) ProtoMessage
func (*Sentence) ProtoMessage()func (*Sentence) ProtoReflect
func (x *Sentence) ProtoReflect() protoreflect.Messagefunc (*Sentence) Reset
func (x *Sentence) Reset()func (*Sentence) String
Sentiment
type Sentiment struct {
// A non-negative number in the [0, +inf) range, which represents
// the absolute magnitude of sentiment regardless of score (positive or
// negative).
Magnitude float32 `protobuf:"fixed32,1,opt,name=magnitude,proto3" json:"magnitude,omitempty"`
// Sentiment score between -1.0 (negative sentiment) and 1.0
// (positive sentiment).
Score float32 `protobuf:"fixed32,2,opt,name=score,proto3" json:"score,omitempty"`
// contains filtered or unexported fields
}Represents the feeling associated with the entire text or entities in the text.
func (*Sentiment) Descriptor
Deprecated: Use Sentiment.ProtoReflect.Descriptor instead.
func (*Sentiment) GetMagnitude
func (*Sentiment) GetScore
func (*Sentiment) ProtoMessage
func (*Sentiment) ProtoMessage()func (*Sentiment) ProtoReflect
func (x *Sentiment) ProtoReflect() protoreflect.Messagefunc (*Sentiment) Reset
func (x *Sentiment) Reset()func (*Sentiment) String
TextSpan
type TextSpan struct {
// The content of the text span, which is a substring of the document.
Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// The API calculates the beginning offset of the content in the original
// document according to the
// [EncodingType][google.cloud.language.v2.EncodingType] specified in the API
// request.
BeginOffset int32 `protobuf:"varint,2,opt,name=begin_offset,json=beginOffset,proto3" json:"begin_offset,omitempty"`
// contains filtered or unexported fields
}Represents a text span in the input document.
func (*TextSpan) Descriptor
Deprecated: Use TextSpan.ProtoReflect.Descriptor instead.
func (*TextSpan) GetBeginOffset
func (*TextSpan) GetContent
func (*TextSpan) ProtoMessage
func (*TextSpan) ProtoMessage()func (*TextSpan) ProtoReflect
func (x *TextSpan) ProtoReflect() protoreflect.Messagefunc (*TextSpan) Reset
func (x *TextSpan) Reset()func (*TextSpan) String
UnimplementedLanguageServiceServer
type UnimplementedLanguageServiceServer struct {
}UnimplementedLanguageServiceServer should be embedded to have forward compatible implementations.
func (UnimplementedLanguageServiceServer) AnalyzeEntities
func (UnimplementedLanguageServiceServer) AnalyzeEntities(context.Context, *AnalyzeEntitiesRequest) (*AnalyzeEntitiesResponse, error)func (UnimplementedLanguageServiceServer) AnalyzeSentiment
func (UnimplementedLanguageServiceServer) AnalyzeSentiment(context.Context, *AnalyzeSentimentRequest) (*AnalyzeSentimentResponse, error)func (UnimplementedLanguageServiceServer) AnnotateText
func (UnimplementedLanguageServiceServer) AnnotateText(context.Context, *AnnotateTextRequest) (*AnnotateTextResponse, error)func (UnimplementedLanguageServiceServer) ClassifyText
func (UnimplementedLanguageServiceServer) ClassifyText(context.Context, *ClassifyTextRequest) (*ClassifyTextResponse, error)func (UnimplementedLanguageServiceServer) ModerateText
func (UnimplementedLanguageServiceServer) ModerateText(context.Context, *ModerateTextRequest) (*ModerateTextResponse, error)UnsafeLanguageServiceServer
type UnsafeLanguageServiceServer interface {
// contains filtered or unexported methods
}UnsafeLanguageServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to LanguageServiceServer will result in compilation errors.