@@ -19,9 +19,9 @@ type DetectBatchRequest struct {
19
19
}
20
20
21
21
// Detect executes language detection for a single text
22
- func (c * Client ) Detect (in string ) (out []* DetectionResult , err error ) {
22
+ func (c * Client ) Detect (ctx context. Context , in string ) (out []* DetectionResult , err error ) {
23
23
var response []* DetectionResult
24
- err = c .post (context . TODO () , "detect" , & DetectRequest {Query : in }, & response )
24
+ err = c .post (ctx , "detect" , & DetectRequest {Query : in }, & response )
25
25
26
26
if err != nil {
27
27
return nil , err
@@ -31,8 +31,8 @@ func (c *Client) Detect(in string) (out []*DetectionResult, err error) {
31
31
}
32
32
33
33
// DetectCode executes language detection for a single text and returns detected language code
34
- func (c * Client ) DetectCode (in string ) (out string , err error ) {
35
- detections , err := c .Detect (in )
34
+ func (c * Client ) DetectCode (ctx context. Context , in string ) (out string , err error ) {
35
+ detections , err := c .Detect (ctx , in )
36
36
37
37
if err != nil {
38
38
return "" , err
@@ -47,9 +47,9 @@ func (c *Client) DetectCode(in string) (out string, err error) {
47
47
48
48
// DetectBatch executes language detection with multiple texts.
49
49
// It is significantly faster than doing a separate request for each text indivdually.
50
- func (c * Client ) DetectBatch (in []string ) (out [][]* DetectionResult , err error ) {
50
+ func (c * Client ) DetectBatch (ctx context. Context , in []string ) (out [][]* DetectionResult , err error ) {
51
51
var response [][]* DetectionResult
52
- err = c .post (nil , "detect-batch" , & DetectBatchRequest {Query : in }, & response )
52
+ err = c .post (ctx , "detect-batch" , & DetectBatchRequest {Query : in }, & response )
53
53
54
54
if err != nil {
55
55
return nil , err
0 commit comments