Documentation
¶
Overview ¶
Package toneanalyzerv3 : Operations and models for the ToneAnalyzerV3 service
Index ¶
- Constants
- type DocumentAnalysis
- type SentenceAnalysis
- type ToneAnalysis
- type ToneAnalyzerV3
- func (toneAnalyzer *ToneAnalyzerV3) DisableSSLVerification()
- func (toneAnalyzer *ToneAnalyzerV3) NewToneChatOptions(utterances []Utterance) *ToneChatOptions
- func (toneAnalyzer *ToneAnalyzerV3) NewToneInput(text string) (model *ToneInput, err error)
- func (toneAnalyzer *ToneAnalyzerV3) NewToneOptions() *ToneOptions
- func (toneAnalyzer *ToneAnalyzerV3) NewUtterance(text string) (model *Utterance, err error)
- func (toneAnalyzer *ToneAnalyzerV3) SetServiceURL(url string) error
- func (toneAnalyzer *ToneAnalyzerV3) Tone(toneOptions *ToneOptions) (result *ToneAnalysis, response *core.DetailedResponse, err error)
- func (toneAnalyzer *ToneAnalyzerV3) ToneChat(toneChatOptions *ToneChatOptions) (result *UtteranceAnalyses, response *core.DetailedResponse, err error)
- type ToneAnalyzerV3Options
- type ToneCategory
- type ToneChatOptions
- func (options *ToneChatOptions) SetAcceptLanguage(acceptLanguage string) *ToneChatOptions
- func (options *ToneChatOptions) SetContentLanguage(contentLanguage string) *ToneChatOptions
- func (options *ToneChatOptions) SetHeaders(param map[string]string) *ToneChatOptions
- func (options *ToneChatOptions) SetUtterances(utterances []Utterance) *ToneChatOptions
- type ToneChatScore
- type ToneInput
- type ToneOptions
- func (options *ToneOptions) SetAcceptLanguage(acceptLanguage string) *ToneOptions
- func (options *ToneOptions) SetBody(body string) *ToneOptions
- func (options *ToneOptions) SetContentLanguage(contentLanguage string) *ToneOptions
- func (options *ToneOptions) SetContentType(contentType string) *ToneOptions
- func (options *ToneOptions) SetHeaders(param map[string]string) *ToneOptions
- func (options *ToneOptions) SetSentences(sentences bool) *ToneOptions
- func (options *ToneOptions) SetToneInput(toneInput *ToneInput) *ToneOptions
- func (options *ToneOptions) SetTones(tones []string) *ToneOptions
- type ToneScore
- type Utterance
- type UtteranceAnalyses
- type UtteranceAnalysis
Constants ¶
const ( ToneChatOptions_ContentLanguage_En = "en" ToneChatOptions_ContentLanguage_Fr = "fr" )
Constants associated with the ToneChatOptions.ContentLanguage property. The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for **Content-Language** and **Accept-Language**. * **`2017-09-21`:** Accepts `en` or `fr`. * **`2016-05-19`:** Accepts only `en`.
const ( ToneChatOptions_AcceptLanguage_Ar = "ar" ToneChatOptions_AcceptLanguage_De = "de" ToneChatOptions_AcceptLanguage_En = "en" ToneChatOptions_AcceptLanguage_Es = "es" ToneChatOptions_AcceptLanguage_Fr = "fr" ToneChatOptions_AcceptLanguage_It = "it" ToneChatOptions_AcceptLanguage_Ja = "ja" ToneChatOptions_AcceptLanguage_Ko = "ko" ToneChatOptions_AcceptLanguage_PtBr = "pt-br" ToneChatOptions_AcceptLanguage_ZhCn = "zh-cn" ToneChatOptions_AcceptLanguage_ZhTw = "zh-tw" )
Constants associated with the ToneChatOptions.AcceptLanguage property. The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and **Accept-Language**.
const ( ToneChatScore_ToneID_Excited = "excited" ToneChatScore_ToneID_Frustrated = "frustrated" ToneChatScore_ToneID_Impolite = "impolite" ToneChatScore_ToneID_Polite = "polite" ToneChatScore_ToneID_Sad = "sad" ToneChatScore_ToneID_Satisfied = "satisfied" ToneChatScore_ToneID_Sympathetic = "sympathetic" )
Constants associated with the ToneChatScore.ToneID property. The unique, non-localized identifier of the tone for the results. The service returns results only for tones whose scores meet a minimum threshold of 0.5.
const ( ToneOptions_Tone_Emotion = "emotion" ToneOptions_Tone_Language = "language" ToneOptions_Tone_Social = "social" )
Constants associated with the ToneOptions.Tone property.
const ( ToneOptions_ContentLanguage_En = "en" ToneOptions_ContentLanguage_Fr = "fr" )
Constants associated with the ToneOptions.ContentLanguage property. The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for **Content-Language** and **Accept-Language**. * **`2017-09-21`:** Accepts `en` or `fr`. * **`2016-05-19`:** Accepts only `en`.
const ( ToneOptions_AcceptLanguage_Ar = "ar" ToneOptions_AcceptLanguage_De = "de" ToneOptions_AcceptLanguage_En = "en" ToneOptions_AcceptLanguage_Es = "es" ToneOptions_AcceptLanguage_Fr = "fr" ToneOptions_AcceptLanguage_It = "it" ToneOptions_AcceptLanguage_Ja = "ja" ToneOptions_AcceptLanguage_Ko = "ko" ToneOptions_AcceptLanguage_PtBr = "pt-br" ToneOptions_AcceptLanguage_ZhCn = "zh-cn" ToneOptions_AcceptLanguage_ZhTw = "zh-tw" )
Constants associated with the ToneOptions.AcceptLanguage property. The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and **Accept-Language**.
const DefaultServiceName = "tone_analyzer"
DefaultServiceName is the default key used to find external configuration information.
const DefaultServiceURL = "https://api.us-south.tone-analyzer.watson.cloud.ibm.com"
DefaultServiceURL is the default URL to make service requests to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocumentAnalysis ¶
type DocumentAnalysis struct { // **`2017-09-21`:** An array of `ToneScore` objects that provides the results of the analysis for each qualifying tone // of the document. The array includes results for any tone whose score is at least 0.5. The array is empty if no tone // has a score that meets this threshold. **`2016-05-19`:** Not returned. Tones []ToneScore `json:"tones,omitempty"` // **`2017-09-21`:** Not returned. **`2016-05-19`:** An array of `ToneCategory` objects that provides the results of // the tone analysis for the full document of the input content. The service returns results only for the tones // specified with the `tones` parameter of the request. ToneCategories []ToneCategory `json:"tone_categories,omitempty"` // **`2017-09-21`:** A warning message if the overall content exceeds 128 KB or contains more than 1000 sentences. The // service analyzes only the first 1000 sentences for document-level analysis and the first 100 sentences for // sentence-level analysis. **`2016-05-19`:** Not returned. Warning *string `json:"warning,omitempty"` }
DocumentAnalysis : The results of the analysis for the full input content.
type SentenceAnalysis ¶
type SentenceAnalysis struct { // The unique identifier of a sentence of the input content. The first sentence has ID 0, and the ID of each subsequent // sentence is incremented by one. SentenceID *int64 `json:"sentence_id" validate:"required"` // The text of the input sentence. Text *string `json:"text" validate:"required"` // **`2017-09-21`:** An array of `ToneScore` objects that provides the results of the analysis for each qualifying tone // of the sentence. The array includes results for any tone whose score is at least 0.5. The array is empty if no tone // has a score that meets this threshold. **`2016-05-19`:** Not returned. Tones []ToneScore `json:"tones,omitempty"` // **`2017-09-21`:** Not returned. **`2016-05-19`:** An array of `ToneCategory` objects that provides the results of // the tone analysis for the sentence. The service returns results only for the tones specified with the `tones` // parameter of the request. ToneCategories []ToneCategory `json:"tone_categories,omitempty"` // **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the first character of the sentence in the overall // input content. InputFrom *int64 `json:"input_from,omitempty"` // **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the last character of the sentence in the overall // input content. InputTo *int64 `json:"input_to,omitempty"` }
SentenceAnalysis : The results of the analysis for the individual sentences of the input content.
type ToneAnalysis ¶
type ToneAnalysis struct { // The results of the analysis for the full input content. DocumentTone *DocumentAnalysis `json:"document_tone" validate:"required"` // An array of `SentenceAnalysis` objects that provides the results of the analysis for the individual sentences of the // input content. The service returns results only for the first 100 sentences of the input. The field is omitted if // the `sentences` parameter of the request is set to `false`. SentencesTone []SentenceAnalysis `json:"sentences_tone,omitempty"` }
ToneAnalysis : The tone analysis results for the input from the general-purpose endpoint.
type ToneAnalyzerV3 ¶
type ToneAnalyzerV3 struct { Service *core.BaseService Version string }
ToneAnalyzerV3 : The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and language tones in written text. The service can analyze tone at both the document and sentence levels. You can use the service to understand how your written communications are perceived and then to improve the tone of your communications. Businesses can use the service to learn the tone of their customers' communications and to respond to each customer appropriately, or to understand and improve their customer conversations.
**Note:** Request logging is disabled for the Tone Analyzer service. Regardless of whether you set the `X-Watson-Learning-Opt-Out` request header, the service does not log or retain data from requests and responses.
Version: 3.5.3 See: https://cloud.ibm.com/docs/tone-analyzer/
func NewToneAnalyzerV3 ¶
func NewToneAnalyzerV3(options *ToneAnalyzerV3Options) (service *ToneAnalyzerV3, err error)
NewToneAnalyzerV3 : constructs an instance of ToneAnalyzerV3 with passed in options.
func (*ToneAnalyzerV3) DisableSSLVerification ¶ added in v1.0.0
func (toneAnalyzer *ToneAnalyzerV3) DisableSSLVerification()
DisableSSLVerification bypasses verification of the server's SSL certificate
func (*ToneAnalyzerV3) NewToneChatOptions ¶
func (toneAnalyzer *ToneAnalyzerV3) NewToneChatOptions(utterances []Utterance) *ToneChatOptions
NewToneChatOptions : Instantiate ToneChatOptions
func (*ToneAnalyzerV3) NewToneInput ¶ added in v1.3.0
func (toneAnalyzer *ToneAnalyzerV3) NewToneInput(text string) (model *ToneInput, err error)
NewToneInput : Instantiate ToneInput (Generic Model Constructor)
func (*ToneAnalyzerV3) NewToneOptions ¶
func (toneAnalyzer *ToneAnalyzerV3) NewToneOptions() *ToneOptions
NewToneOptions : Instantiate ToneOptions
func (*ToneAnalyzerV3) NewUtterance ¶ added in v1.3.0
func (toneAnalyzer *ToneAnalyzerV3) NewUtterance(text string) (model *Utterance, err error)
NewUtterance : Instantiate Utterance (Generic Model Constructor)
func (*ToneAnalyzerV3) SetServiceURL ¶ added in v1.0.0
func (toneAnalyzer *ToneAnalyzerV3) SetServiceURL(url string) error
SetServiceURL sets the service URL
func (*ToneAnalyzerV3) Tone ¶
func (toneAnalyzer *ToneAnalyzerV3) Tone(toneOptions *ToneOptions) (result *ToneAnalysis, response *core.DetailedResponse, err error)
Tone : Analyze general tone Use the general-purpose endpoint to analyze the tone of your input content. The service analyzes the content for emotional and language tones. The method always analyzes the tone of the full document; by default, it also analyzes the tone of each individual sentence of the content.
You can submit no more than 128 KB of total input content and no more than 1000 individual sentences in JSON, plain text, or HTML format. The service analyzes the first 1000 sentences for document-level analysis and only the first 100 sentences for sentence-level analysis.
Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. For `text/html`, the service removes HTML tags and analyzes only the textual content.
**See also:** [Using the general-purpose endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).
func (*ToneAnalyzerV3) ToneChat ¶
func (toneAnalyzer *ToneAnalyzerV3) ToneChat(toneChatOptions *ToneChatOptions) (result *UtteranceAnalyses, response *core.DetailedResponse, err error)
ToneChat : Analyze customer-engagement tone Use the customer-engagement endpoint to analyze the tone of customer service and customer support conversations. For each utterance of a conversation, the method reports the most prevalent subset of the following seven tones: sad, frustrated, satisfied, excited, polite, impolite, and sympathetic.
If you submit more than 50 utterances, the service returns a warning for the overall content and analyzes only the first 50 utterances. If you submit a single utterance that contains more than 500 characters, the service returns an error for that utterance and does not analyze the utterance. The request fails if all utterances have more than 500 characters. Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8.
**See also:** [Using the customer-engagement endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utco#utco).
type ToneAnalyzerV3Options ¶
type ToneAnalyzerV3Options struct { ServiceName string URL string Authenticator core.Authenticator Version string }
ToneAnalyzerV3Options : Service options
type ToneCategory ¶
type ToneCategory struct { // An array of `ToneScore` objects that provides the results for the tones of the category. Tones []ToneScore `json:"tones" validate:"required"` // The unique, non-localized identifier of the category for the results. The service can return results for the // following category IDs: `emotion_tone`, `language_tone`, and `social_tone`. CategoryID *string `json:"category_id" validate:"required"` // The user-visible, localized name of the category. CategoryName *string `json:"category_name" validate:"required"` }
ToneCategory : The category for a tone from the input content.
type ToneChatOptions ¶
type ToneChatOptions struct { // An array of `Utterance` objects that provides the input content that the service is to analyze. Utterances []Utterance `json:"utterances" validate:"required"` // The language of the input text for the request: English or French. Regional variants are treated as their parent // language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not // submit content that contains both languages. You can use different languages for **Content-Language** and // **Accept-Language**. // * **`2017-09-21`:** Accepts `en` or `fr`. // * **`2016-05-19`:** Accepts only `en`. ContentLanguage *string `json:"Content-Language,omitempty"` // The desired language of the response. For two-character arguments, regional variants are treated as their parent // language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and // **Accept-Language**. AcceptLanguage *string `json:"Accept-Language,omitempty"` // Allows users to set headers to be GDPR compliant Headers map[string]string }
ToneChatOptions : The ToneChat options.
func (*ToneChatOptions) SetAcceptLanguage ¶
func (options *ToneChatOptions) SetAcceptLanguage(acceptLanguage string) *ToneChatOptions
SetAcceptLanguage : Allow user to set AcceptLanguage
func (*ToneChatOptions) SetContentLanguage ¶
func (options *ToneChatOptions) SetContentLanguage(contentLanguage string) *ToneChatOptions
SetContentLanguage : Allow user to set ContentLanguage
func (*ToneChatOptions) SetHeaders ¶
func (options *ToneChatOptions) SetHeaders(param map[string]string) *ToneChatOptions
SetHeaders : Allow user to set Headers
func (*ToneChatOptions) SetUtterances ¶
func (options *ToneChatOptions) SetUtterances(utterances []Utterance) *ToneChatOptions
SetUtterances : Allow user to set Utterances
type ToneChatScore ¶
type ToneChatScore struct { // The score for the tone in the range of 0.5 to 1. A score greater than 0.75 indicates a high likelihood that the tone // is perceived in the utterance. Score *float64 `json:"score" validate:"required"` // The unique, non-localized identifier of the tone for the results. The service returns results only for tones whose // scores meet a minimum threshold of 0.5. ToneID *string `json:"tone_id" validate:"required"` // The user-visible, localized name of the tone. ToneName *string `json:"tone_name" validate:"required"` }
ToneChatScore : The score for an utterance from the input content.
type ToneInput ¶
type ToneInput struct { // The input content that the service is to analyze. Text *string `json:"text" validate:"required"` }
ToneInput : Input for the general-purpose endpoint.
type ToneOptions ¶
type ToneOptions struct { // JSON, plain text, or HTML input that contains the content to be analyzed. For JSON input, provide an object of type // `ToneInput`. ToneInput *ToneInput `json:"tone_input,omitempty"` // JSON, plain text, or HTML input that contains the content to be analyzed. For JSON input, provide an object of type // `ToneInput`. Body *string `json:"body,omitempty"` // The type of the input. A character encoding can be specified by including a `charset` parameter. For example, // 'text/plain;charset=utf-8'. ContentType *string `json:"Content-Type,omitempty"` // Indicates whether the service is to return an analysis of each individual sentence in addition to its analysis of // the full document. If `true` (the default), the service returns results for each sentence. Sentences *bool `json:"sentences,omitempty"` // **`2017-09-21`:** Deprecated. The service continues to accept the parameter for backward-compatibility, but the // parameter no longer affects the response. // // **`2016-05-19`:** A comma-separated list of tones for which the service is to return its analysis of the input; the // indicated tones apply both to the full document and to individual sentences of the document. You can specify one or // more of the valid values. Omit the parameter to request results for all three tones. Tones []string `json:"tones,omitempty"` // The language of the input text for the request: English or French. Regional variants are treated as their parent // language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not // submit content that contains both languages. You can use different languages for **Content-Language** and // **Accept-Language**. // * **`2017-09-21`:** Accepts `en` or `fr`. // * **`2016-05-19`:** Accepts only `en`. ContentLanguage *string `json:"Content-Language,omitempty"` // The desired language of the response. For two-character arguments, regional variants are treated as their parent // language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and // **Accept-Language**. AcceptLanguage *string `json:"Accept-Language,omitempty"` // Allows users to set headers to be GDPR compliant Headers map[string]string }
ToneOptions : The Tone options.
func (*ToneOptions) SetAcceptLanguage ¶
func (options *ToneOptions) SetAcceptLanguage(acceptLanguage string) *ToneOptions
SetAcceptLanguage : Allow user to set AcceptLanguage
func (*ToneOptions) SetBody ¶
func (options *ToneOptions) SetBody(body string) *ToneOptions
SetBody : Allow user to set Body
func (*ToneOptions) SetContentLanguage ¶
func (options *ToneOptions) SetContentLanguage(contentLanguage string) *ToneOptions
SetContentLanguage : Allow user to set ContentLanguage
func (*ToneOptions) SetContentType ¶
func (options *ToneOptions) SetContentType(contentType string) *ToneOptions
SetContentType : Allow user to set ContentType
func (*ToneOptions) SetHeaders ¶
func (options *ToneOptions) SetHeaders(param map[string]string) *ToneOptions
SetHeaders : Allow user to set Headers
func (*ToneOptions) SetSentences ¶
func (options *ToneOptions) SetSentences(sentences bool) *ToneOptions
SetSentences : Allow user to set Sentences
func (*ToneOptions) SetToneInput ¶
func (options *ToneOptions) SetToneInput(toneInput *ToneInput) *ToneOptions
SetToneInput : Allow user to set ToneInput
func (*ToneOptions) SetTones ¶
func (options *ToneOptions) SetTones(tones []string) *ToneOptions
SetTones : Allow user to set Tones
type ToneScore ¶
type ToneScore struct { // The score for the tone. // * **`2017-09-21`:** The score that is returned lies in the range of 0.5 to 1. A score greater than 0.75 indicates a // high likelihood that the tone is perceived in the content. // * **`2016-05-19`:** The score that is returned lies in the range of 0 to 1. A score less than 0.5 indicates that the // tone is unlikely to be perceived in the content; a score greater than 0.75 indicates a high likelihood that the tone // is perceived. Score *float64 `json:"score" validate:"required"` // The unique, non-localized identifier of the tone. // * **`2017-09-21`:** The service can return results for the following tone IDs: `anger`, `fear`, `joy`, and `sadness` // (emotional tones); `analytical`, `confident`, and `tentative` (language tones). The service returns results only for // tones whose scores meet a minimum threshold of 0.5. // * **`2016-05-19`:** The service can return results for the following tone IDs of the different categories: for the // `emotion` category: `anger`, `disgust`, `fear`, `joy`, and `sadness`; for the `language` category: `analytical`, // `confident`, and `tentative`; for the `social` category: `openness_big5`, `conscientiousness_big5`, // `extraversion_big5`, `agreeableness_big5`, and `emotional_range_big5`. The service returns scores for all tones of a // category, regardless of their values. ToneID *string `json:"tone_id" validate:"required"` // The user-visible, localized name of the tone. ToneName *string `json:"tone_name" validate:"required"` }
ToneScore : The score for a tone from the input content.
type Utterance ¶
type Utterance struct { // An utterance contributed by a user in the conversation that is to be analyzed. The utterance can contain multiple // sentences. Text *string `json:"text" validate:"required"` // A string that identifies the user who contributed the utterance specified by the `text` parameter. User *string `json:"user,omitempty"` }
Utterance : An utterance for the input of the general-purpose endpoint.
type UtteranceAnalyses ¶
type UtteranceAnalyses struct { // An array of `UtteranceAnalysis` objects that provides the results for each utterance of the input. UtterancesTone []UtteranceAnalysis `json:"utterances_tone" validate:"required"` // **`2017-09-21`:** A warning message if the content contains more than 50 utterances. The service analyzes only the // first 50 utterances. **`2016-05-19`:** Not returned. Warning *string `json:"warning,omitempty"` }
UtteranceAnalyses : The results of the analysis for the utterances of the input content.
type UtteranceAnalysis ¶
type UtteranceAnalysis struct { // The unique identifier of the utterance. The first utterance has ID 0, and the ID of each subsequent utterance is // incremented by one. UtteranceID *int64 `json:"utterance_id" validate:"required"` // The text of the utterance. UtteranceText *string `json:"utterance_text" validate:"required"` // An array of `ToneChatScore` objects that provides results for the most prevalent tones of the utterance. The array // includes results for any tone whose score is at least 0.5. The array is empty if no tone has a score that meets this // threshold. Tones []ToneChatScore `json:"tones" validate:"required"` // **`2017-09-21`:** An error message if the utterance contains more than 500 characters. The service does not analyze // the utterance. **`2016-05-19`:** Not returned. Error *string `json:"error,omitempty"` }
UtteranceAnalysis : The results of the analysis for an utterance of the input content.