stardict

package
v0.0.0-...-445cf5a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: AGPL-3.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	I_bookname    = "bookname"
	I_wordcount   = "wordcount"
	I_description = "description"
	I_idxfilesize = "idxfilesize"

	I_sametypesequence = "sametypesequence"
	I_idxoffsetbits    = "idxoffsetbits"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleItem

type ArticleItem struct {
	Data []byte
	Type rune
}

type Dict

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

Dict implements in-memory dictionary

func ReadDict

func ReadDict(filename string, info *Info) (*Dict, error)

ReadDict creates Dict and opens .dict file

func (*Dict) Close

func (d *Dict) Close()

func (*Dict) GetSequence

func (d *Dict) GetSequence(offset uint64, size uint64) []byte

GetSequence returns data at the given offset

func (*Dict) Open

func (d *Dict) Open() error

type DictFile

type DictFile interface {
	ReadAt(p []byte, off int64) (n int, err error)
	Close() error
}

type Info

type Info struct {
	Options map[string]string
	Version string
	Is64    bool
}

Info contains dictionary options

func ReadInfo

func ReadInfo(filename string) (info *Info, err error)

ReadInfo reads ifo file and collects dictionary options

func (Info) Description

func (info Info) Description() string

func (Info) DictName

func (info Info) DictName() string

func (Info) EntryCount

func (info Info) EntryCount() (int, error)

EntryCount returns number of words in the dictionary

func (Info) IndexFileSize

func (info Info) IndexFileSize() uint64

func (Info) MaxIdxBytes

func (info Info) MaxIdxBytes() int

type StarDictReader

type StarDictReader struct {
	*Info
	// contains filtered or unexported fields
}

dictionaryImp stardict dictionary

func NewReader

func NewReader(path string, name string) (*StarDictReader, error)

NewReader returns a new Dictionary path - path to dictionary files name - name of dictionary to parse

func (*StarDictReader) Close

func (d *StarDictReader) Close()

func (*StarDictReader) DictName

func (d *StarDictReader) DictName() string

DictName returns book name

func (*StarDictReader) IndexPath

func (d *StarDictReader) IndexPath() string

func (*StarDictReader) InfoPath

func (d *StarDictReader) InfoPath() string

func (*StarDictReader) Loaded

func (d *StarDictReader) Loaded() bool

func (*StarDictReader) Read

func (r *StarDictReader) Read() (func() ([]string, []*ArticleItem), error)

Directories

Path Synopsis
Package dictzip provides a reader for files in the random access `dictzip` format.
Package dictzip provides a reader for files in the random access `dictzip` format.

Jump to

Keyboard shortcuts

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