v20230401

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const APIVersion = "2023-04-01"
View Source
const AnalyzeTextAPIPath = "/language/:analyze-text"
View Source
const JobStatusAPIPath = "/language/analyze-text/jobs/{jobId}"
View Source
const SubmitJobAPIPath = "/language/analyze-text/jobs"

Variables

This section is empty.

Functions

func ParseJobID

func ParseJobID(jobLocation string) (string, error)

Types

type AbstractiveSummarizationResult

type AbstractiveSummarizationResult struct {
	// Documents Response by document
	Documents []AbstractiveSummaryDocumentResult `json:"documents"`
	// Errors Errors by document id.
	Errors []DocumentError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type AbstractiveSummarizationTaskParameters

type AbstractiveSummarizationTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
	SentenceCount int    `json:"sentenceCount,omitempty"`
	// StringIndexType Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets.
	StringIndexType string `json:"stringIndexType,omitempty"`
}

type AbstractiveSummary

type AbstractiveSummary struct {
	// Contexts The context list of the summary.
	Contexts []SummaryContext `json:"contexts"`
	// Text The text of the summary.
	Text string `json:"text"`
}

type AbstractiveSummaryDocumentResult

type AbstractiveSummaryDocumentResult struct {
	// ID Unique, non-empty document identifier.
	ID string `json:"id"`
	// Summaries A list of abstractive summaries.
	Summaries []AbstractiveSummary `json:"summaries"`
	// Warnings Warnings encountered while processing document.
	Warnings []DocumentWarning `json:"warnings"`
}

type Client

type Client interface {
	AnalyzeTextLanguageDetection(ctx context.Context, input LanguageDetectionAnalysisInput, parameters LanguageDetectionTaskParameters) (*LanguageDetectionResult, error)
	AnalyzeTextEntityRecognition(ctx context.Context, input MultiLanguageAnalysisInput, parameters EntitiesTaskParameters) (*EntitiesResult, error)
	AnalyzeTextKeyPhraseExtraction(ctx context.Context, input MultiLanguageAnalysisInput, parameters KeyPhraseTaskParameters) (*KeyPhraseResult, error)
	AnalyzeTextSentimentAnalysis(ctx context.Context, input MultiLanguageAnalysisInput, parameters SentimentAnalysisTaskParameters) (*SentimentResponse, error)
	SubmitTextAnalyticsJob(ctx context.Context, input SubmitJobRequestBody) (string, error)
	GetTextAnalyticsJobResult(ctx context.Context, jobID string) (*JobStatusResponse, error)
}

func NewClient

func NewClient(endpoint string, key string, optAppliers ...Option) Client
Example
package main

import (
	"time"

	azuretextanalysis "github.com/kde713/azurelangai-go/textanalysis/v20230401"
)

var azureTextAnalysisClient azuretextanalysis.Client

func main() {
	// Get your endpoint and key from the Azure portal.
	endpoint := "https://<this-is-example>.cognitiveservices.azure.com/"
	key := "<this-is-example>"

	// Create a client.
	azureTextAnalysisClient = azuretextanalysis.NewClient(
		endpoint,
		key,
		azuretextanalysis.WithRetryCount(3, 5*time.Second, 20*time.Second),
	)
}
Output:

type DetectedLanguage

type DetectedLanguage struct {
	// ConfidenceScore A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true.
	ConfidenceScore float64 `json:"confidenceScore"`
	// ISO6391Name A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr).
	ISO6391Name string `json:"iso6391Name"`
	// Name Long name of a detected language (e.g. English, French).
	Name string `json:"name"`
}

type DocumentError

type DocumentError struct {
	// Error Error encountered.
	Error ErrorInformation `json:"error"`
	// ID The ID of the input document.
	ID string `json:"id"`
}

type DocumentWarning

type DocumentWarning struct {
	// Code Error code.
	Code string `json:"code"`
	// Message Warning message.
	Message string `json:"message"`
	// TargetRef A JSON pointer reference indicating the target object.
	TargetRef string `json:"targetRef"`
}

type EntitiesResult

type EntitiesResult struct {
	// Documents Response by document
	Documents []EntityRecognizedDocument `json:"documents"`
	// Errors Errors by document id.
	Errors []DocumentError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type EntitiesTaskParameters

type EntitiesTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
	// StringIndexType Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets.
	StringIndexType string `json:"stringIndexType,omitempty"`
}

