|
| 1 | +package labstack |
| 2 | + |
| 3 | +type ( |
| 4 | + TextSummaryRequest struct { |
| 5 | + Text string `json:"text"` |
| 6 | + URL string `json:"url"` |
| 7 | + Language string `json:"language"` |
| 8 | + Length int `json:"length"` |
| 9 | + } |
| 10 | + |
| 11 | + TextSummaryResponse struct { |
| 12 | + Summary string `json:"summary"` |
| 13 | + } |
| 14 | + |
| 15 | + TextSentimentRequest struct { |
| 16 | + Text string `json:"text"` |
| 17 | + } |
| 18 | + |
| 19 | + TextSentimentResponse struct { |
| 20 | + Subjectivity float32 `json:"subjectivity"` |
| 21 | + Polarity float32 `json:"polarity"` |
| 22 | + } |
| 23 | + |
| 24 | + TextSpellCheckRequest struct { |
| 25 | + Text string `json:"text"` |
| 26 | + } |
| 27 | + |
| 28 | + TextSpellCheckResponse struct { |
| 29 | + Misspelled []*TextSpellCheckMisspelled `json:"misspelled"` |
| 30 | + } |
| 31 | + |
| 32 | + TextSpellCheckMisspelled struct { |
| 33 | + Word string `json:"word"` |
| 34 | + Offset int `json:"offset"` |
| 35 | + Suggestions []string `json:"suggestions"` |
| 36 | + } |
| 37 | +) |
| 38 | + |
| 39 | +func (c *Client) TextSummary(req *TextSummaryRequest) (res *TextSummaryResponse, err *APIError) { |
| 40 | + res = new(TextSummaryResponse) |
| 41 | + _, e := c.resty.R(). |
| 42 | + SetBody(req). |
| 43 | + SetResult(res). |
| 44 | + SetError(err). |
| 45 | + Post("/text/summary") |
| 46 | + if e != nil { |
| 47 | + err = new(APIError) |
| 48 | + err.Message = e.Error() |
| 49 | + } |
| 50 | + return |
| 51 | +} |
| 52 | + |
| 53 | +func (c *Client) TextSentiment(req *TextSentimentRequest) (res *TextSentimentResponse, err *APIError) { |
| 54 | + res = new(TextSentimentResponse) |
| 55 | + _, e := c.resty.R(). |
| 56 | + SetBody(req). |
| 57 | + SetResult(res). |
| 58 | + SetError(err). |
| 59 | + Post("/text/sentiment") |
| 60 | + if e != nil { |
| 61 | + err = new(APIError) |
| 62 | + err.Message = e.Error() |
| 63 | + } |
| 64 | + return |
| 65 | +} |
| 66 | + |
| 67 | +func (c *Client) TextSpellCheck(req *TextSpellCheckRequest) (res *TextSpellCheckResponse, err *APIError) { |
| 68 | + res = new(TextSpellCheckResponse) |
| 69 | + _, e := c.resty.R(). |
| 70 | + SetBody(req). |
| 71 | + SetResult(res). |
| 72 | + SetError(err). |
| 73 | + Post("/text/spell-check") |
| 74 | + if e != nil { |
| 75 | + err = new(APIError) |
| 76 | + err.Message = e.Error() |
| 77 | + } |
| 78 | + return |
| 79 | +} |
0 commit comments