alpha

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WORD = "word"
	LINE = "line"
)
View Source
const ALPHA = "alpha"

Variables

View Source
var Index = &ice.Context{Name: ALPHA, Help: "英汉词典",
	Configs: map[string]*ice.Config{
		ALPHA: {Name: ALPHA, Help: "英汉词典", Value: kit.Data(
			kit.MDB_LIMIT, "50000", kit.MDB_LEAST, "1000",
			kit.MDB_STORE, path.Join(ice.USR_LOCAL_EXPORT, ALPHA), kit.MDB_FSIZE, "2000000",
			kit.SSH_REPOS, "word-dict", kit.MDB_FIELD, []interface{}{
				"audio", "bnc", "collins", "definition", "detail", "exchange", "frq", "id", "oxford", "phonetic", "pos", "tag", "time", "translation", "word",
			},
		)},
		"_cache": {Name: "_cache", Value: kit.Data(kit.MDB_SHORT, "mw")},
	},
	Commands: map[string]*ice.Command{
		ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			m.Load()
			m.Cmd(mdb.SEARCH, mdb.CREATE, ALPHA, m.Prefix(ALPHA))
		}},
		ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},

		ALPHA: {Name: "alpha method=word,line word auto _cache", Help: "英汉", Action: map[string]*ice.Action{
			mdb.IMPORT: {Name: "import file=usr/word-dict/ecdict name", Help: "加载词库", Hand: func(m *ice.Message, arg ...string) {
				_alpha_load(m, m.Option(kit.MDB_FILE), kit.Select(path.Base(m.Option(kit.MDB_FILE)), m.Option(kit.MDB_NAME)))
			}},
			mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
				if arg[0] == ALPHA {
					_alpha_find(m, kit.Select(WORD, arg, 2), arg[1])
				}
			}},
			"_cache": {Name: "_cache", Help: "缓存", Hand: func(m *ice.Message, arg ...string) {
				m.OptionFields("time,id,word,translation,definition")
				m.Cmdy(mdb.SELECT, m.Prefix("_cache"), "", mdb.HASH)
			}},
		}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			if len(arg) < 2 {
				return
			}
			defer m.StatusTimeCount()
			m.OptionFields("id,word,translation,definition")
			if m.Cmdy(mdb.SELECT, m.Prefix("_cache"), "", mdb.HASH, "mw", arg[0]+arg[1]); len(m.Appendv("id")) > 0 {
				return
			}
			if _alpha_find(m, arg[0], arg[1]); len(m.Appendv("id")) > 0 {
				m.Cmd(mdb.INSERT, m.Prefix("_cache"), "", mdb.HASH, "mw", arg[0]+arg[1], m.AppendSimple())
			}
		}},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL