mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt alpha
This commit is contained in:
parent
bf3847e436
commit
351c1981ca
@ -127,7 +127,7 @@ func init() {
|
||||
})
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
|
||||
mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value map[string]string, head []string) {
|
||||
switch value[STATUS] {
|
||||
case START:
|
||||
m.PushButton(RESTART, STOP)
|
||||
|
@ -60,7 +60,9 @@ func _hash_select(m *ice.Message, prefix, chain, field, value string) {
|
||||
value = RANDOMS
|
||||
}
|
||||
fields := _hash_fields(m)
|
||||
m.Debug("what %v", 123)
|
||||
m.Richs(prefix, chain, value, func(key string, val map[string]interface{}) {
|
||||
m.Debug("what %v", 123)
|
||||
switch val = kit.GetMeta(val); cb := m.Optionv(kit.Keycb(SELECT)).(type) {
|
||||
case func(fields []string, value map[string]interface{}):
|
||||
cb(fields, val)
|
||||
|
@ -2,12 +2,16 @@ package mdb
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _file_name(m *ice.Message, arg ...string) string {
|
||||
if len(arg) > 3 && strings.Contains(arg[3], ice.PS) {
|
||||
return arg[3]
|
||||
}
|
||||
return path.Join(ice.USR_LOCAL_EXPORT, m.Option(ice.MSG_DOMAIN), path.Join(arg[:2]...), arg[2])
|
||||
return kit.Select(path.Join(ice.USR_LOCAL_EXPORT, m.Option(ice.MSG_DOMAIN), path.Join(arg[:2]...), arg[2]), arg, 3)
|
||||
}
|
||||
@ -208,6 +212,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
||||
case HASH:
|
||||
_hash_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||
case LIST:
|
||||
m.Debug("what %v /// %v", arg, file)
|
||||
_list_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||
}
|
||||
}},
|
||||
|
4
conf.go
4
conf.go
@ -12,9 +12,9 @@ const (
|
||||
|
||||
PWD = "./"
|
||||
|
||||
JS = "js"
|
||||
GO = "go"
|
||||
SH = "sh"
|
||||
GO = "go"
|
||||
JS = "js"
|
||||
|
||||
OK = "ok"
|
||||
TRUE = "true"
|
||||
|
@ -24,7 +24,8 @@ func _website_parse(m *ice.Message, text string) map[string]interface{} {
|
||||
for i := 2; i < len(ls); i += 2 {
|
||||
switch ls[i] {
|
||||
case ctx.ARGS:
|
||||
data[ls[i]] = kit.UnMarshal(ls[i+1])
|
||||
data[ls[i]] = kit.Split(ls[i+1])
|
||||
// data[ls[i]] = kit.UnMarshal(ls[i+1])
|
||||
default:
|
||||
data[ls[i]] = ls[i+1]
|
||||
}
|
||||
|
@ -87,9 +87,21 @@ func init() {
|
||||
return false
|
||||
})
|
||||
nfs.AddRewrite(func(msg *ice.Message, name string) []byte {
|
||||
if strings.HasPrefix(name, ice.SRC) {
|
||||
if _, e := os.Stat(name); e == nil {
|
||||
if f, e := os.Open(name); e == nil {
|
||||
defer f.Close()
|
||||
if b, e := ioutil.ReadAll(f); e == nil {
|
||||
m.Logs("local", len(b), name)
|
||||
return b // 本地文件
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if b, ok := ice.Info.Pack[name]; ok {
|
||||
m.Logs("binpack", len(b), name)
|
||||
return b
|
||||
return b // 打包文件
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
1
go.mod
1
go.mod
@ -4,7 +4,6 @@ go 1.11
|
||||
|
||||
require (
|
||||
shylinux.com/x/go-qrcode v0.0.1
|
||||
shylinux.com/x/ice v0.4.7
|
||||
shylinux.com/x/toolkits v0.4.4
|
||||
shylinux.com/x/websocket v0.0.1
|
||||
)
|
||||
|
10
init.go
10
init.go
@ -98,18 +98,14 @@ var Pulse = &Message{
|
||||
}
|
||||
|
||||
func Run(arg ...string) string {
|
||||
if len(arg) == 0 {
|
||||
arg = os.Args[1:]
|
||||
}
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, HELP)
|
||||
}
|
||||
if os.Getenv("ctx_arg") != "" {
|
||||
arg = append(arg, kit.Split(os.Getenv("ctx_arg"))...)
|
||||
}
|
||||
if arg = append(arg, os.Args[1:]...); len(arg) == 0 {
|
||||
arg = append(arg, HELP)
|
||||
}
|
||||
|
||||
Index.root, Pulse.root = Index, Pulse
|
||||
|
||||
switch Index.Merge(Index).Begin(Pulse.Spawn(), arg...); kit.Select("", arg, 0) {
|
||||
case "serve", "space":
|
||||
if log.LogDisable = false; Index.Start(Pulse, arg...) {
|
||||
|
@ -5,98 +5,81 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/core/wiki"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _alpha_find(m *ice.Message, method, word string) {
|
||||
if word == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// 搜索方法
|
||||
switch word = strings.TrimSpace(word); method {
|
||||
case LINE:
|
||||
case WORD:
|
||||
word = "^" + word + ","
|
||||
}
|
||||
|
||||
// 搜索词汇
|
||||
msg := m.Cmd(cli.SYSTEM, "grep", "-rih", word, m.Config(mdb.STORE))
|
||||
msg.CSV(msg.Result(), kit.Split(m.Config(mdb.FIELD))...).Table(func(index int, value map[string]string, head []string) {
|
||||
if m.FieldsIsDetail() {
|
||||
m.Push(mdb.DETAIL, value, kit.Split(m.Config(mdb.FIELD)))
|
||||
m.Push(mdb.TIME, m.Time())
|
||||
return
|
||||
}
|
||||
m.PushSearch(ice.CMD, ALPHA, mdb.TYPE, method, mdb.NAME, value[WORD], mdb.TEXT, value["translation"], value)
|
||||
})
|
||||
}
|
||||
func _alpha_load(m *ice.Message, file, name string) {
|
||||
// 清空数据
|
||||
meta := m.Confm(ALPHA, mdb.META)
|
||||
m.Assert(os.RemoveAll(path.Join(kit.Format(meta[mdb.STORE]), name)))
|
||||
m.Conf(ALPHA, name, "")
|
||||
|
||||
// 缓存配置
|
||||
m.Conf(ALPHA, kit.Keys(name, mdb.META), kit.Dict(meta))
|
||||
m.Cmd(mdb.IMPORT, ALPHA, name, mdb.LIST, file)
|
||||
|
||||
// 保存词库
|
||||
m.Conf(ALPHA, kit.Keys(name, kit.Keym(mdb.LIMIT)), 0)
|
||||
m.Conf(ALPHA, kit.Keys(name, kit.Keym(mdb.LEAST)), 0)
|
||||
m.Echo("%s: %d", name, m.Grow(ALPHA, name, kit.Dict(WORD, ice.SP)))
|
||||
}
|
||||
|
||||
const (
|
||||
WORD = "word"
|
||||
LINE = "line"
|
||||
)
|
||||
|
||||
const ALPHA = "alpha"
|
||||
type alpha struct {
|
||||
cache
|
||||
field string `data:"word,translation,definition"`
|
||||
store string `data:"usr/local/export/alpha"`
|
||||
fsize string `data:"300000"`
|
||||
limit string `data:"50000"`
|
||||
least string `data:"1000"`
|
||||
|
||||
var Index = &ice.Context{Name: ALPHA, Help: "英汉词典", Configs: map[string]*ice.Config{
|
||||
ALPHA: {Name: ALPHA, Help: "英汉词典", Value: kit.Data(
|
||||
nfs.REPOS, "word-dict", mdb.FIELD, "word,translation,definition",
|
||||
mdb.STORE, path.Join(ice.USR_LOCAL_EXPORT, ALPHA), mdb.FSIZE, "300000",
|
||||
mdb.LIMIT, "50000", mdb.LEAST, "1000",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
ALPHA: {Name: "alpha method=word,line word auto", Help: "英汉", Action: map[string]*ice.Action{
|
||||
mdb.IMPORT: {Name: "import file=usr/word-dict/ecdict name=ecdict", Help: "加载词库", Hand: func(m *ice.Message, arg ...string) {
|
||||
_alpha_load(m, m.Option(nfs.FILE), kit.Select(path.Base(m.Option(nfs.FILE)), m.Option(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])
|
||||
}
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(CACHE, mdb.REMOVE)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
m.Cmdy(CACHE, kit.Select("", arg, 1))
|
||||
load string `name:"load file=usr/word-dict/ecdict name=ecdict" help:"词典"`
|
||||
list string `name:"list method=word,line word auto" help:"词典"`
|
||||
}
|
||||
|
||||
func (a alpha) Load(m *ice.Message, arg ...string) {
|
||||
name := m.Option(mdb.NAME)
|
||||
// 清空数据
|
||||
meta := m.Confm(m.PrefixKey(), mdb.META)
|
||||
m.Assert(os.RemoveAll(path.Join(kit.Format(meta[mdb.STORE]), name)))
|
||||
m.Conf(m.PrefixKey(), name, "")
|
||||
|
||||
// 缓存配置
|
||||
m.Conf(m.PrefixKey(), kit.Keys(name, mdb.META), kit.Dict(meta))
|
||||
m.Cmd(mdb.IMPORT, m.PrefixKey(), name, mdb.LIST, m.Option(nfs.FILE))
|
||||
|
||||
// 保存词库
|
||||
m.Conf(m.PrefixKey(), kit.Keys(name, kit.Keym(mdb.LIMIT)), 0)
|
||||
m.Conf(m.PrefixKey(), kit.Keys(name, kit.Keym(mdb.LEAST)), 0)
|
||||
m.Echo("%s: %d", name, m.Grow(m.PrefixKey(), name, kit.Dict(WORD, ice.SP)))
|
||||
}
|
||||
func (a alpha) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 || arg[1] == "" {
|
||||
m.Cmdy(a.cache, kit.Slice(arg, 1))
|
||||
return
|
||||
}
|
||||
|
||||
// 搜索方法
|
||||
switch arg[1] = strings.TrimSpace(arg[1]); arg[0] {
|
||||
case LINE:
|
||||
m.OptionFields(m.Config(mdb.FIELD))
|
||||
case WORD:
|
||||
if m.Cmdy(a.cache, kit.Slice(arg, 1)); m.Length() > 0 {
|
||||
return
|
||||
}
|
||||
defer m.StatusTimeCountTotal(m.Config(mdb.COUNT))
|
||||
if arg[0] == WORD {
|
||||
if msg := m.Cmd(CACHE, arg[1]); msg.Length() > 0 {
|
||||
m.Copy(msg)
|
||||
return
|
||||
defer func() {
|
||||
if m.Length() > 0 {
|
||||
m.Cmd(a.cache.Create, m.AppendSimple())
|
||||
}
|
||||
m.OptionFields(mdb.DETAIL)
|
||||
} else {
|
||||
m.OptionFields(m.Config(mdb.FIELD))
|
||||
}
|
||||
if _alpha_find(m, arg[0], arg[1]); arg[0] == WORD && m.Length() > 0 {
|
||||
m.Cmd(CACHE, mdb.CREATE, m.AppendSimple())
|
||||
}
|
||||
}},
|
||||
}}
|
||||
}()
|
||||
|
||||
func init() { wiki.Index.Register(Index, nil) }
|
||||
m.OptionFields(mdb.DETAIL)
|
||||
arg[1] = "^" + arg[1] + ice.FS
|
||||
}
|
||||
|
||||
// 搜索词汇
|
||||
msg := m.Cmd(cli.SYSTEM, "grep", "-rih", arg[1], m.Config(mdb.STORE))
|
||||
msg.CSV(msg.Result(), kit.Split(m.Config(mdb.FIELD))...).Table(func(index int, value map[string]string, head []string) {
|
||||
if m.FieldsIsDetail() {
|
||||
m.Push(mdb.DETAIL, value, kit.Split(m.Config(mdb.FIELD)))
|
||||
m.Push(mdb.TIME, m.Time())
|
||||
return
|
||||
}
|
||||
m.PushSearch(kit.SimpleKV("", arg[0], value[WORD], value["translation"]), value)
|
||||
})
|
||||
m.StatusTimeCount()
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.wiki.alpha.alpha", alpha{}) }
|
||||
|
@ -1,23 +1,18 @@
|
||||
package alpha
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/ice"
|
||||
)
|
||||
|
||||
const CACHE = "cache"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
CACHE: {Name: "cache", Help: "缓存", Value: kit.Data(
|
||||
mdb.SHORT, "word", mdb.FIELD, "time,word,translation,definition",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
CACHE: {Name: "cache word auto", Help: "缓存", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create word translation definition", Help: "创建"},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
mdb.HashSelect(m, arg...)
|
||||
}},
|
||||
}})
|
||||
type cache struct {
|
||||
ice.Hash
|
||||
short string `data:"word"`
|
||||
field string `data:"time,word,translation,definition"`
|
||||
create string `name:"create word translation definition" help:"创建"`
|
||||
}
|
||||
|
||||
func (c cache) Create(m *ice.Message, arg ...string) {
|
||||
c.Hash.Create(m, arg...)
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.wiki.alpha.cache", cache{}) }
|
||||
|
@ -26,4 +26,4 @@ var Index = &ice.Context{Name: GIT, Help: "代码库", Configs: map[string]*ice.
|
||||
}},
|
||||
}}
|
||||
|
||||
func init() { code.Index.Register(Index, &web.Frame{}) }
|
||||
func init() { code.Index.Register(Index, &web.Frame{}, REPOS) }
|
||||
|
@ -9,46 +9,36 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _input_find(m *ice.Message, method, word, limit string) {
|
||||
switch method {
|
||||
case LINE:
|
||||
case WORD:
|
||||
word = "^" + word + ","
|
||||
}
|
||||
const (
|
||||
TEXT = "text"
|
||||
CODE = "code"
|
||||
WEIGHT = "weight"
|
||||
)
|
||||
const (
|
||||
WORD = "word"
|
||||
LINE = "line"
|
||||
)
|
||||
|
||||
// 搜索词汇
|
||||
res := m.Cmdx(cli.SYSTEM, "grep", "-rn", word, m.Config(mdb.STORE))
|
||||
bio := csv.NewReader(bytes.NewBufferString(strings.Replace(res, ":", ",", -1)))
|
||||
|
||||
for i := 0; i < kit.Int(limit); i++ {
|
||||
if line, e := bio.Read(); e != nil {
|
||||
break
|
||||
} else if len(line) < 3 {
|
||||
|
||||
} else { // 输出词汇
|
||||
m.Push(mdb.ID, line[3])
|
||||
m.Push(CODE, line[2])
|
||||
m.Push(TEXT, line[4])
|
||||
m.Push(WEIGHT, line[6])
|
||||
}
|
||||
|
||||
}
|
||||
m.SortIntR(WEIGHT)
|
||||
type input struct {
|
||||
insert string `name:"insert zone=person text code weight" help:"添加"`
|
||||
load string `name:"load file=usr/wubi-dict/wubi86 zone=wubi86" help:"加载"`
|
||||
save string `name:"save file=usr/wubi-dict/person zone=person" help:"保存"`
|
||||
list string `name:"list method code auto" help:"输入法"`
|
||||
}
|
||||
func _input_load(m *ice.Message, file string, libs ...string) {
|
||||
if f, e := os.Open(file); m.Assert(e) {
|
||||
|
||||
func (i input) Load(m *ice.Message, arg ...string) {
|
||||
if f, e := os.Open(m.Option(nfs.FILE)); m.Assert(e) {
|
||||
defer f.Close()
|
||||
|
||||
// 清空数据
|
||||
lib := kit.Select(path.Base(file), libs, 0)
|
||||
lib := kit.Select(path.Base(m.Option(nfs.FILE)), m.Option(mdb.ZONE))
|
||||
m.Assert(os.RemoveAll(path.Join(m.Config(mdb.STORE), lib)))
|
||||
m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, mdb.ZONE, lib)
|
||||
prefix := kit.Keys(mdb.HASH, m.Rich(m.PrefixKey(), "", kit.Data(
|
||||
@ -59,7 +49,7 @@ func _input_load(m *ice.Message, file string, libs ...string) {
|
||||
|
||||
// 加载词库
|
||||
for bio := bufio.NewScanner(f); bio.Scan(); {
|
||||
if strings.HasPrefix(bio.Text(), "#") {
|
||||
if strings.HasPrefix(bio.Text(), "# ") {
|
||||
continue
|
||||
}
|
||||
line := kit.Split(bio.Text())
|
||||
@ -77,32 +67,12 @@ func _input_load(m *ice.Message, file string, libs ...string) {
|
||||
m.Echo("%s: %d", lib, n)
|
||||
}
|
||||
}
|
||||
func _input_push(m *ice.Message, lib, text, code, weight string) {
|
||||
if m.Richs(m.PrefixKey(), "", lib, nil) == nil {
|
||||
m.Rich(m.PrefixKey(), "", kit.Data(
|
||||
mdb.STORE, path.Join(m.Config(mdb.STORE), lib),
|
||||
mdb.FSIZE, m.Config(mdb.FSIZE),
|
||||
mdb.LIMIT, m.Config(mdb.LIMIT),
|
||||
mdb.LEAST, m.Config(mdb.LEAST),
|
||||
mdb.ZONE, lib,
|
||||
))
|
||||
}
|
||||
|
||||
m.Richs(m.PrefixKey(), "", lib, func(key string, value map[string]interface{}) {
|
||||
prefix := kit.Keys(mdb.HASH, key)
|
||||
m.Conf(m.PrefixKey(), kit.Keys(prefix, kit.Keym(mdb.LIMIT)), 0)
|
||||
m.Conf(m.PrefixKey(), kit.Keys(prefix, kit.Keym(mdb.LEAST)), 0)
|
||||
n := m.Grow(m.PrefixKey(), prefix, kit.Dict(TEXT, text, CODE, code, WEIGHT, weight))
|
||||
m.Log_IMPORT(CODE, code, TEXT, text)
|
||||
m.Echo("%s: %d", lib, n)
|
||||
})
|
||||
}
|
||||
func _input_save(m *ice.Message, file string, lib ...string) {
|
||||
if f, p, e := kit.Create(file); m.Assert(e) {
|
||||
func (i input) Save(m *ice.Message, arg ...string) {
|
||||
if f, p, e := kit.Create(m.Option(nfs.FILE)); m.Assert(e) {
|
||||
defer f.Close()
|
||||
n := 0
|
||||
m.Option(ice.CACHE_LIMIT, -2)
|
||||
for _, lib := range lib {
|
||||
for _, lib := range kit.Split(m.Option(mdb.ZONE)) {
|
||||
m.Richs(m.PrefixKey(), "", lib, func(key string, value map[string]interface{}) {
|
||||
m.Grows(m.PrefixKey(), kit.Keys(mdb.HASH, key), "", "", func(index int, value map[string]interface{}) {
|
||||
if value[CODE] != "z" {
|
||||
@ -112,39 +82,36 @@ func _input_save(m *ice.Message, file string, lib ...string) {
|
||||
})
|
||||
})
|
||||
}
|
||||
m.Log_EXPORT(FILE, p, mdb.COUNT, n)
|
||||
m.Log_EXPORT(nfs.FILE, p, mdb.COUNT, n)
|
||||
m.Echo("%s: %d", p, n)
|
||||
}
|
||||
}
|
||||
|
||||
func _input_list(m *ice.Message, lib string) {
|
||||
if lib == "" {
|
||||
m.Richs(m.PrefixKey(), "", mdb.FOREACH, func(key string, value map[string]interface{}) {
|
||||
m.Push("", kit.GetMeta(value), kit.Split("time,zone,count,store"))
|
||||
})
|
||||
func (i input) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 || arg[1] == "" {
|
||||
return
|
||||
}
|
||||
switch arg[0] {
|
||||
case LINE:
|
||||
case WORD:
|
||||
arg[1] = "^" + arg[1] + ice.FS
|
||||
}
|
||||
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
m.Richs(m.PrefixKey(), "", lib, func(key string, value map[string]interface{}) {
|
||||
m.Cmdy(nfs.DIR, kit.Value(value, kit.Keym(mdb.STORE)), "time size line path")
|
||||
})
|
||||
// 搜索词汇
|
||||
res := m.Cmdx(cli.SYSTEM, "grep", "-rn", arg[1], m.Config(mdb.STORE))
|
||||
bio := csv.NewReader(bytes.NewBufferString(strings.Replace(res, ":", ",", -1)))
|
||||
|
||||
for i := 0; i < kit.Int(10); i++ {
|
||||
if line, e := bio.Read(); e != nil {
|
||||
break
|
||||
} else if len(line) < 3 {
|
||||
|
||||
} else { // 输出词汇
|
||||
m.Push(mdb.ID, line[3])
|
||||
m.Push(CODE, line[2])
|
||||
m.Push(TEXT, line[4])
|
||||
m.Push(WEIGHT, line[6])
|
||||
}
|
||||
}
|
||||
m.SortIntR(WEIGHT)
|
||||
m.StatusTimeCount()
|
||||
}
|
||||
|
||||
const (
|
||||
ZONE = "zone"
|
||||
FILE = "file"
|
||||
CODE = "code"
|
||||
TEXT = "text"
|
||||
WEIGHT = "weight"
|
||||
)
|
||||
const (
|
||||
WORD = "word"
|
||||
LINE = "line"
|
||||
)
|
||||
const INPUT = "input"
|
||||
|
||||
var Index = &ice.Context{Name: INPUT, Help: "输入法"}
|
||||
|
||||
func init() { code.Index.Register(Index, nil) }
|
||||
|
@ -1,37 +1,22 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/ice"
|
||||
)
|
||||
|
||||
const WUBI = "wubi"
|
||||
type wubi struct {
|
||||
input
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
WUBI: {Name: WUBI, Help: "输入法", Value: kit.Data(
|
||||
mdb.STORE, path.Join(ice.USR_LOCAL_EXPORT, INPUT, WUBI), mdb.FSIZE, "200000",
|
||||
mdb.SHORT, "zone", nfs.REPOS, "wubi-dict",
|
||||
mdb.LIMIT, "5000", mdb.LEAST, "1000",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
WUBI: {Name: "wubi method=word,line code auto", Help: "五笔", Action: map[string]*ice.Action{
|
||||
mdb.INSERT: {Name: "insert zone=person text code weight", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_input_push(m, m.Option(ZONE), m.Option(TEXT), m.Option(CODE), m.Option(WEIGHT))
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export file=usr/wubi-dict/person zone=person", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
_input_save(m, m.Option(FILE), m.Option(ZONE))
|
||||
}},
|
||||
mdb.IMPORT: {Name: "import file=usr/wubi-dict/wubi86 zone=wubi86", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
_input_load(m, m.Option(FILE), m.Option(ZONE))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_input_find(m, arg[0], arg[1], m.Option(ice.CACHE_LIMIT))
|
||||
m.StatusTime()
|
||||
}},
|
||||
}})
|
||||
short string `data:"zone"`
|
||||
store string `data:"usr/local/export/input/wubi"`
|
||||
fsize string `data:"300000"`
|
||||
limit string `data:"50000"`
|
||||
least string `data:"1000"`
|
||||
|
||||
insert string `name:"insert zone=person text code weight" help:"添加"`
|
||||
load string `name:"load file=usr/wubi-dict/wubi86 zone=wubi86" help:"加载"`
|
||||
save string `name:"save file=usr/wubi-dict/person zone=person" help:"保存"`
|
||||
list string `name:"list method=word,line code auto" help:"五笔"`
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.code.input.wubi", wubi{}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user