Closed swys closed 4 years ago
Thanks for the feedback @swys I just made a fix in v1.0.9 version, please pull and test. I added integration test to validate that it works.
@plutov thank you so much for the quick response on this, it is very appreciated. I pulled the new version and tested and it works as expected. But there is still a case where it still fails. What happens when the text that you wish to select is in the beginning of the sentence?
Example :
// samples test
_, validateErr := c.ValidateSamples([]Sample{
{
Text: "SFO is where I need to go",
Entities: []SampleEntity{
{
Entity: "intent",
Value: "flight_request",
},
{
Entity: "wit$location",
Value: "SFO",
Start: 0,
End: 3,
},
},
},
})
In this case you would have to put the start:0
and end:3
to select the entire word, but because 0
is the zero value for the type and you enabled omitempty
on the json tags, the start
field will be removed from the resulting json and the integration test fails with :
--- FAIL: TestIntegrationSamples (5.40s)
integration_test.go:197: expected nil error, got unable to make a request. error: Failed to validate sample at index 0. You must provide both start and end, or neither.
Good catch, let me reopen it then.
Removed omitempty.
While using the
ValidateSamples
method with the sample code shown in the docs : https://wit.ai/docs/http/20170307#post__samples_linkI'm getting error : unable to make a request. error: Failed to validate sample at index 0. Start must be less than end.
I also slightly altered your integration test to reproduce the same error. I added below code to the
TestIntegrationSamples
test :The added lines were just to make the test match the sample curl command in the docs : https://wit.ai/docs/http/20170307#post__samples_link
And as suspected the integration test now fails with :
I believe this is because the struct def has int values for the
start
andend
fields, but in this example where theintent
doesn't need the text selection to be called out (like when you have a trait lookup strategy) so there is no value given forstart
andend
, they are give the zero value for the type, which is0
.The problem is the api receives :
and it responds with a 400 :
If I hit the api outside of the library and replace the values of
start
andend
withnull
or omit them completely then I get back a 200 and it works as expected.Maybe I'm missing something here? I would really appreciate some help here. Thanks!