type Entity

type Entity struct {
	// Category Entity type.
	Category string `json:"category"`
	// ConfidenceScore Confidence score between 0 and 1 of the extracted entity.
	ConfidenceScore float64 `json:"confidenceScore"`
	// Length Length for the entity text. Use of different 'stringIndexType' values can affect the length returned.
	Length int `json:"length"`
	// Offset Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned.
	Offset int `json:"offset"`
	// SubCategory (Optional) Entity sub type.
	SubCategory string `json:"subcategory"`
	// Text Entity text as appears in the request.
	Text string `json:"text"`
}

type EntityRecognizedDocument

type EntityRecognizedDocument struct {
	// Entities Recognized entities in the document.
	Entities []Entity `json:"entities"`
	// ID Unique, non-empty document identifier.
	ID string `json:"id"`
	// Warnings Warnings encountered while processing document.
	Warnings []DocumentWarning `json:"warnings"`
}

type ErrorInformation

type ErrorInformation struct {
	// Code One of a server-defined set of error codes.
	Code string `json:"code"`
	// Message A human-readable representation of the error.
	Message string `json:"message"`
	// Target The target of the error.
	Target string `json:"target"`
}

type ErrorResponse

type ErrorResponse struct {
	// Error The error object.
	Error ErrorInformation `json:"error"`
}

type ExtractedSummaryDocumentResult

type ExtractedSummaryDocumentResult struct {
	// ID Unique, non-empty document identifier.
	ID string `json:"id"`
	// Sentences A ranked list of sentences representing the extracted summary.
	Sentences []ExtractedSummarySentence `json:"sentences"`
	// Warnings Warnings encountered while processing document.
	Warnings []DocumentWarning `json:"warnings"`
}

type ExtractedSummarySentence

type ExtractedSummarySentence struct {
	// Length The length of the sentence.
	Length int `json:"length"`
	// Offset The sentence offset from the start of the document, based on the value of the parameter StringIndexType.
	Offset int `json:"offset"`
	// RankScore A double value representing the relevance of the sentence within the summary. Higher values indicate higher importance.
	RankScore float64 `json:"rankScore"`
	// Text The extracted sentence text.
	Text string `json:"text"`
}

type ExtractiveSummarizationResult

type ExtractiveSummarizationResult struct {
	// Documents Response by document
	Documents []ExtractedSummaryDocumentResult `json:"documents"`
	// Errors Errors by document id.
	Errors []DocumentError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type ExtractiveSummarizationTaskParameters

type ExtractiveSummarizationTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
	SentenceCount int    `json:"sentenceCount,omitempty"`
	// SortBy The sorting criteria to use for the results of Extractive Summarization.
	// "Offset" (Default): Indicates that results should be sorted in order of appearance in the text.
	// "Rank": Indicates that results should be sorted in order of importance (i.e. rank score) according to the model.
	SortBy string `json:"sortBy,omitempty"`
	// StringIndexType Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets.
	StringIndexType string `json:"stringIndexType,omitempty"`
}

type InputError

type InputError struct {
	// Error Error encountered.
	Error ErrorInformation `json:"error"`
	// ID The ID of the input.
	ID string `json:"id"`
}

type JobStatus

type JobStatus string
const (
	StatusCancelled          JobStatus = "cancelled"
	StatusCancelling         JobStatus = "cancelling"
	StatusFailed             JobStatus = "failed"
	StatusNotStarted         JobStatus = "notStarted"
	StatusPartiallyCompleted JobStatus = "partiallyCompleted"
	StatusRunning            JobStatus = "running"
	StatusSucceeded          JobStatus = "succeeded"
)

type JobStatusResponse

type JobStatusResponse struct {
	CreatedDateTime    string             `json:"createdDateTime"`
	DisplayName        string             `json:"displayName"`
	Errors             []ErrorInformation `json:"errors"`
	ExpirationDateTime string             `json:"expirationDateTime"`
	JobID              string             `json:"jobId"`
	LastUpdateDateTime string             `json:"lastUpdateDateTime"`
	NextLink           string             `json:"nextLink"`
	Status             JobStatus          `json:"status"`
	Tasks              Tasks              `json:"tasks"`
}

type KeyPhraseResult

type KeyPhraseResult struct {
	// Documents Response by document
	Documents []KeyPhrasesExtractedDocument `json:"documents"`
	// Errors Errors by document id.
	Errors []DocumentError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type KeyPhraseTaskParameters

type KeyPhraseTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
}

type KeyPhrasesExtractedDocument

type KeyPhrasesExtractedDocument struct {
	// ID Unique, non-empty document identifier.
	ID string `json:"id"`
	// Warnings Warnings encountered while processing document.
	Warnings   []DocumentWarning `json:"warnings"`
	KeyPhrases []string          `json:"keyPhrases"`
}

type LROBuilder

type LROBuilder struct {
	// contains filtered or unexported fields
}

func NewJobBuilder

func NewJobBuilder(displayName string, input MultiLanguageAnalysisInput) *LROBuilder

func (*LROBuilder) AddAbstractiveSummarizationTask

func (b *LROBuilder) AddAbstractiveSummarizationTask(taskName string, parameters AbstractiveSummarizationTaskParameters)

func (*LROBuilder) AddEntityRecognitionTask

func (b *LROBuilder) AddEntityRecognitionTask(taskName string, parameters EntitiesTaskParameters)

func (*LROBuilder) AddExtractiveSummarizationTask

func (b *LROBuilder) AddExtractiveSummarizationTask(taskName string, parameters ExtractiveSummarizationTaskParameters)

func (*LROBuilder) AddKeyPhraseExtractionTask

func (b *LROBuilder) AddKeyPhraseExtractionTask(taskName string, parameters KeyPhraseTaskParameters)

func (*LROBuilder) AddSentimentAnalysisTask

func (b *LROBuilder) AddSentimentAnalysisTask(taskName string, parameters SentimentAnalysisTaskParameters)

func (*LROBuilder) Build

func (b *LROBuilder) Build() (*SubmitJobRequestBody, error)

type LROKind

type LROKind string
const (
	LROKindEntityRecognition        LROKind = "EntityRecognitionLROResults"
	LROKindKeyPhraseExtraction      LROKind = "KeyPhraseExtractionLROResults"
	LROKindSentimentAnalysis        LROKind = "SentimentAnalysisLROResults"
	LROKindExtractiveSummarization  LROKind = "ExtractiveSummarizationLROResults"
	LROKindAbstractiveSummarization LROKind = "AbstractiveSummarizationLROResults"
)

type LROResult

type LROResult struct {
	// Kind Enumeration of supported Text Analysis long-running operation task results.
	Kind               LROKind
	LastUpdateDateTime string
	Results            interface{}
	Status             JobStatus
	TaskName           string
}

func (*LROResult) UnmarshalJSON

func (r *LROResult) UnmarshalJSON(bytes []byte) error

type LanguageDetectionAnalysisInput

type LanguageDetectionAnalysisInput struct {
	Documents []LanguageInput `json:"documents"`
}

type LanguageDetectionDocumentResult

type LanguageDetectionDocumentResult struct {
	// DetectedLanguage Detected Language.
	DetectedLanguage DetectedLanguage `json:"detectedLanguage"`
	// ID Unique, non-empty document identifier.
	ID string `json:"id"`
	// Warnings Warnings encountered while processing document.
	Warnings []DocumentWarning `json:"warnings"`
}

type LanguageDetectionResult

type LanguageDetectionResult struct {
	// Documents Response by document
	Documents []LanguageDetectionDocumentResult `json:"documents"`
	// Errors Errors by document id.
	Errors []InputError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type LanguageDetectionTaskParameters

type LanguageDetectionTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
}

type LanguageInput

type LanguageInput struct {
	CountryHint string `json:"countryHint,omitempty"`
	// ID Unique, non-empty document identifier.
	ID   string `json:"id"`
	Text string `json:"text"`
}

type MultiLanguageAnalysisInput

type MultiLanguageAnalysisInput struct {
	// Documents Contains an input document to be analyzed by the service.
	Documents []MultiLanguageInput `json:"documents"`
}

type MultiLanguageInput

type MultiLanguageInput struct {
	// ID A unique, non-empty document identifier.
	ID string `json:"id"`
	// Language (Optional) This is the 2 letter ISO 639-1 representation of a language. For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default.
	Language string `json:"language,omitempty"`
	// Text The input text to process.
	Text string `json:"text"`
}

type Option added in v0.0.2

type Option func(*options)

func WithRetryCount added in v0.0.2

func WithRetryCount(count int, minWait time.Duration, maxWait time.Duration) Option

