Last active
June 28, 2021 14:16
-
-
Save elliotchance/30b6fe0069aace5ece7ee968c1c0cbc6 to your computer and use it in GitHub Desktop.
Compare gedcom files with Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/elliotchance/gedcom" | |
) | |
func main() { | |
// 1. Load gedcom files. | |
leftGedcom, err := gedcom.NewDocumentFromGEDCOMFile("file1.ged") | |
check(err) | |
rightGedcom, err := gedcom.NewDocumentFromGEDCOMFile("file2.ged") | |
check(err) | |
// 2. Configure any options for the comparison. | |
similarityOptions := gedcom.NewSimilarityOptions() | |
// similarityOptions.MinimumWeightedSimilarity = | |
// similarityOptions.PreferPointerAbove = | |
// similarityOptions.MinimumSimilarity = | |
compareOptions := gedcom.NewIndividualNodesCompareOptions() | |
compareOptions.SimilarityOptions = similarityOptions | |
// 3. Perform comparison. | |
leftIndividuals := leftGedcom.Individuals() | |
rightIndividuals := rightGedcom.Individuals() | |
comparisons := leftIndividuals.Compare(rightIndividuals, compareOptions) | |
// 4. Do stuff with the results. | |
for _, comparison := range comparisons { | |
fmt.Println(comparison) | |
} | |
} | |
func check(err error) { | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment