1
0
mirror of https://github.com/fumiama/emozi.git synced 2026-07-01 09:20:24 +08:00
This commit is contained in:
源文雨
2024-02-14 18:39:07 +09:00
parent 9463d5e7b6
commit ceb7686da6
18 changed files with 1776 additions and 0 deletions

53
lookup.go Normal file
View File

@@ -0,0 +1,53 @@
package emozi
import (
"math/rand"
"strconv"
)
var = "🈳️"
func (c *Coder) 查声母(s 声母枚举) string {
lst := 声母[s]
if len(lst) == 0 {
return
}
if len(lst) == 1 || !c.isRandom {
return lst[0]
}
return lst[rand.Intn(len(lst))]
}
func (c *Coder) 查韵母(y 韵母枚举) string {
lst := 韵母[y]
if len(lst) == 0 {
return
}
if len(lst) == 1 || !c.isRandom {
return lst[0]
}
return lst[rand.Intn(len(lst))]
}
func (c *Coder) 查声调(t 声调枚举) string {
lst := 声调[t]
if len(lst) == 0 {
return
}
if len(lst) == 1 || !c.isRandom {
return lst[0]
}
return lst[rand.Intn(len(lst))]
}
func (c *Coder) 查部首(r rune) string {
x := &部首表{}
err := c.db.Find(部首表名, x, "WHERE R="+strconv.Itoa(int(r)))
if err == nil && len(x.E) > 0 && x.E != {
return x.E
}
if e, ok := 部首后备[r]; ok {
return e
}
return
}