Documentation ¶
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) Detect(in string) (out []*DetectionResult, err error)
- func (c *Client) DetectBatch(in []string) (out [][]*DetectionResult, err error)
- func (c *Client) DetectCode(in string) (out string, err error)
- func (c *Client) Languages() (out []*Language, err error)
- func (c *Client) UserStatus() (out *UserStatusResponse, err error)
- type DetectBatchRequest
- type DetectBatchResponse
- type DetectBatchResponseData
- type DetectRequest
- type DetectResponse
- type DetectResponseData
- type DetectionError
- type DetectionResult
- type Language
- type UserStatusResponse
Constants ¶
const Version = "1.0.1"
Version is the API client version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { // Status is the HTTP text status of the response. Status string // StatusCode is the HTTP numerical status code of the response. StatusCode int // Code is an error code returned by the API. Code int `json:"code"` // Message is a human-readable error code returned by the API. Message string `json:"message"` }
APIError is an error returned from the API
type Client ¶
type Client struct { // BaseURL specifies the location of the API. It is used with // ResolveReference to create request URLs. (If 'Path' is specified, it // should end with a trailing slash.) If nil, the default will be used. BaseURL *url.URL // Client is an HTTP client used to make API requests. If nil, // default will be used. Client *http.Client // APIKey is the user's API key. It is required. // Note: Treat your API Keys as passwords—keep them secret. API Keys give // full read/write access to your account, so they should not be included in // public repositories, emails, client side code, etc. APIKey string // UserAgent is a User-Agent to be sent with API HTTP requests. If empty, // a default will be used. UserAgent string }
A Client provides an HTTP client for DetectLanguage API operations.
func (*Client) Detect ¶
func (c *Client) Detect(in string) (out []*DetectionResult, err error)
Detect executes language detection for a single text
func (*Client) DetectBatch ¶
func (c *Client) DetectBatch(in []string) (out [][]*DetectionResult, err error)
DetectBatch executes language detection with multiple texts. It is significantly faster than doing a separate request for each text indivdually.
func (*Client) DetectCode ¶
DetectCode executes language detection for a single text and returns detected language code
func (*Client) UserStatus ¶
func (c *Client) UserStatus() (out *UserStatusResponse, err error)
UserStatus fetches account status
type DetectBatchRequest ¶
type DetectBatchRequest struct {
Query []string `json:"q"`
}
DetectBatchRequest contains batch language detection request params
type DetectBatchResponse ¶
type DetectBatchResponse struct {
Data *DetectBatchResponseData `json:"data"`
}
DetectBatchResponse is a resource batch containing language detection response
type DetectBatchResponseData ¶
type DetectBatchResponseData struct {
Detections [][]*DetectionResult `json:"detections"`
}
DetectBatchResponseData contains batch language detection response data
type DetectRequest ¶
type DetectRequest struct {
Query string `json:"q"`
}
DetectRequest contains language detection request params
type DetectResponse ¶
type DetectResponse struct {
Data *DetectResponseData `json:"data"`
}
DetectResponse is a resource containing language detection response
type DetectResponseData ¶
type DetectResponseData struct {
Detections []*DetectionResult `json:"detections"`
}
DetectResponseData contains language detection response data
type DetectionError ¶
type DetectionError struct {
Message string
}
DetectionError is retuned when detection fails
func (*DetectionError) Error ¶
func (e *DetectionError) Error() string
type DetectionResult ¶
type DetectionResult struct { Language string `json:"language"` Reliable bool `json:"isReliable"` Confidence float32 `json:"confidence"` }
DetectionResult is single language detection result
type UserStatusResponse ¶
type UserStatusResponse struct { Date string `json:"date,omitempty"` Requests int `json:"requests"` Bytes int `json:"bytes"` Plan string `json:"plan"` PlanExpires string `json:"plan_expires,omitempty"` DailyRequestsLimit int `json:"daily_requests_limit"` DailyBytesLimit int `json:"daily_bytes_limit"` Status string `json:"status"` }
UserStatusResponse is the resource containing account status information