Documentation ¶
Overview ¶
Package glanguage contains some utilities for working with Google's Natural Language API.
Index ¶
- Constants
- func GetMID(e languagepb.Entity) string
- func GetWikipediaURL(e languagepb.Entity) string
- type MockLanguageServer
- func (s *MockLanguageServer) AnalyzeEntities(ctx context.Context, req *languagepb.AnalyzeEntitiesRequest) (*languagepb.AnalyzeEntitiesResponse, error)
- func (s *MockLanguageServer) AnalyzeEntitySentiment(ctx context.Context, req *languagepb.AnalyzeEntitySentimentRequest) (*languagepb.AnalyzeEntitySentimentResponse, error)
- func (s *MockLanguageServer) AnalyzeSentiment(ctx context.Context, req *languagepb.AnalyzeSentimentRequest) (*languagepb.AnalyzeSentimentResponse, error)
- func (s *MockLanguageServer) AnalyzeSyntax(ctx context.Context, req *languagepb.AnalyzeSyntaxRequest) (*languagepb.AnalyzeSyntaxResponse, error)
- func (s *MockLanguageServer) AnnotateText(ctx context.Context, req *languagepb.AnnotateTextRequest) (*languagepb.AnnotateTextResponse, error)
- func (s *MockLanguageServer) ClassifyText(ctx context.Context, req *languagepb.ClassifyTextRequest) (*languagepb.ClassifyTextResponse, error)
Constants ¶
View Source
const ( // Metadata keys in the entity entry // https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity WikipediaKey = "wikipedia_url" MIDKey = "mid" )
Variables ¶
This section is empty.
Functions ¶
func GetMID ¶
func GetMID(e languagepb.Entity) string
GetMID gets the mid (knowledge graph id ) from the entity if there is one otherwise returns the empty string.
func GetWikipediaURL ¶
func GetWikipediaURL(e languagepb.Entity) string
GetWikipediaURL gets the wikipedia url from the entity if there is one otherwise returns the empty string.
Types ¶
type MockLanguageServer ¶
type MockLanguageServer struct { // Embed for forward compatibility. // Tests will keep working if more methods are added // in the future. languagepb.LanguageServiceServer Reqs []proto.Message // If set, all calls return this error. Err error // responses to return if Err == nil Resps []proto.Message }
MockLanguageServer is a mock implementation to be used in tests.
func (*MockLanguageServer) AnalyzeEntities ¶
func (s *MockLanguageServer) AnalyzeEntities(ctx context.Context, req *languagepb.AnalyzeEntitiesRequest) (*languagepb.AnalyzeEntitiesResponse, error)
func (*MockLanguageServer) AnalyzeEntitySentiment ¶
func (s *MockLanguageServer) AnalyzeEntitySentiment(ctx context.Context, req *languagepb.AnalyzeEntitySentimentRequest) (*languagepb.AnalyzeEntitySentimentResponse, error)
func (*MockLanguageServer) AnalyzeSentiment ¶
func (s *MockLanguageServer) AnalyzeSentiment(ctx context.Context, req *languagepb.AnalyzeSentimentRequest) (*languagepb.AnalyzeSentimentResponse, error)
func (*MockLanguageServer) AnalyzeSyntax ¶
func (s *MockLanguageServer) AnalyzeSyntax(ctx context.Context, req *languagepb.AnalyzeSyntaxRequest) (*languagepb.AnalyzeSyntaxResponse, error)
func (*MockLanguageServer) AnnotateText ¶
func (s *MockLanguageServer) AnnotateText(ctx context.Context, req *languagepb.AnnotateTextRequest) (*languagepb.AnnotateTextResponse, error)
func (*MockLanguageServer) ClassifyText ¶
func (s *MockLanguageServer) ClassifyText(ctx context.Context, req *languagepb.ClassifyTextRequest) (*languagepb.ClassifyTextResponse, error)
Click to show internal directories.
Click to hide internal directories.