Added cj & jyutping lookup
This commit is contained in:
42
datasources/cjlookup/searchables.go
Normal file
42
datasources/cjlookup/searchables.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package cjlookup
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
query "github.com/tgckpg/golifehk/query"
|
||||
)
|
||||
|
||||
func getSearchables() (*[]query.ISearchable, error) {
|
||||
searchables := []query.ISearchable{}
|
||||
|
||||
cjRepl, err := ReadCangJieKeys()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
chars := map[string]*CChar{}
|
||||
ReadCangJieTable(chars, cjRepl)
|
||||
jpMap, err := ReadJyutPingTable(chars)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for jyutping, chars := range jpMap {
|
||||
for _, c := range *chars {
|
||||
cjp := CJyutPing{}
|
||||
cjp.Ref = c
|
||||
cjp.SKey = strings.ToUpper(jyutping)
|
||||
cjp.Key = &cjp.SKey
|
||||
searchables = append(searchables, &cjp)
|
||||
}
|
||||
}
|
||||
|
||||
for _, c := range chars {
|
||||
ccj := CFace{}
|
||||
ccj.Ref = c
|
||||
ccj.Key = &c.Face
|
||||
searchables = append(searchables, &ccj)
|
||||
}
|
||||
|
||||
return &searchables, nil
|
||||
}
|
||||
Reference in New Issue
Block a user