tree

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPlaceName = errors.New("invalid place name")

Functions

func CreateFile

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

func DefaultConfigDir

func DefaultConfigDir() string

func SaveGazeteer

func SaveGazeteer(filename string, g *Gazeteer) error

func SaveIdentityMap

func SaveIdentityMap(imFilename string, im *IdentityMap) error

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) ApplyTree

func (o *Annotations) ApplyTree(t *Tree) 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) 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"`
	Trees   []ObjectAnnotationsJSON `json:"trees,omitempty"`
}

type Gazeteer

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

func LoadGazeteer

func LoadGazeteer(filename string) (*Gazeteer, error)

func (*Gazeteer) CleanHierarchy

func (g *Gazeteer) CleanHierarchy()

func (*Gazeteer) ID

func (g *Gazeteer) ID(original string, hints ...place.Hint) string

ID returns the canonical identifier corresponding to the named place, creating a new one if necessary The supplied name is assumed to be generally unstructured, but ordered hierarchically from most to least specific with each heierarchy level separated by a comma. Additional context may be supplied by the use of hints. For example the user could hint that the place could be a UK registration district based on the source being the general register office.

func (*Gazeteer) LookupPlace

func (g *Gazeteer) LookupPlace(id string) (GazeteerPlace, bool)

func (*Gazeteer) MarshalJSON

func (g *Gazeteer) MarshalJSON() ([]byte, error)

func (*Gazeteer) MatchPlace

func (g *Gazeteer) MatchPlace(original string, hints ...place.Hint) (GazeteerPlace, error)

MatchPlace returns information about the named place, creating a new one if necessary The supplied name is assumed to be generally unstructured, but ordered hierarchically from most to least specific with each heierarchy level separated by a comma. Additional context may be supplied by the use of hints. For example the user could hint that the place could be a UK registration district based on the source being the general register office.

func (*Gazeteer) UnmarshalJSON

func (g *Gazeteer) UnmarshalJSON(data []byte) error

type GazeteerJSON

type GazeteerJSON struct {
	Places map[string]PlaceInfoJSON `json:"places"`
}

type GazeteerPlace

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

type IdentityMap

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

func LoadIdentityMap

func LoadIdentityMap(imFilename string) (*IdentityMap, error)

func (*IdentityMap) AddAlias

func (m *IdentityMap) AddAlias(alias string, canonical string)

AddAlias adds an alias to a canonical identifier. This can be used to create more friendly identifiers.

func (*IdentityMap) ID

func (m *IdentityMap) ID(scope string, id string) string

ID returns the canonical identifier corresponding to the scoped identifier, creating a new one if necessary scope indicates the source of the supplied identifier, usually a gedcom file.

func (*IdentityMap) MarshalJSON

func (m *IdentityMap) MarshalJSON() ([]byte, error)

func (*IdentityMap) UnmarshalJSON

func (m *IdentityMap) UnmarshalJSON(data []byte) error

type IdentityMapJSON

type IdentityMapJSON struct {
	Scopes  map[string][]IdentityMappingJSON `json:"scopes"`
	Replace map[string]string                `json:"replace"`
	Places  map[string]string                `json:"places"`
}

type IdentityMappingJSON

type IdentityMappingJSON struct {
	ScopeID string `json:"scopeid"`
	ID      string `json:"id"`
}

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 PlaceInfoJSON

type PlaceInfoJSON struct {
	Name     string   `json:"name"`
	Kind     string   `json:"kind,omitempty"`
	IDSrc    string   `json:"idsrc"`
	Matches  []string `json:"matches,omitempty"`
	ParentID string   `json:"parentid,omitempty"`
}

type SourceAnnotation

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

type Tree

type Tree struct {
	ID           string
	Name         string
	Description  string
	IdentityMap  *IdentityMap
	Gazeteer     *Gazeteer
	Annotations  *Annotations
	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(id string, configDir string, loader Loader) (*Tree, error)

func NewTree

func NewTree(id string, m *IdentityMap, g *Gazeteer, a *Annotations) *Tree

func (*Tree) AddAlias

func (t *Tree) AddAlias(alias string, canonical string)

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) RefinePersonNames

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

func (*Tree) RefinePersonOccupations

func (t *Tree) RefinePersonOccupations(p *model.Person) 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

type TreeAnnotation

type TreeAnnotation struct {
	Field string
	Value any
	Kind  string
	Fn    treeAnnotaterFunc
}

Jump to

Keyboard shortcuts

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