...

Source file src/github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/runtime/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/runtime

     1  package runtime
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"encoding/json"
    11  	"github.com/Azure/go-autorest/autorest"
    12  )
    13  
    14  // The package's fully qualified name.
    15  const fqdn = "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/runtime"
    16  
    17  // APIError error information returned by the API
    18  type APIError struct {
    19  	// StatusCode - HTTP Status code
    20  	StatusCode *string `json:"statusCode,omitempty"`
    21  	// Message - Cause of the error.
    22  	Message *string `json:"message,omitempty"`
    23  }
    24  
    25  // CompositeChildModel child entity in a LUIS Composite Entity.
    26  type CompositeChildModel struct {
    27  	// Type - Type of child entity.
    28  	Type *string `json:"type,omitempty"`
    29  	// Value - Value extracted by LUIS.
    30  	Value *string `json:"value,omitempty"`
    31  }
    32  
    33  // CompositeEntityModel LUIS Composite Entity.
    34  type CompositeEntityModel struct {
    35  	// ParentType - Type/name of parent entity.
    36  	ParentType *string `json:"parentType,omitempty"`
    37  	// Value - Value for composite entity extracted by LUIS.
    38  	Value *string `json:"value,omitempty"`
    39  	// Children - Child entities.
    40  	Children *[]CompositeChildModel `json:"children,omitempty"`
    41  }
    42  
    43  // EntityModel an entity extracted from the utterance.
    44  type EntityModel struct {
    45  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
    46  	AdditionalProperties map[string]interface{} `json:""`
    47  	// Entity - Name of the entity, as defined in LUIS.
    48  	Entity *string `json:"entity,omitempty"`
    49  	// Type - Type of the entity, as defined in LUIS.
    50  	Type *string `json:"type,omitempty"`
    51  	// StartIndex - The position of the first character of the matched entity within the utterance.
    52  	StartIndex *int32 `json:"startIndex,omitempty"`
    53  	// EndIndex - The position of the last character of the matched entity within the utterance.
    54  	EndIndex *int32 `json:"endIndex,omitempty"`
    55  }
    56  
    57  // MarshalJSON is the custom marshaler for EntityModel.
    58  func (em EntityModel) MarshalJSON() ([]byte, error) {
    59  	objectMap := make(map[string]interface{})
    60  	if em.Entity != nil {
    61  		objectMap["entity"] = em.Entity
    62  	}
    63  	if em.Type != nil {
    64  		objectMap["type"] = em.Type
    65  	}
    66  	if em.StartIndex != nil {
    67  		objectMap["startIndex"] = em.StartIndex
    68  	}
    69  	if em.EndIndex != nil {
    70  		objectMap["endIndex"] = em.EndIndex
    71  	}
    72  	for k, v := range em.AdditionalProperties {
    73  		objectMap[k] = v
    74  	}
    75  	return json.Marshal(objectMap)
    76  }
    77  
    78  // UnmarshalJSON is the custom unmarshaler for EntityModel struct.
    79  func (em *EntityModel) UnmarshalJSON(body []byte) error {
    80  	var m map[string]*json.RawMessage
    81  	err := json.Unmarshal(body, &m)
    82  	if err != nil {
    83  		return err
    84  	}
    85  	for k, v := range m {
    86  		switch k {
    87  		default:
    88  			if v != nil {
    89  				var additionalProperties interface{}
    90  				err = json.Unmarshal(*v, &additionalProperties)
    91  				if err != nil {
    92  					return err
    93  				}
    94  				if em.AdditionalProperties == nil {
    95  					em.AdditionalProperties = make(map[string]interface{})
    96  				}
    97  				em.AdditionalProperties[k] = additionalProperties
    98  			}
    99  		case "entity":
   100  			if v != nil {
   101  				var entity string
   102  				err = json.Unmarshal(*v, &entity)
   103  				if err != nil {
   104  					return err
   105  				}
   106  				em.Entity = &entity
   107  			}
   108  		case "type":
   109  			if v != nil {
   110  				var typeVar string
   111  				err = json.Unmarshal(*v, &typeVar)
   112  				if err != nil {
   113  					return err
   114  				}
   115  				em.Type = &typeVar
   116  			}
   117  		case "startIndex":
   118  			if v != nil {
   119  				var startIndex int32
   120  				err = json.Unmarshal(*v, &startIndex)
   121  				if err != nil {
   122  					return err
   123  				}
   124  				em.StartIndex = &startIndex
   125  			}
   126  		case "endIndex":
   127  			if v != nil {
   128  				var endIndex int32
   129  				err = json.Unmarshal(*v, &endIndex)
   130  				if err != nil {
   131  					return err
   132  				}
   133  				em.EndIndex = &endIndex
   134  			}
   135  		}
   136  	}
   137  
   138  	return nil
   139  }
   140  
   141  // EntityWithResolution ...
   142  type EntityWithResolution struct {
   143  	// Resolution - Resolution values for pre-built LUIS entities.
   144  	Resolution interface{} `json:"resolution,omitempty"`
   145  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
   146  	AdditionalProperties map[string]interface{} `json:""`
   147  	// Entity - Name of the entity, as defined in LUIS.
   148  	Entity *string `json:"entity,omitempty"`
   149  	// Type - Type of the entity, as defined in LUIS.
   150  	Type *string `json:"type,omitempty"`
   151  	// StartIndex - The position of the first character of the matched entity within the utterance.
   152  	StartIndex *int32 `json:"startIndex,omitempty"`
   153  	// EndIndex - The position of the last character of the matched entity within the utterance.
   154  	EndIndex *int32 `json:"endIndex,omitempty"`
   155  }
   156  
   157  // MarshalJSON is the custom marshaler for EntityWithResolution.
   158  func (ewr EntityWithResolution) MarshalJSON() ([]byte, error) {
   159  	objectMap := make(map[string]interface{})
   160  	if ewr.Resolution != nil {
   161  		objectMap["resolution"] = ewr.Resolution
   162  	}
   163  	if ewr.Entity != nil {
   164  		objectMap["entity"] = ewr.Entity
   165  	}
   166  	if ewr.Type != nil {
   167  		objectMap["type"] = ewr.Type
   168  	}
   169  	if ewr.StartIndex != nil {
   170  		objectMap["startIndex"] = ewr.StartIndex
   171  	}
   172  	if ewr.EndIndex != nil {
   173  		objectMap["endIndex"] = ewr.EndIndex
   174  	}
   175  	for k, v := range ewr.AdditionalProperties {
   176  		objectMap[k] = v
   177  	}
   178  	return json.Marshal(objectMap)
   179  }
   180  
   181  // UnmarshalJSON is the custom unmarshaler for EntityWithResolution struct.
   182  func (ewr *EntityWithResolution) UnmarshalJSON(body []byte) error {
   183  	var m map[string]*json.RawMessage
   184  	err := json.Unmarshal(body, &m)
   185  	if err != nil {
   186  		return err
   187  	}
   188  	for k, v := range m {
   189  		switch k {
   190  		case "resolution":
   191  			if v != nil {
   192  				var resolution interface{}
   193  				err = json.Unmarshal(*v, &resolution)
   194  				if err != nil {
   195  					return err
   196  				}
   197  				ewr.Resolution = resolution
   198  			}
   199  		default:
   200  			if v != nil {
   201  				var additionalProperties interface{}
   202  				err = json.Unmarshal(*v, &additionalProperties)
   203  				if err != nil {
   204  					return err
   205  				}
   206  				if ewr.AdditionalProperties == nil {
   207  					ewr.AdditionalProperties = make(map[string]interface{})
   208  				}
   209  				ewr.AdditionalProperties[k] = additionalProperties
   210  			}
   211  		case "entity":
   212  			if v != nil {
   213  				var entity string
   214  				err = json.Unmarshal(*v, &entity)
   215  				if err != nil {
   216  					return err
   217  				}
   218  				ewr.Entity = &entity
   219  			}
   220  		case "type":
   221  			if v != nil {
   222  				var typeVar string
   223  				err = json.Unmarshal(*v, &typeVar)
   224  				if err != nil {
   225  					return err
   226  				}
   227  				ewr.Type = &typeVar
   228  			}
   229  		case "startIndex":
   230  			if v != nil {
   231  				var startIndex int32
   232  				err = json.Unmarshal(*v, &startIndex)
   233  				if err != nil {
   234  					return err
   235  				}
   236  				ewr.StartIndex = &startIndex
   237  			}
   238  		case "endIndex":
   239  			if v != nil {
   240  				var endIndex int32
   241  				err = json.Unmarshal(*v, &endIndex)
   242  				if err != nil {
   243  					return err
   244  				}
   245  				ewr.EndIndex = &endIndex
   246  			}
   247  		}
   248  	}
   249  
   250  	return nil
   251  }
   252  
   253  // EntityWithScore ...
   254  type EntityWithScore struct {
   255  	// Score - Associated prediction score for the intent (float).
   256  	Score *float64 `json:"score,omitempty"`
   257  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
   258  	AdditionalProperties map[string]interface{} `json:""`
   259  	// Entity - Name of the entity, as defined in LUIS.
   260  	Entity *string `json:"entity,omitempty"`
   261  	// Type - Type of the entity, as defined in LUIS.
   262  	Type *string `json:"type,omitempty"`
   263  	// StartIndex - The position of the first character of the matched entity within the utterance.
   264  	StartIndex *int32 `json:"startIndex,omitempty"`
   265  	// EndIndex - The position of the last character of the matched entity within the utterance.
   266  	EndIndex *int32 `json:"endIndex,omitempty"`
   267  }
   268  
   269  // MarshalJSON is the custom marshaler for EntityWithScore.
   270  func (ews EntityWithScore) MarshalJSON() ([]byte, error) {
   271  	objectMap := make(map[string]interface{})
   272  	if ews.Score != nil {
   273  		objectMap["score"] = ews.Score
   274  	}
   275  	if ews.Entity != nil {
   276  		objectMap["entity"] = ews.Entity
   277  	}
   278  	if ews.Type != nil {
   279  		objectMap["type"] = ews.Type
   280  	}
   281  	if ews.StartIndex != nil {
   282  		objectMap["startIndex"] = ews.StartIndex
   283  	}
   284  	if ews.EndIndex != nil {
   285  		objectMap["endIndex"] = ews.EndIndex
   286  	}
   287  	for k, v := range ews.AdditionalProperties {
   288  		objectMap[k] = v
   289  	}
   290  	return json.Marshal(objectMap)
   291  }
   292  
   293  // UnmarshalJSON is the custom unmarshaler for EntityWithScore struct.
   294  func (ews *EntityWithScore) UnmarshalJSON(body []byte) error {
   295  	var m map[string]*json.RawMessage
   296  	err := json.Unmarshal(body, &m)
   297  	if err != nil {
   298  		return err
   299  	}
   300  	for k, v := range m {
   301  		switch k {
   302  		case "score":
   303  			if v != nil {
   304  				var score float64
   305  				err = json.Unmarshal(*v, &score)
   306  				if err != nil {
   307  					return err
   308  				}
   309  				ews.Score = &score
   310  			}
   311  		default:
   312  			if v != nil {
   313  				var additionalProperties interface{}
   314  				err = json.Unmarshal(*v, &additionalProperties)
   315  				if err != nil {
   316  					return err
   317  				}
   318  				if ews.AdditionalProperties == nil {
   319  					ews.AdditionalProperties = make(map[string]interface{})
   320  				}
   321  				ews.AdditionalProperties[k] = additionalProperties
   322  			}
   323  		case "entity":
   324  			if v != nil {
   325  				var entity string
   326  				err = json.Unmarshal(*v, &entity)
   327  				if err != nil {
   328  					return err
   329  				}
   330  				ews.Entity = &entity
   331  			}
   332  		case "type":
   333  			if v != nil {
   334  				var typeVar string
   335  				err = json.Unmarshal(*v, &typeVar)
   336  				if err != nil {
   337  					return err
   338  				}
   339  				ews.Type = &typeVar
   340  			}
   341  		case "startIndex":
   342  			if v != nil {
   343  				var startIndex int32
   344  				err = json.Unmarshal(*v, &startIndex)
   345  				if err != nil {
   346  					return err
   347  				}
   348  				ews.StartIndex = &startIndex
   349  			}
   350  		case "endIndex":
   351  			if v != nil {
   352  				var endIndex int32
   353  				err = json.Unmarshal(*v, &endIndex)
   354  				if err != nil {
   355  					return err
   356  				}
   357  				ews.EndIndex = &endIndex
   358  			}
   359  		}
   360  	}
   361  
   362  	return nil
   363  }
   364  
   365  // IntentModel an intent detected from the utterance.
   366  type IntentModel struct {
   367  	// Intent - Name of the intent, as defined in LUIS.
   368  	Intent *string `json:"intent,omitempty"`
   369  	// Score - Associated prediction score for the intent (float).
   370  	Score *float64 `json:"score,omitempty"`
   371  }
   372  
   373  // LuisResult prediction, based on the input query, containing intent(s) and entities.
   374  type LuisResult struct {
   375  	autorest.Response `json:"-"`
   376  	// Query - The input utterance that was analyzed.
   377  	Query *string `json:"query,omitempty"`
   378  	// AlteredQuery - The corrected utterance (when spell checking was enabled).
   379  	AlteredQuery     *string      `json:"alteredQuery,omitempty"`
   380  	TopScoringIntent *IntentModel `json:"topScoringIntent,omitempty"`
   381  	// Intents - All the intents (and their score) that were detected from utterance.
   382  	Intents *[]IntentModel `json:"intents,omitempty"`
   383  	// Entities - The entities extracted from the utterance.
   384  	Entities *[]EntityModel `json:"entities,omitempty"`
   385  	// CompositeEntities - The composite entities extracted from the utterance.
   386  	CompositeEntities      *[]CompositeEntityModel `json:"compositeEntities,omitempty"`
   387  	SentimentAnalysis      *Sentiment              `json:"sentimentAnalysis,omitempty"`
   388  	ConnectedServiceResult *LuisResult             `json:"connectedServiceResult,omitempty"`
   389  }
   390  
   391  // Sentiment sentiment of the input utterance.
   392  type Sentiment struct {
   393  	// Label - The polarity of the sentiment, can be positive, neutral or negative.
   394  	Label *string `json:"label,omitempty"`
   395  	// Score - Score of the sentiment, ranges from 0 (most negative) to 1 (most positive).
   396  	Score *float64 `json:"score,omitempty"`
   397  }
   398  

View as plain text