Help us shape the future of Go! Take the 2026 Go Developer Survey

tree

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Unlicense Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(fname string) (*os.File, error)

func WalkFamilyLines added in v0.0.3

func WalkFamilyLines(keyPerson *model.Person) []*model.FamilyLine

WalkFamilyLines traverses the ancestor tree of keyPerson, following the paternal line at each generation and pushing maternal branches onto a stack. It returns one FamilyLine per direct line found.

Types

type Annotations

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

func LoadAnnotations

func LoadAnnotations(filename string) (*Annotations, error)

func (*Annotations) Add

func (o *Annotations) Add(kind string, id string, field string, value any) error

func (*Annotations) ApplyPerson

func (o *Annotations) ApplyPerson(p *model.Person) error

func (*Annotations) ApplyPlace

func (o *Annotations) ApplyPlace(p *model.Place) error

func (*Annotations) ApplySource

func (o *Annotations) ApplySource(p *model.Source) error

func (*Annotations) MarshalJSON

func (a *Annotations) MarshalJSON() ([]byte, error)

func (*Annotations) Replace

func (o *Annotations) Replace(kind string, id string, field string, value any) error

func (*Annotations) Set added in v0.0.3

func (o *Annotations) Set(kind, id, field string, value any) error

Set applies a field value to the named kind/id, trying Replace first then Add.

func (*Annotations) UnmarshalJSON

func (a *Annotations) UnmarshalJSON(data []byte) error

type AnnotationsJSON

type AnnotationsJSON struct {
	People  []ObjectAnnotationsJSON `json:"people,omitempty"`
	Places  []ObjectAnnotationsJSON `json:"places,omitempty"`
	Sources []ObjectAnnotationsJSON `json:"sources,omitempty"`
}

type Config added in v0.0.3

type Config struct {
	ID            string
	Name          string
	Description   string
	SurnameGroups *SurnameGroups
	Annotations   *Annotations
}

Config holds the configuration for a tree.

func ReadConfig added in v0.0.3

func ReadConfig(filename string) (*Config, error)

ReadConfig reads a KDL config file and returns a *Config.

type Loader

type Loader interface {
	Load(*Tree) error
	Scope() string
}

type ObjectAnnotationsJSON

type ObjectAnnotationsJSON struct {
	ID      string         `json:"id,omitempty"`
	Comment string         `json:"comment,omitempty"` // for use by user as a free form comment in the annotations file
	Replace map[string]any `json:"replace,omitempty"`
	Add     map[string]any `json:"add,omitempty"`
}

type PersonAnnotation

type PersonAnnotation struct {
	Field string
	Value any
	Kind  string
	Fn    personAnnotaterFunc
}

type PersonMeta

type PersonMeta struct {
	Comment     string
	Annotations []PersonAnnotation
}

type PlaceAnnotation

type PlaceAnnotation struct {
	Field string
	Value any
	Kind  string
	Fn    placeAnnotaterFunc
}

type SourceAnnotation

type SourceAnnotation struct {
	Field string
	Value any
	Kind  string
	Fn    sourceAnnotaterFunc
}

type SurnameGroup added in v0.0.3

type SurnameGroup struct {
	Surname string   // canonical surname for this group
	Names   []string // sorted list of surnames in group other than the canonical one
}

func (*SurnameGroup) String added in v0.0.3

func (g *SurnameGroup) String() string

type SurnameGroups added in v0.0.3

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

func LoadSurnameGroups added in v0.0.3

func LoadSurnameGroups(filename string) (*SurnameGroups, error)

func (*SurnameGroups) AddGroup added in v0.0.3

func (sg *SurnameGroups) AddGroup(canonical string, variants []string)

AddGroup registers a canonical surname and its variants in the group map.

func (*SurnameGroups) Lookup added in v0.0.3

func (sg *SurnameGroups) Lookup(name string) (*SurnameGroup, bool)

Lookup returns the SurnameGroup for the given name (canonical or variant), or nil if not found.

func (*SurnameGroups) UnmarshalJSON added in v0.0.3

func (sg *SurnameGroups) UnmarshalJSON(data []byte) error

type Tree

type Tree struct {
	ID            string
	Name          string
	Description   string
	Annotations   *Annotations
	SurnameGroups *SurnameGroups
	People        map[string]*model.Person
	Citations     map[string]*model.GeneralCitation
	Sources       map[string]*model.Source
	Repositories  map[string]*model.Repository
	Places        map[string]*model.Place
	Families      map[string]*model.Family
	MediaObjects  map[string]*model.MediaObject
	KeyPerson     *model.Person
}

func LoadTree

func LoadTree(cfg *Config, loader Loader) (*Tree, error)

func NewTree

func NewTree(id string, a *Annotations, sg *SurnameGroups) *Tree

func (*Tree) AddPlaceAdjectives added in v0.0.3

func (t *Tree) AddPlaceAdjectives(pl *model.Place) error

func (*Tree) AddSpouses

func (t *Tree) AddSpouses(f *model.Family) error

func (*Tree) ApplyPeopleMatching

func (t *Tree) ApplyPeopleMatching(m model.PersonMatcher, fn model.PersonActionFunc) error

ApplyPeopleMatching applies fn to each person that matches m until fn returns false or an error which is returned if encountered

func (*Tree) BuildOlb

func (t *Tree) BuildOlb(p *model.Person) error

func (*Tree) BuildRelationsToKeyPerson

func (t *Tree) BuildRelationsToKeyPerson()

func (*Tree) CanonicalID

func (t *Tree) CanonicalID(scope string, sid string) string

func (*Tree) CrossReferenceCitations

func (t *Tree) CrossReferenceCitations(p *model.Person)

func (*Tree) ExpandPersonTimeline

func (t *Tree) ExpandPersonTimeline(p *model.Person) error

func (*Tree) FindCitation

func (t *Tree) FindCitation(scope string, sid string) (*model.GeneralCitation, bool)

func (*Tree) FindFamily

func (t *Tree) FindFamily(scope string, sid string) *model.Family

func (*Tree) FindFamilyByParents

func (t *Tree) FindFamilyByParents(father *model.Person, mother *model.Person) *model.Family

func (*Tree) FindFamilyOneParent

func (t *Tree) FindFamilyOneParent(parent *model.Person, child *model.Person) *model.Family

func (*Tree) FindMediaObject

func (t *Tree) FindMediaObject(path string) *model.MediaObject

func (*Tree) FindPerson

func (t *Tree) FindPerson(scope string, sid string) *model.Person

func (*Tree) FindPlace

func (t *Tree) FindPlace(scope string, sid string) *model.Place

func (*Tree) FindPlaceUnstructured

func (t *Tree) FindPlaceUnstructured(name string, hints ...place.Hint) *model.Place

func (*Tree) FindRepository

func (t *Tree) FindRepository(scope string, sid string) *model.Repository

func (*Tree) FindSource

func (t *Tree) FindSource(scope string, sid string) *model.Source

func (*Tree) Generate

func (t *Tree) Generate(redactLiving bool) error

func (*Tree) GetCitation

func (t *Tree) GetCitation(id string) (*model.GeneralCitation, bool)

func (*Tree) GetPerson

func (t *Tree) GetPerson(id string) (*model.Person, bool)

func (*Tree) GetPlace

func (t *Tree) GetPlace(id string) (*model.Place, bool)

func (*Tree) GetSource

func (t *Tree) GetSource(id string) (*model.Source, bool)

func (*Tree) InferFamilyRelationships

func (t *Tree) InferFamilyRelationships(f *model.Family) error

func (*Tree) InferFamilyStartEndDates

func (t *Tree) InferFamilyStartEndDates(f *model.Family) error

func (*Tree) ListPeopleMatching

func (t *Tree) ListPeopleMatching(m model.PersonMatcher, limit int) []*model.Person

func (*Tree) ListPlacesMatching

func (t *Tree) ListPlacesMatching(m model.PlaceMatcher, limit int) []*model.Place

func (*Tree) PropagateParents

func (t *Tree) PropagateParents(p *model.Person) error

func (*Tree) Redact

func (t *Tree) Redact(redactLiving bool) error

func (*Tree) RefineFamilyNames added in v0.0.3

func (t *Tree) RefineFamilyNames(f *model.Family) error

func (*Tree) RefinePersonNames

func (t *Tree) RefinePersonNames(p *model.Person) error

func (*Tree) RefinePersonOccupations

func (t *Tree) RefinePersonOccupations(p *model.Person) error

func (*Tree) RefinePlaceNames added in v0.0.3

func (t *Tree) RefinePlaceNames(pl *model.Place) error

func (*Tree) SelectPersonBestBirthDeathEvents

func (t *Tree) SelectPersonBestBirthDeathEvents(p *model.Person) error

func (*Tree) SetKeyPerson

func (t *Tree) SetKeyPerson(p *model.Person)

func (*Tree) TrimCitationEventsCited

func (t *Tree) TrimCitationEventsCited(c *model.GeneralCitation) error

func (*Tree) TrimCitationPeopleCited

func (t *Tree) TrimCitationPeopleCited(c *model.GeneralCitation) error

func (*Tree) TrimPersonTimeline

func (t *Tree) TrimPersonTimeline(p *model.Person) error

func (*Tree) TrimPlaceTimeline

func (t *Tree) TrimPlaceTimeline(p *model.Place) error

func (*Tree) TrimSourceTimeline

func (t *Tree) TrimSourceTimeline(s *model.Source) error

Jump to

Keyboard shortcuts

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