firstname

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RussianNaiveGenderRules = NaiveGenderRules{
	Suffixes: []NaiveGenderRulesSuffixes{
		{
			Length: 5,
			Genders: map[string]Gender{
				"слава": GenderFemale,
			},
		},
		{
			Length: 4,
			Genders: map[string]Gender{
				"слав": GenderMale,
			},
		},
		{
			Length: 3,
			Genders: map[string]Gender{
				"ика": GenderFemale,
				"ида": GenderFemale,
				"ана": GenderFemale,
			},
		},
		{
			Length: 2,
			Genders: map[string]Gender{
				"ан": GenderMale,
				"он": GenderMale,
				"ий": GenderMale,
				"ав": GenderMale,
				"ем": GenderMale,
				"ём": GenderMale,
				"ей": GenderMale,
				"на": GenderFemale,
				"ил": GenderMale,
				"ия": GenderFemale,
				"ья": GenderFemale,
			},
		},
	},
}

Functions

This section is empty.

Types

type DBStore added in v0.3.0

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

func NewDBStore added in v0.3.0

func NewDBStore(tableName string, conn *sql.DB) *DBStore

func (*DBStore) Get added in v0.3.0

func (d *DBStore) Get(ctx context.Context, names []string) (*GetResult, error)

type FindResult added in v0.3.0

type FindResult GetResult

type Gender

type Gender uint8
const (
	GenderUnspecified Gender = iota
	GenderMale        Gender = 1
	GenderFemale      Gender = 2
	GenderNeutral     Gender = 3
)

type GenderFinder added in v0.4.0

type GenderFinder interface {
	Find(ctx context.Context, names []string) (*FindResult, error)
}

type GetResult

type GetResult struct {
	Found    map[string]Gender
	NotFound []string
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore(names map[string]Gender) *MemoryStore

func (*MemoryStore) Get

func (s *MemoryStore) Get(_ context.Context, names []string) (*GetResult, error)

type NaiveGenderFinder added in v0.4.0

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

func NewNaiveGenderFinder added in v0.4.0

func NewNaiveGenderFinder(rules NaiveGenderRules) NaiveGenderFinder

func (*NaiveGenderFinder) Find added in v0.4.0

func (f *NaiveGenderFinder) Find(_ context.Context, names []string) (*FindResult, error)

func (*NaiveGenderFinder) FindOne added in v0.4.0

func (f *NaiveGenderFinder) FindOne(name string) Gender

type NaiveGenderRules added in v0.4.0

type NaiveGenderRules struct {
	Suffixes []NaiveGenderRulesSuffixes
}

type NaiveGenderRulesSuffixes added in v0.4.0

type NaiveGenderRulesSuffixes struct {
	Length  int
	Genders map[string]Gender
}

type StorableFinder

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

func NewStorableGenderFinder added in v0.4.0

func NewStorableGenderFinder(store Store) *StorableFinder

func (*StorableFinder) Find

func (f *StorableFinder) Find(ctx context.Context, names []string) (*FindResult, error)

type Store

type Store interface {
	Get(ctx context.Context, names []string) (*GetResult, error)
}

func LoadCSVStore

func LoadCSVStore(filepath string) (Store, error)

func LoadStorePerGender

func LoadStorePerGender(maleFilepath string, femaleFilepath string, otherFilepath string) (Store, error)

LoadStorePerGender expects file paths to file, which contain names per line.

Jump to

Keyboard shortcuts

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