naturallanguageclassifierv1

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package naturallanguageclassifierv1 : Operations and models for the NaturalLanguageClassifierV1 service

Index

Constants

View Source
const (
	ClassifierStatusAvailableConst   = "Available"
	ClassifierStatusFailedConst      = "Failed"
	ClassifierStatusNonExistentConst = "Non Existent"
	ClassifierStatusTrainingConst    = "Training"
	ClassifierStatusUnavailableConst = "Unavailable"
)

Constants associated with the Classifier.Status property. The state of the classifier.

View Source
const DefaultServiceName = "natural_language_classifier"

DefaultServiceName is the default key used to find external configuration information.

View Source
const DefaultServiceURL = "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"

DefaultServiceURL is the default URL to make service requests to.

Variables

This section is empty.

Functions

func GetServiceURLForRegion

func GetServiceURLForRegion(region string) (string, error)

GetServiceURLForRegion returns the service URL to be used for the specified region

func UnmarshalClassification

func UnmarshalClassification(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassification unmarshals an instance of Classification from the specified map of raw messages.

func UnmarshalClassificationCollection

func UnmarshalClassificationCollection(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassificationCollection unmarshals an instance of ClassificationCollection from the specified map of raw messages.

func UnmarshalClassifiedClass

func UnmarshalClassifiedClass(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassifiedClass unmarshals an instance of ClassifiedClass from the specified map of raw messages.

func UnmarshalClassifier

func UnmarshalClassifier(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassifier unmarshals an instance of Classifier from the specified map of raw messages.

func UnmarshalClassifierList

func UnmarshalClassifierList(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassifierList unmarshals an instance of ClassifierList from the specified map of raw messages.

func UnmarshalClassifyInput

func UnmarshalClassifyInput(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalClassifyInput unmarshals an instance of ClassifyInput from the specified map of raw messages.

func UnmarshalCollectionItem

func UnmarshalCollectionItem(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalCollectionItem unmarshals an instance of CollectionItem from the specified map of raw messages.

Types

type Classification

type Classification struct {
	// Unique identifier for this classifier.
	ClassifierID *string `json:"classifier_id,omitempty"`

	// Link to the classifier.
	URL *string `json:"url,omitempty"`

	// The submitted phrase.
	Text *string `json:"text,omitempty"`

	// The class with the highest confidence.
	TopClass *string `json:"top_class,omitempty"`

	// An array of up to ten class-confidence pairs sorted in descending order of confidence.
	Classes []ClassifiedClass `json:"classes,omitempty"`
}

Classification : Response from the classifier for a phrase.

type ClassificationCollection

type ClassificationCollection struct {
	// Unique identifier for this classifier.
	ClassifierID *string `json:"classifier_id,omitempty"`

	// Link to the classifier.
	URL *string `json:"url,omitempty"`

	// An array of classifier responses for each submitted phrase.
	Collection []CollectionItem `json:"collection,omitempty"`
}

ClassificationCollection : Response from the classifier for multiple phrases.

type ClassifiedClass

type ClassifiedClass struct {
	// A decimal percentage that represents the confidence that Watson has in this class. Higher values represent higher
	// confidences.
	Confidence *float64 `json:"confidence,omitempty"`

	// Class label.
	ClassName *string `json:"class_name,omitempty"`
}

ClassifiedClass : Class and confidence.

type Classifier

type Classifier struct {
	// User-supplied name for the classifier.
	Name *string `json:"name,omitempty"`

	// Link to the classifier.
	URL *string `json:"url" validate:"required"`

	// The state of the classifier.
	Status *string `json:"status,omitempty"`

	// Unique identifier for this classifier.
	ClassifierID *string `json:"classifier_id" validate:"required"`

	// Date and time (UTC) the classifier was created.
	Created *strfmt.DateTime `json:"created,omitempty"`

	// Additional detail about the status.
	StatusDescription *string `json:"status_description,omitempty"`

	// The language used for the classifier.
	Language *string `json:"language,omitempty"`
}

Classifier : A classifier for natural language phrases.

type ClassifierList

type ClassifierList struct {
	// The classifiers available to the user. Returns an empty array if no classifiers are available.
	Classifiers []Classifier `json:"classifiers" validate:"required"`
}

ClassifierList : List of available classifiers.

type ClassifyCollectionOptions

type ClassifyCollectionOptions struct {
	// Classifier ID to use.
	ClassifierID *string `json:"-" validate:"required,ne="`

	// The submitted phrases.
	Collection []ClassifyInput `json:"collection" validate:"required"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

ClassifyCollectionOptions : The ClassifyCollection options.

func (*ClassifyCollectionOptions) SetClassifierID

func (_options *ClassifyCollectionOptions) SetClassifierID(classifierID string) *ClassifyCollectionOptions

SetClassifierID : Allow user to set ClassifierID

func (*ClassifyCollectionOptions) SetCollection

func (_options *ClassifyCollectionOptions) SetCollection(collection []ClassifyInput) *ClassifyCollectionOptions

SetCollection : Allow user to set Collection

func (*ClassifyCollectionOptions) SetHeaders

func (options *ClassifyCollectionOptions) SetHeaders(param map[string]string) *ClassifyCollectionOptions

SetHeaders : Allow user to set Headers

type ClassifyInput

type ClassifyInput struct {
	// The submitted phrase. The maximum length is 2048 characters.
	Text *string `json:"text" validate:"required"`
}

ClassifyInput : Request payload to classify.

type ClassifyOptions

type ClassifyOptions struct {
	// Classifier ID to use.
	ClassifierID *string `json:"-" validate:"required,ne="`

	// The submitted phrase. The maximum length is 2048 characters.
	Text *string `json:"text" validate:"required"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

ClassifyOptions : The Classify options.

func (*ClassifyOptions) SetClassifierID

func (_options *ClassifyOptions) SetClassifierID(classifierID string) *ClassifyOptions

SetClassifierID : Allow user to set ClassifierID

func (*ClassifyOptions) SetHeaders

func (options *ClassifyOptions) SetHeaders(param map[string]string) *ClassifyOptions

SetHeaders : Allow user to set Headers

func (*ClassifyOptions) SetText

func (_options *ClassifyOptions) SetText(text string) *ClassifyOptions

SetText : Allow user to set Text

type CollectionItem

type CollectionItem struct {
	// The submitted phrase. The maximum length is 2048 characters.
	Text *string `json:"text,omitempty"`

	// The class with the highest confidence.
	TopClass *string `json:"top_class,omitempty"`

	// An array of up to ten class-confidence pairs sorted in descending order of confidence.
	Classes []ClassifiedClass `json:"classes,omitempty"`
}

CollectionItem : Response from the classifier for a phrase in a collection.

type CreateClassifierOptions

type CreateClassifierOptions struct {
	// Metadata in JSON format. The metadata identifies the language of the data, and an optional name to identify the
	// classifier. Specify the language with the 2-letter primary language code as assigned in ISO standard 639.
	//
	// Supported languages are English (`en`), Arabic (`ar`), French (`fr`), German, (`de`), Italian (`it`), Japanese
	// (`ja`), Korean (`ko`), Brazilian Portuguese (`pt`), and Spanish (`es`).
	TrainingMetadata io.ReadCloser `json:"-" validate:"required"`

	// Training data in CSV format. Each text value must have at least one class. The data can include up to 3,000 classes
	// and 20,000 records. For details, see [Data
	// preparation](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-using-your-data).
	TrainingData io.ReadCloser `json:"-" validate:"required"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

CreateClassifierOptions : The CreateClassifier options.

func (*CreateClassifierOptions) SetHeaders

func (options *CreateClassifierOptions) SetHeaders(param map[string]string) *CreateClassifierOptions

SetHeaders : Allow user to set Headers

func (*CreateClassifierOptions) SetTrainingData

func (_options *CreateClassifierOptions) SetTrainingData(trainingData io.ReadCloser) *CreateClassifierOptions

SetTrainingData : Allow user to set TrainingData

func (*CreateClassifierOptions) SetTrainingMetadata

func (_options *CreateClassifierOptions) SetTrainingMetadata(trainingMetadata io.ReadCloser) *CreateClassifierOptions

SetTrainingMetadata : Allow user to set TrainingMetadata

type DeleteClassifierOptions

type DeleteClassifierOptions struct {
	// Classifier ID to delete.
	ClassifierID *string `json:"-" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

DeleteClassifierOptions : The DeleteClassifier options.

func (*DeleteClassifierOptions) SetClassifierID

func (_options *DeleteClassifierOptions) SetClassifierID(classifierID string) *DeleteClassifierOptions

SetClassifierID : Allow user to set ClassifierID

func (*DeleteClassifierOptions) SetHeaders

func (options *DeleteClassifierOptions) SetHeaders(param map[string]string) *DeleteClassifierOptions

SetHeaders : Allow user to set Headers

type GetClassifierOptions

type GetClassifierOptions struct {
	// Classifier ID to query.
	ClassifierID *string `json:"-" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

GetClassifierOptions : The GetClassifier options.

func (*GetClassifierOptions) SetClassifierID

func (_options *GetClassifierOptions) SetClassifierID(classifierID string) *GetClassifierOptions

SetClassifierID : Allow user to set ClassifierID

func (*GetClassifierOptions) SetHeaders

func (options *GetClassifierOptions) SetHeaders(param map[string]string) *GetClassifierOptions

SetHeaders : Allow user to set Headers

type ListClassifiersOptions

type ListClassifiersOptions struct {

	// Allows users to set headers on API requests
	Headers map[string]string
}

ListClassifiersOptions : The ListClassifiers options.

func (*ListClassifiersOptions) SetHeaders

func (options *ListClassifiersOptions) SetHeaders(param map[string]string) *ListClassifiersOptions

SetHeaders : Allow user to set Headers

type NaturalLanguageClassifierV1

type NaturalLanguageClassifierV1 struct {
	Service *core.BaseService
}

NaturalLanguageClassifierV1 : On 9 August 2021, IBM announced the deprecation of IBM Watson&trade; Natural Language Classifier. As of 9 September 2021, you cannot create new instances. However, existing instances are supported until 8 August 2022. The service will no longer be available on 8 August 2022.<br/><br/>As an alternative, consider migrating to IBM Watson Natural Language Understanding. For more information, see [Migrating to Natural Language Understanding](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-migrating). {: deprecated}

Natural Language Classifier uses machine learning algorithms to return the top matching predefined classes for short text input. You create and train a classifier to connect predefined classes to example texts so that the service can apply those classes to new inputs.

API Version: 1.0 See: https://cloud.ibm.com/docs/natural-language-classifier

func NewNaturalLanguageClassifierV1

func NewNaturalLanguageClassifierV1(options *NaturalLanguageClassifierV1Options) (service *NaturalLanguageClassifierV1, err error)

NewNaturalLanguageClassifierV1 : constructs an instance of NaturalLanguageClassifierV1 with passed in options.

func (*NaturalLanguageClassifierV1) Classify

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) Classify(classifyOptions *ClassifyOptions) (result *Classification, response *core.DetailedResponse, err error)

Classify : Classify a phrase Returns label information for the input. The status must be `Available` before you can use the classifier to classify text.

func (*NaturalLanguageClassifierV1) ClassifyCollection

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) ClassifyCollection(classifyCollectionOptions *ClassifyCollectionOptions) (result *ClassificationCollection, response *core.DetailedResponse, err error)

ClassifyCollection : Classify multiple phrases Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to classify text.

Note that classifying Japanese texts is a beta feature.

func (*NaturalLanguageClassifierV1) ClassifyCollectionWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) ClassifyCollectionWithContext(ctx context.Context, classifyCollectionOptions *ClassifyCollectionOptions) (result *ClassificationCollection, response *core.DetailedResponse, err error)

ClassifyCollectionWithContext is an alternate form of the ClassifyCollection method which supports a Context parameter

func (*NaturalLanguageClassifierV1) ClassifyWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) ClassifyWithContext(ctx context.Context, classifyOptions *ClassifyOptions) (result *Classification, response *core.DetailedResponse, err error)

ClassifyWithContext is an alternate form of the Classify method which supports a Context parameter

func (*NaturalLanguageClassifierV1) Clone

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) Clone() *NaturalLanguageClassifierV1

Clone makes a copy of "naturalLanguageClassifier" suitable for processing requests.

func (*NaturalLanguageClassifierV1) CreateClassifier

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) CreateClassifier(createClassifierOptions *CreateClassifierOptions) (result *Classifier, response *core.DetailedResponse, err error)

CreateClassifier : Create classifier Sends data to create and train a classifier and returns information about the new classifier.

func (*NaturalLanguageClassifierV1) CreateClassifierWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) CreateClassifierWithContext(ctx context.Context, createClassifierOptions *CreateClassifierOptions) (result *Classifier, response *core.DetailedResponse, err error)

CreateClassifierWithContext is an alternate form of the CreateClassifier method which supports a Context parameter

func (*NaturalLanguageClassifierV1) DeleteClassifier

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) DeleteClassifier(deleteClassifierOptions *DeleteClassifierOptions) (response *core.DetailedResponse, err error)

DeleteClassifier : Delete classifier

func (*NaturalLanguageClassifierV1) DeleteClassifierWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) DeleteClassifierWithContext(ctx context.Context, deleteClassifierOptions *DeleteClassifierOptions) (response *core.DetailedResponse, err error)

DeleteClassifierWithContext is an alternate form of the DeleteClassifier method which supports a Context parameter

func (*NaturalLanguageClassifierV1) DisableRetries

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) DisableRetries()

DisableRetries disables automatic retries for requests invoked for this service instance.

func (*NaturalLanguageClassifierV1) DisableSSLVerification

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) DisableSSLVerification()

DisableSSLVerification bypasses verification of the server's SSL certificate

func (*NaturalLanguageClassifierV1) EnableRetries

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) EnableRetries(maxRetries int, maxRetryInterval time.Duration)

EnableRetries enables automatic retries for requests invoked for this service instance. If either parameter is specified as 0, then a default value is used instead.

func (*NaturalLanguageClassifierV1) GetClassifier

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) GetClassifier(getClassifierOptions *GetClassifierOptions) (result *Classifier, response *core.DetailedResponse, err error)

GetClassifier : Get information about a classifier Returns status and other information about a classifier.

func (*NaturalLanguageClassifierV1) GetClassifierWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) GetClassifierWithContext(ctx context.Context, getClassifierOptions *GetClassifierOptions) (result *Classifier, response *core.DetailedResponse, err error)

GetClassifierWithContext is an alternate form of the GetClassifier method which supports a Context parameter

func (*NaturalLanguageClassifierV1) GetEnableGzipCompression

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) GetEnableGzipCompression() bool

GetEnableGzipCompression returns the service's EnableGzipCompression field

func (*NaturalLanguageClassifierV1) GetServiceURL

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) GetServiceURL() string

GetServiceURL returns the service URL

func (*NaturalLanguageClassifierV1) ListClassifiers

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) ListClassifiers(listClassifiersOptions *ListClassifiersOptions) (result *ClassifierList, response *core.DetailedResponse, err error)

ListClassifiers : List classifiers Returns an empty array if no classifiers are available.

func (*NaturalLanguageClassifierV1) ListClassifiersWithContext

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) ListClassifiersWithContext(ctx context.Context, listClassifiersOptions *ListClassifiersOptions) (result *ClassifierList, response *core.DetailedResponse, err error)

ListClassifiersWithContext is an alternate form of the ListClassifiers method which supports a Context parameter

func (*NaturalLanguageClassifierV1) NewClassifyCollectionOptions

func (*NaturalLanguageClassifierV1) NewClassifyCollectionOptions(classifierID string, collection []ClassifyInput) *ClassifyCollectionOptions

NewClassifyCollectionOptions : Instantiate ClassifyCollectionOptions

func (*NaturalLanguageClassifierV1) NewClassifyInput

func (*NaturalLanguageClassifierV1) NewClassifyInput(text string) (_model *ClassifyInput, err error)

NewClassifyInput : Instantiate ClassifyInput (Generic Model Constructor)

func (*NaturalLanguageClassifierV1) NewClassifyOptions

func (*NaturalLanguageClassifierV1) NewClassifyOptions(classifierID string, text string) *ClassifyOptions

NewClassifyOptions : Instantiate ClassifyOptions

func (*NaturalLanguageClassifierV1) NewCreateClassifierOptions

func (*NaturalLanguageClassifierV1) NewCreateClassifierOptions(trainingMetadata io.ReadCloser, trainingData io.ReadCloser) *CreateClassifierOptions

NewCreateClassifierOptions : Instantiate CreateClassifierOptions

func (*NaturalLanguageClassifierV1) NewDeleteClassifierOptions

func (*NaturalLanguageClassifierV1) NewDeleteClassifierOptions(classifierID string) *DeleteClassifierOptions

NewDeleteClassifierOptions : Instantiate DeleteClassifierOptions

func (*NaturalLanguageClassifierV1) NewGetClassifierOptions

func (*NaturalLanguageClassifierV1) NewGetClassifierOptions(classifierID string) *GetClassifierOptions

NewGetClassifierOptions : Instantiate GetClassifierOptions

func (*NaturalLanguageClassifierV1) NewListClassifiersOptions

func (*NaturalLanguageClassifierV1) NewListClassifiersOptions() *ListClassifiersOptions

NewListClassifiersOptions : Instantiate ListClassifiersOptions

func (*NaturalLanguageClassifierV1) SetDefaultHeaders

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) SetDefaultHeaders(headers http.Header)

SetDefaultHeaders sets HTTP headers to be sent in every request

func (*NaturalLanguageClassifierV1) SetEnableGzipCompression

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) SetEnableGzipCompression(enableGzip bool)

SetEnableGzipCompression sets the service's EnableGzipCompression field

func (*NaturalLanguageClassifierV1) SetServiceURL

func (naturalLanguageClassifier *NaturalLanguageClassifierV1) SetServiceURL(url string) error

SetServiceURL sets the service URL

type NaturalLanguageClassifierV1Options

type NaturalLanguageClassifierV1Options struct {
	ServiceName   string
	URL           string
	Authenticator core.Authenticator
}

NaturalLanguageClassifierV1Options : Service options

Jump to

Keyboard shortcuts

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