-
Notifications
You must be signed in to change notification settings - Fork 19
/
wife_node.go
52 lines (40 loc) 路 1.18 KB
/
wife_node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package gedcom
import "fmt"
// WifeNode is an individual in the role as a mother and/or married woman.
type WifeNode struct {
*SimpleNode
family *FamilyNode
}
func newWifeNode(family *FamilyNode, value string, children ...Node) *WifeNode {
return &WifeNode{
newSimpleNode(TagWife, value, "", children...),
family,
}
}
func newWifeNodeWithIndividual(family *FamilyNode, individual *IndividualNode) *WifeNode {
// TODO: check individual belongs to the same document as family
return newWifeNode(family, fmt.Sprintf("@%s@", individual.Pointer()))
}
func (node *WifeNode) Family() *FamilyNode {
return node.family
}
func (node *WifeNode) Individual() *IndividualNode {
if node == nil {
return nil
}
n := node.family.document.NodeByPointer(valueToPointer(node.value))
// TODO: may not exist
return n.(*IndividualNode)
}
func (node *WifeNode) Similarity(other *WifeNode, options SimilarityOptions) float64 {
if node == nil || other == nil {
return 0.5
}
return node.Individual().Similarity(other.Individual(), options)
}
func (node *WifeNode) IsIndividual(node2 *IndividualNode) bool {
if node == nil || node2 == nil {
return false
}
return node.Individual().Is(node2)
}