Skip to content

Commit 36f5e8a

Browse files
committed
Fix UTs
1 parent 2351da2 commit 36f5e8a

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ client.GetEntity("favorite_city")
6868
Update:
6969
```go
7070
client.UpdateEntity("favorite_city", witai.Entity{
71+
ID: "my_entity_id",
7172
Doc: "My favorite city",
7273
})
7374
```
@@ -110,12 +111,20 @@ Validate samples (sentence + entities annotations) to train your app programmati
110111
```go
111112
client.ValidateSamples([]witai.Sample{
112113
Sample{
113-
Text: "I live in HCMC",
114+
Text: "I want to fly SFO",
115+
Entities: []SampleEntity{
116+
{
117+
Entity: "wit$location",
118+
Value: "SFO",
119+
Start: 17,
120+
End: 20,
121+
},
122+
},
114123
},
115124
})
116125
```
117126

118-
Get validate samples:
127+
Get samples:
119128
```go
120129
limit := 10
121130
offset := 0

integration_test.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
Lang: "en",
2424
}
2525
integrationEntityUpdateFields = Entity{
26-
Name: "integration_entity_id",
26+
ID: "integration_entity_id",
2727
Lookups: []string{"keywords"},
2828
Doc: "integration_entity_doc_updated",
2929
}
@@ -168,33 +168,28 @@ func TestIntegrationSamples(t *testing.T) {
168168
// cleanup
169169
c.DeleteSamples([]Sample{
170170
{
171-
Text: "I want to fly SFO",
171+
Text: "I want to fly to SFO",
172172
},
173173
})
174174

175175
// Deletion takes time
176176
time.Sleep(time.Second * 5)
177177

178178
// samples test
179-
start := 17
180-
end := 20
181-
_, validateErr := c.ValidateSamples([]Sample{
179+
res, validateErr := c.ValidateSamples([]Sample{
182180
{
183-
Text: "I want to fly SFO",
181+
Text: "I want to fly to SFO",
184182
Entities: []SampleEntity{
185-
{
186-
Entity: "intent",
187-
Value: "flight_request",
188-
},
189183
{
190184
Entity: "wit$location",
191185
Value: "SFO",
192-
Start: &start,
193-
End: &end,
186+
Start: 17,
187+
End: 20,
194188
},
195189
},
196190
},
197191
})
192+
198193
if validateErr != nil {
199194
t.Fatalf("expected nil error, got %v", validateErr)
200195
}
@@ -214,7 +209,7 @@ func TestIntegrationSamples(t *testing.T) {
214209
// delete samples
215210
_, delSamplesErr := c.DeleteSamples([]Sample{
216211
{
217-
Text: "I want to fly SFO",
212+
Text: "I want to fly to SFO",
218213
},
219214
})
220215
if delSamplesErr != nil {

samples.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type SampleEntity struct {
2020
Entity string `json:"entity"`
2121
Value string `json:"value"`
2222
Role string `json:"role"`
23-
Start *int `json:"start,omitempty"`
24-
End *int `json:"end,omitempty"`
23+
Start int `json:"start"`
24+
End int `json:"end"`
2525
Subentitites []SampleEntity `json:"subentities"`
2626
}
2727

0 commit comments

Comments
 (0)