Documentation
¶
Overview ¶
Package kotoshu is a Go client for the Kotoshu HTTP spell-check API.
Index ¶
- Constants
- func IsResourceNotSetup(err error) bool
- type APIError
- type CheckOptions
- type Client
- func (c *Client) Check(ctx context.Context, text string, opts *CheckOptions) (*DocumentResult, error)
- func (c *Client) Correct(ctx context.Context, word string, opts *CheckOptions) (bool, error)
- func (c *Client) Detect(ctx context.Context, text string) (*Detection, error)
- func (c *Client) Health(ctx context.Context) (*Health, error)
- func (c *Client) Languages(ctx context.Context) ([]string, error)
- func (c *Client) Suggest(ctx context.Context, word string, opts *SuggestOptions) ([]Suggestion, error)
- type Detection
- type DocumentResult
- type Health
- type Languages
- type Option
- type SuggestOptions
- type Suggestion
- type WordError
Constants ¶
View Source
const Version = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
func IsResourceNotSetup ¶
IsResourceNotSetup reports whether err is a 422 resource_not_setup.
Types ¶
type CheckOptions ¶
CheckOptions controls a single /v1/check call.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Kotoshu HTTP API client.
func (*Client) Check ¶
func (c *Client) Check(ctx context.Context, text string, opts *CheckOptions) (*DocumentResult, error)
Check posts text to /v1/check.
func (*Client) Suggest ¶
func (c *Client) Suggest(ctx context.Context, word string, opts *SuggestOptions) ([]Suggestion, error)
Suggest posts word to /v1/suggest.
type DocumentResult ¶
type DocumentResult struct {
File string `json:"file"`
WordCount int `json:"word_count"`
Errors []WordError `json:"errors"`
}
DocumentResult is the response from /v1/check.
type Health ¶
type Health struct {
Status string `json:"status"`
Ready map[string]bool `json:"ready"`
Timestamp string `json:"timestamp,omitempty"`
}
Health is the response from /v1/health.
type Languages ¶
type Languages struct {
Cached []string `json:"cached"`
}
Languages is the response from /v1/languages.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient supplies a custom *http.Client.
type SuggestOptions ¶
SuggestOptions controls a single /v1/suggest call.
type Suggestion ¶
type Suggestion struct {
Word string `json:"word"`
Distance int `json:"distance"`
Confidence float64 `json:"confidence"`
Source string `json:"source"`
}
Suggestion is a single correction candidate.
type WordError ¶
type WordError struct {
Word string `json:"word"`
Position *int `json:"position"`
Suggestions []Suggestion `json:"suggestions"`
}
WordError is one misspelled word with its candidates.
Click to show internal directories.
Click to hide internal directories.