model

package
v1.2.1-0...-2a81cf5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessErrCode   = 200
	InnerSysErrCode  = 500
	BadParamErrCode  = 401
	UnknownErrorCode = 999
)

Variables

This section is empty.

Functions

func DecodeHex

func DecodeHex(str string) ([]byte, error)

func DecodeUTF16

func DecodeUTF16(b []byte) (string, error)

Types

type DictType

type DictType string
const MDD DictType = "MDD"
const MDX DictType = "MDX"

type DictionaryItem

type DictionaryItem struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	PathInfo *DirItem
	MDX      *gomdict.Mdict
	MDDS     []*gomdict.Mdict
}

func NewByDirItem

func NewByDirItem(dirItem *DirItem) (*DictionaryItem, error)

type DirItem

type DirItem struct {
	BaseDir    string
	CurrentDir string
	MdxAbsPath string
	MddAbsPath []string
}

type KeyBlockEntry

type KeyBlockEntry struct {
	ID                int    `json:"id"`
	RecordStartOffset int64  `json:"record_start_offset"`
	RecordEndOffset   int64  `json:"record_end_offset"`
	KeyWord           string `json:"key_word"`
	KeyBlockIdx       int64  `json:"key_block_idx"`
}

type PlainDictionaryItem

type PlainDictionaryItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
}

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

func NewPQ

func NewPQ(word *WordItem) *PriorityQueue

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type Resp

type Resp struct {
	Data interface{} `json:"data"`
	Err  string      `json:"err"`
	Code int         `json:"code"`
}

func BuildError

func BuildError(err error, code int) *Resp

func BuildSuccess

func BuildSuccess(data interface{}) *Resp

type WordItem

type WordItem struct {
	RawKeyWord  string `json:"raw_key_word"`
	KeyWord     string `json:"key_word"`
	RecordStart uint64 `json:"record_start"`
}

func NewWordItem

func NewWordItem(wtype DictType, rawkw string, rs uint64) (*WordItem, error)

func (*WordItem) Distance

func (wi *WordItem) Distance(e bktree.Entry) int

Distance calculates levenshtein distance.

func (*WordItem) HMDistance

func (wi *WordItem) HMDistance(e bktree.Entry) int

HMDistance calculates hamming distance.

type WrappedWordItem

type WrappedWordItem struct {
	DictId string `json:"dict_id"`
	*WordItem
}

Jump to

Keyboard shortcuts

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