-
Notifications
You must be signed in to change notification settings - Fork 844
/
models.go
155 lines (140 loc) · 5.86 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package runtime
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/cognitiveservices/v3.0/luis/runtime"
// DynamicList defines an extension for a list entity.
type DynamicList struct {
// ListEntityName - The name of the list entity to extend.
ListEntityName *string `json:"listEntityName,omitempty"`
// RequestLists - The lists to append on the extended list entity.
RequestLists *[]RequestList `json:"requestLists,omitempty"`
}
// Error represents the error that occurred.
type Error struct {
Error *ErrorBody `json:"error,omitempty"`
}
// ErrorBody represents the definition of the error that occurred.
type ErrorBody struct {
// Code - The error code.
Code *string `json:"code,omitempty"`
// Message - The error message.
Message *string `json:"message,omitempty"`
}
// ExternalEntity defines a user predicted entity that extends an already existing one.
type ExternalEntity struct {
// EntityName - The name of the entity to extend.
EntityName *string `json:"entityName,omitempty"`
// StartIndex - The start character index of the predicted entity.
StartIndex *int32 `json:"startIndex,omitempty"`
// EntityLength - The length of the predicted entity.
EntityLength *int32 `json:"entityLength,omitempty"`
// Resolution - A user supplied custom resolution to return as the entity's prediction.
Resolution interface{} `json:"resolution,omitempty"`
}
// Intent represents an intent prediction.
type Intent struct {
// Score - The score of the fired intent.
Score *float64 `json:"score,omitempty"`
// ChildApp - The prediction of the dispatched application.
ChildApp *Prediction `json:"childApp,omitempty"`
}
// Prediction represents the prediction of a query.
type Prediction struct {
// NormalizedQuery - The query after pre-processing and normalization.
NormalizedQuery *string `json:"normalizedQuery,omitempty"`
// AlteredQuery - The query after spell checking. Only set if spell check was enabled and a spelling mistake was found.
AlteredQuery *string `json:"alteredQuery,omitempty"`
// TopIntent - The name of the top scoring intent.
TopIntent *string `json:"topIntent,omitempty"`
// Intents - A dictionary representing the intents that fired.
Intents map[string]*Intent `json:"intents"`
// Entities - The dictionary representing the entities that fired.
Entities map[string]interface{} `json:"entities"`
// Sentiment - The result of the sentiment analysis.
Sentiment *Sentiment `json:"sentiment,omitempty"`
}
// MarshalJSON is the custom marshaler for Prediction.
func (p Prediction) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if p.NormalizedQuery != nil {
objectMap["normalizedQuery"] = p.NormalizedQuery
}
if p.AlteredQuery != nil {
objectMap["alteredQuery"] = p.AlteredQuery
}
if p.TopIntent != nil {
objectMap["topIntent"] = p.TopIntent
}
if p.Intents != nil {
objectMap["intents"] = p.Intents
}
if p.Entities != nil {
objectMap["entities"] = p.Entities
}
if p.Sentiment != nil {
objectMap["sentiment"] = p.Sentiment
}
return json.Marshal(objectMap)
}
// PredictionRequest represents the prediction request parameters.
type PredictionRequest struct {
// Query - The query to predict
Query *string `json:"query,omitempty"`
// Options - The custom options defined for this request.
Options *PredictionRequestOptions `json:"options,omitempty"`
// ExternalEntities - The externally predicted entities for this request
ExternalEntities *[]ExternalEntity `json:"externalEntities,omitempty"`
// DynamicLists - The dynamically created list entities for this request
DynamicLists *[]DynamicList `json:"dynamicLists,omitempty"`
}
// PredictionRequestOptions the custom options for the prediction request.
type PredictionRequestOptions struct {
// DatetimeReference - The reference DateTime used for predicting datetime entities.
DatetimeReference *date.Time `json:"datetimeReference,omitempty"`
// OverridePredictions - Whether to make the external entities resolution override the predictions if an overlap occurs.
OverridePredictions *bool `json:"overridePredictions,omitempty"`
}
// PredictionResponse represents the prediction response.
type PredictionResponse struct {
autorest.Response `json:"-"`
// Query - The query used in the prediction.
Query *string `json:"query,omitempty"`
// Prediction - The prediction of the requested query.
Prediction *Prediction `json:"prediction,omitempty"`
}
// RequestList defines a sub-list to append to an existing list entity.
type RequestList struct {
// Name - The name of the sub-list.
Name *string `json:"name,omitempty"`
// CanonicalForm - The canonical form of the sub-list.
CanonicalForm *string `json:"canonicalForm,omitempty"`
// Synonyms - The synonyms of the canonical form.
Synonyms *[]string `json:"synonyms,omitempty"`
}
// Sentiment the result of the sentiment analysis.
type Sentiment struct {
// Score - The sentiment score of the query.
Score *float64 `json:"score,omitempty"`
// Label - The label of the sentiment analysis result.
Label *string `json:"label,omitempty"`
}