type RequestBody

type RequestBody[AnalysisInput any, Parameters any] struct {
	// Kind Enumeration of supported Text Analysis tasks.
	Kind          TaskKind      `json:"kind"`
	AnalysisInput AnalysisInput `json:"analysisInput"`
	// Parameters Supported parameters for requesting analysis task.
	Parameters Parameters `json:"parameters"`
}

type SentenceSentiment

type SentenceSentiment struct {
	Sentiment        Sentiment                 `json:"sentiment"`
	ConfidenceScores SentimentConfidenceScores `json:"confidenceScores"`
	Offset           int                       `json:"offset"`
	Length           int                       `json:"length"`
	Text             string                    `json:"text"`
}

type Sentiment

type Sentiment string
const (
	SentimentPositive Sentiment = "positive"
	SentimentNeutral  Sentiment = "neutral"
	SentimentNegative Sentiment = "negative"
	SentimentMixed    Sentiment = "mixed"
)

type SentimentAnalysisTaskParameters

type SentimentAnalysisTaskParameters struct {
	LoggingOptOut bool   `json:"loggingOptOut,omitempty"`
	ModelVersion  string `json:"modelVersion,omitempty"`
	OpinionMining bool   `json:"opinionMining,omitempty"`
	// StringIndexType Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets.
	StringIndexType string `json:"stringIndexType,omitempty"`
}

type SentimentAnalyzedDocument

type SentimentAnalyzedDocument struct {
	// ID Unique, non-empty document identifier.
	ID               string                    `json:"id"`
	Sentiment        Sentiment                 `json:"sentiment"`
	ConfidenceScores SentimentConfidenceScores `json:"confidenceScores"`
	Sentences        []SentenceSentiment       `json:"sentences"`
	Warnings         []DocumentWarning         `json:"warnings"`
}

type SentimentConfidenceScores

type SentimentConfidenceScores struct {
	Positive float64 `json:"positive"`
	Negative float64 `json:"negative"`
	Neutral  float64 `json:"neutral"`
}

type SentimentResponse

type SentimentResponse struct {
	// Documents Response by document
	Documents []SentimentAnalyzedDocument `json:"documents"`
	// Errors Errors by document id.
	Errors []DocumentError `json:"errors"`
	// ModelVersion This field indicates which model is used for scoring.
	ModelVersion string `json:"modelVersion"`
}

type SubmitJobRequestBody

type SubmitJobRequestBody struct {
	AnalysisInput MultiLanguageAnalysisInput `json:"analysisInput"`
	Tasks         []TaskRequest              `json:"tasks"`
	DisplayName   string                     `json:"displayName"`
}

type SummaryContext

type SummaryContext struct {
	// Length The length of the context. Use of different 'stringIndexType' values can affect the length returned.
	Length int `json:"length"`
	// Offset Start position for the context. Use of different 'stringIndexType' values can affect the offset returned.
	Offset int `json:"offset"`
}

type TaskError

type TaskError struct {
	Information ErrorInformation
}

func (*TaskError) Error

func (e *TaskError) Error() string

type TaskKind

type TaskKind string
const (
	TaskKindLanguageDetection        TaskKind = "LanguageDetection"
	TaskKindEntityRecognition        TaskKind = "EntityRecognition"
	TaskKindKeyPhraseExtraction      TaskKind = "KeyPhraseExtraction"
	TaskKindSentimentAnalysis        TaskKind = "SentimentAnalysis"
	TaskKindExtractiveSummarization  TaskKind = "ExtractiveSummarization"
	TaskKindAbstractiveSummarization TaskKind = "AbstractiveSummarization"
)

type TaskRequest

type TaskRequest struct {
	// Kind Enumeration of supported long-running Text Analysis tasks.
	Kind       TaskKind    `json:"kind"`
	Parameters interface{} `json:"parameters"`
	TaskName   string      `json:"taskName"`
}

type TaskResponse

type TaskResponse[Results any] struct {
	// Kind Enumeration of supported Text Analysis task results.
	Kind    TaskKind `json:"kind"`
	Results Results  `json:"results"`
}

type Tasks

type Tasks struct {
	Completed  int         `json:"completed"`
	Failed     int         `json:"failed"`
	InProgress int         `json:"inProgress"`
	Items      []LROResult `json:"items"`
	Total      int         `json:"total"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL