Documentation
¶
Overview ¶
Package agify is the library behind the agify command line: the HTTP client, request shaping, and the typed data models for the Agify.io family of name-prediction APIs (Agify, Genderize, Nationalize).
The Client is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (5xx) that any public API throws under load.
Index ¶
- type AgeResult
- type Client
- func (c *Client) BatchAge(ctx context.Context, names []string, country string) ([]AgeResult, error)
- func (c *Client) BatchGender(ctx context.Context, names []string, country string) ([]GenderResult, error)
- func (c *Client) PredictAge(ctx context.Context, name, country string) (*AgeResult, error)
- func (c *Client) PredictGender(ctx context.Context, name, country string) (*GenderResult, error)
- func (c *Client) PredictNationality(ctx context.Context, name string) (*NationalityResult, error)
- type Config
- type CountryProb
- type Domain
- type GenderResult
- type NationalityResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgeResult ¶ added in v0.1.1
type AgeResult struct {
Name string `json:"name"`
Age int `json:"age"`
Count int `json:"count"`
Country string `json:"country_id,omitempty"`
}
AgeResult is the age prediction for one first name.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Agify.io API family over HTTP.
func (*Client) BatchAge ¶ added in v0.1.1
BatchAge returns age predictions for up to 10 names in one request.
func (*Client) BatchGender ¶ added in v0.1.1
func (c *Client) BatchGender(ctx context.Context, names []string, country string) ([]GenderResult, error)
BatchGender returns gender predictions for up to 10 names in one request.
func (*Client) PredictAge ¶ added in v0.1.1
PredictAge returns the age prediction for a single first name. country is an ISO 3166-1 alpha-2 code (e.g. "US") or empty for global.
func (*Client) PredictGender ¶ added in v0.1.1
PredictGender returns the gender prediction for a single first name. country is an ISO 3166-1 alpha-2 code or empty for global.
func (*Client) PredictNationality ¶ added in v0.1.1
PredictNationality returns the nationality prediction for a single first name.
type Config ¶
type Config struct {
AgifyURL string
GenderizeURL string
NationalizeURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tuneable parameters for a Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the production configuration for the Agify.io family.
type CountryProb ¶ added in v0.1.1
type CountryProb struct {
CountryID string `json:"country_id"`
Probability float64 `json:"probability"`
}
CountryProb is one entry in a NationalityResult.
type Domain ¶
type Domain struct{}
Domain is the agify driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type GenderResult ¶ added in v0.1.1
type GenderResult struct {
Name string `json:"name"`
Gender string `json:"gender"`
Probability float64 `json:"probability"`
Count int `json:"count"`
Country string `json:"country_id,omitempty"`
}
GenderResult is the gender prediction for one first name.
type NationalityResult ¶ added in v0.1.1
type NationalityResult struct {
Name string `json:"name"`
Count int `json:"count"`
Countries []CountryProb `json:"country"`
}
NationalityResult is the nationality prediction for one first name.