Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (30 sloc) 955 Bytes
// Copyright 2017 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"context"
"log"
language "cloud.google.com/go/language/apiv1beta2"
languagepb "google.golang.org/genproto/googleapis/cloud/language/v1beta2"
)
func betaClient() *language.Client {
ctx := context.Background()
client, err := language.NewClient(ctx)
if err != nil {
log.Fatal(err)
}
return client
}
// [START language_entity_sentiment_text]
func analyzeEntitySentiment(ctx context.Context, client *language.Client, text string) (*languagepb.AnalyzeEntitySentimentResponse, error) {
return client.AnalyzeEntitySentiment(ctx, &languagepb.AnalyzeEntitySentimentRequest{
Document: &languagepb.Document{
Source: &languagepb.Document_Content{
Content: text,
},
Type: languagepb.Document_PLAIN_TEXT,
},
})
}
// [END language_entity_sentiment_text]