-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parse.go
More file actions
41 lines (35 loc) · 961 Bytes
/
Copy pathtest_parse.go
File metadata and controls
41 lines (35 loc) · 961 Bytes
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
//go:build ignore
package main
import (
"encoding/json"
"fmt"
"os"
"strings"
)
type TaxonomyMap map[string]string
func main() {
data, err := os.ReadFile("internal/classifier/data/eBird_taxonomy_codes_2021E.json")
if err != nil {
fmt.Printf("Err: %v\n", err)
return
}
var taxonomyMap TaxonomyMap
if err := json.Unmarshal(data, &taxonomyMap); err != nil {
fmt.Printf("Err: %v\n", err)
return
}
index := make(map[string]string)
for taxonName, taxonCode := range taxonomyMap {
parts := strings.Split(taxonName, "_")
sci := taxonName
if len(parts) == 2 {
sci = parts[0]
}
index[strings.ToLower(sci)] = taxonCode
}
fmt.Printf("Size: %d\n", len(index))
fmt.Printf("Cardinalis cardinalis: %q\n", index["cardinalis cardinalis"])
fmt.Printf("Dryophytes cinereus: %q\n", index["dryophytes cinereus"])
fmt.Printf("Buteo lineatus: %q\n", index["buteo lineatus"])
fmt.Printf("Spizella pallida: %q\n", index["spizella pallida"])
}