gomdict

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MdictTypeMdd MdictType = 1
	MdictTypeMdx MdictType = 2

	EncryptNoEnc      = 0
	EncryptRecordEnc  = 1
	EncryptKeyInfoEnc = 2
	NumfmtBe8bytesq   = 0
	NumfmtBe4bytesi   = 1
	EncodingUtf8      = 0
	EncodingUtf16     = 1
	EncodingBig5      = 2
	ENCODING_GBK      = 3
	ENCODING_GB2312   = 4
	EncodingGb18030   = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

type Dictionary struct {
	XMLName                  xml.Name `xml:"Dictionary"`
	Text                     string   `xml:",chardata"`
	GeneratedByEngineVersion string   `xml:"GeneratedByEngineVersion,attr"`
	RequiredEngineVersion    string   `xml:"RequiredEngineVersion,attr"`
	Encrypted                string   `xml:"Encrypted,attr"`
	Encoding                 string   `xml:"Encoding,attr"`
	Format                   string   `xml:"Format,attr"`
	Stripkey                 string   `xml:"Stripkey,attr"`
	CreationDate             string   `xml:"CreationDate,attr"`
	Compact                  string   `xml:"Compact,attr"`
	Compat                   string   `xml:"Compat,attr"`
	KeyCaseSensitive         string   `xml:"KeyCaseSensitive,attr"`
	Description              string   `xml:"Description,attr"`
	Title                    string   `xml:"Title,attr"`
	DataSourceFormat         string   `xml:"DataSourceFormat,attr"`
	StyleSheet               string   `xml:"StyleSheet,attr"`
	Left2Right               string   `xml:"Left2Right,attr"`
	RegisterBy               string   `xml:"RegisterBy,attr"`
}

Dictionary was generated 2023-09-11 11:07:50 by https://xml-to-go.github.io/ in Ukraine.

type MDictHeader

type MDictHeader struct {
	HeaderBytesSize          uint32
	HeaderInfoBytes          []byte
	HeaderInfo               string
	Adler32Checksum          uint32
	DictionaryHeaderByteSize int64
}

type MDictKeyBlockData

type MDictKeyBlockData struct {
	KeyEntries                 []*MDictKeyBlockEntry
	KeyEntriesSize             int64
	RecordBlockMetaStartOffset int64
}

type MDictKeyBlockEntry

type MDictKeyBlockEntry struct {
	RecordStartOffset int64
	RecordEndOffset   int64
	KeyWord           string
	KeyBlockIdx       int64
}

func (*MDictKeyBlockEntry) Distance

func (x *MDictKeyBlockEntry) Distance(e bktree.Entry) int

Distance calculates hamming distance.

type MDictKeyBlockInfo

type MDictKeyBlockInfo struct {
	KeyBlockEntriesStartOffset int64
	KeyBlockInfoList           []*MDictKeyBlockInfoItem
}

type MDictKeyBlockInfoItem

type MDictKeyBlockInfoItem struct {
	FirstKey                      string
	FirstKeySize                  int
	LastKey                       string
	LastKeySize                   int
	KeyBlockInfoIndex             int
	KeyBlockCompressSize          int64
	KeyBlockCompAccumulator       int64
	KeyBlockDeCompressSize        int64
	KeyBlockDeCompressAccumulator int64
}

type MDictKeyBlockMeta

type MDictKeyBlockMeta struct {
	// KeyBlockNum key block number size
	KeyBlockNum int64
	// entriesNums entries number size
	EntriesNum int64
	// key-block information size (decompressed)
	KeyBlockInfoDecompressSize int64
	// key-block information size (compressed)
	KeyBlockInfoCompressedSize int64
	// key-block Data Size (decompressed)
	KeyBlockDataTotalSize int64
	// key-block information start position in the mdx/mdd file
	KeyBlockInfoStartOffset int64
}

type MDictMeta

type MDictMeta struct {
	EncryptType  int
	Version      float32
	NumberWidth  int
	NumberFormat int
	Encoding     int

	// key-block part bytes start offset in the mdx/mdd file
	KeyBlockMetaStartOffset int64
}

type MDictRecordBlockData

type MDictRecordBlockData struct {
	RecordItemList         []*MDictRecordDataItem
	RecordBlockStartOffset int64
	RecordBlockEndOffset   int64
}

type MDictRecordBlockInfo

type MDictRecordBlockInfo struct {
	RecordInfoList             []*MDictRecordBlockInfoListItem
	RecordBlockInfoStartOffset int64
	RecordBlockInfoEndOffset   int64
	RecordBlockDataStartOffset int64
}

type MDictRecordBlockInfoListItem

type MDictRecordBlockInfoListItem struct {
	CompressSize                int64
	DeCompressSize              int64
	CompressAccumulatorOffset   int64
	DeCompressAccumulatorOffset int64
}

type MDictRecordBlockMeta

type MDictRecordBlockMeta struct {
	KeyRecordMetaStartOffset int64
	KeyRecordMetaEndOffset   int64

	RecordBlockNum          int64
	EntriesNum              int64
	RecordBlockInfoCompSize int64
	RecordBlockCompSize     int64
}

type MDictRecordDataItem

type MDictRecordDataItem struct {
	KeyWord                          string
	RecordEntryIndex                 int64
	RecordInfoIndex                  int64
	RecordBlockIndex                 int64
	RecordBlockCompressStart         int64
	RecordBlockCompressEnd           int64
	RecordBlockCompressSize          int64
	RecordBlockDeCompressSize        int64
	RecordBlockCompressType          string
	RecordBlockEncrypted             bool
	RecordBlockFileRelativeOffset    int64
	RecordBlockCompressAccumulator   int64
	RecordBlockDeCompressAccumulator int64

	RecordEntryDecompressStart int64
	RecordEntryDecompressEnd   int64
}

type Mdict

type Mdict struct {
	*MdictBase
	// contains filtered or unexported fields
}

func New

func New(filename string) (*Mdict, error)

func (*Mdict) BuildBKTree

func (mdict *Mdict) BuildBKTree() error

func (*Mdict) Locate

func (mdict *Mdict) Locate(entry *MDictKeyBlockEntry) ([]byte, error)

func (*Mdict) Lookup

func (mdict *Mdict) Lookup(word string) ([]byte, error)

func (*Mdict) Search

func (mdict *Mdict) Search(word string) ([]*MDictKeyBlockEntry, error)

func (*Mdict) SimSearch

func (mdict *Mdict) SimSearch(word string, tolerance int) ([]*MDictKeyBlockEntry, error)

type MdictBase

type MdictBase struct {
	FilePath string
	FileType MdictType
	Meta     *MDictMeta

	Header       *MDictHeader
	KeyBlockMeta *MDictKeyBlockMeta
	KeyBlockInfo *MDictKeyBlockInfo
	KeyBlockData *MDictKeyBlockData

	RecordBlockMeta *MDictRecordBlockMeta
	RecordBlockInfo *MDictRecordBlockInfo
	RecordBlockData *MDictRecordBlockData
}

func (*MdictBase) LocateRecordDefinition

func (mdict *MdictBase) LocateRecordDefinition(item *MDictKeyBlockEntry) ([]byte, error)

func (*MdictBase) ReadDictHeader

func (mdict *MdictBase) ReadDictHeader() error

ReadDictHeader reads the dictionary header.

func (*MdictBase) ReadKeyBlockInfo

func (mdict *MdictBase) ReadKeyBlockInfo() error

func (*MdictBase) ReadKeyBlockMeta

func (mdict *MdictBase) ReadKeyBlockMeta() error

ReadKeyBlockMeta keyblock header part contains keyblock meta info

func (*MdictBase) ReadKeyEntries

func (mdict *MdictBase) ReadKeyEntries() error

func (*MdictBase) ReadRecordBlockData

func (mdict *MdictBase) ReadRecordBlockData() error

func (*MdictBase) ReadRecordBlockInfo

func (mdict *MdictBase) ReadRecordBlockInfo() error

func (*MdictBase) ReadRecordBlockMeta

func (mdict *MdictBase) ReadRecordBlockMeta() error

type MdictType

type MdictType int

Jump to

Keyboard shortcuts

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