enrich

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package enrich enriches a spreadsheet with gender/age/nationality predictions from the public API, joining results back onto the original rows. It mirrors the Demografix browser tool's column names and semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServiceNames

func ServiceNames(o Options) []string

ServiceNames lists the enabled services in canonical order.

Types

type ConfigError

type ConfigError struct {
	// contains filtered or unexported fields
}

ConfigError is a user-facing validation/column-resolution failure. The CLI maps it to a usage exit code.

func (*ConfigError) Error

func (e *ConfigError) Error() string

type Options

type Options struct {
	InputPath  string
	OutputPath string

	Gender      bool
	Age         bool
	Nationality bool

	NameCol  string
	FirstCol string
	LastCol  string

	CountryCol   string
	FixedCountry string

	TopN   int
	Prefix string
	Resume bool

	Concurrency int
}

Options are the enrich command inputs.

type PlanInfo

type PlanInfo struct {
	InputFormat   string
	OutputFormat  string
	OutputPath    string
	Rows          int
	Services      []string
	NameColumns   string
	Country       string
	OutputColumns []string
	Cost          int
	Resume        bool
}

PlanInfo describes a run without executing it (for --dry-run).

func Plan

func Plan(o Options) (*PlanInfo, error)

Plan validates the inputs and computes the cost without calling the API.

type Predictor

type Predictor interface {
	Genderize(ctx context.Context, names []string, country string) ([]api.GenderizePrediction, api.Quota, error)
	Agify(ctx context.Context, names []string, country string) ([]api.AgifyPrediction, api.Quota, error)
	Nationalize(ctx context.Context, names []string) ([]api.NationalizePrediction, api.Quota, error)
}

Predictor is the subset of the API client the pipeline needs. *api.Client satisfies it; tests inject a fake.

type Result

type Result struct {
	Out         *sheet.Spreadsheet
	RowsTotal   int
	RowsWritten int
	NamesBilled int
	Quota       api.Quota
}

Result is the outcome of a run.

func Run

func Run(ctx context.Context, p Predictor, o Options) (*Result, error)

Run enriches the input and returns the built output spreadsheet. On a 429 it returns a partial Result plus the *api.RateLimitError so the caller can write the partial file and report progress.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL