stardict

package
v0.0.0-...-b5b89ff Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

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

Dict implements in-memory dictionary

func ReadDict

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

ReadDict reads dictionary into memory

func (Dict) GetSequence

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

GetSequence returns data at the given offset

type Dictionary

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

Dictionary stardict dictionary

func NewDictionary

func NewDictionary(path string, name string) (*Dictionary, error)

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

func (Dictionary) GetBookName

func (d Dictionary) GetBookName() string

GetBookName returns book name

func (Dictionary) GetWordCount

func (d Dictionary) GetWordCount() uint64

GetWordCount returns number of words in the dictionary

func (Dictionary) Translate

func (d Dictionary) Translate(item string) (items []*Translation)

Translate translates given item

type Idx

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

Idx implements an in-memory index for a dictionary

func NewIdx

func NewIdx() *Idx

NewIdx initializes idx struct

func ReadIndex

func ReadIndex(filename string, info *Info) (idx *Idx, err error)

ReadIndex reads dictionary index into a memory and returns in-memory index structure

func (*Idx) Add

func (idx *Idx) Add(item string, offset uint64, size uint64)

Add adds an item to in-memory index

func (Idx) Get

func (idx Idx) Get(item string) []*Sense

Get gets all translations for an item

type Info

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

Info contains dictionary options

func ReadInfo

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

ReadInfo reads ifo file and collects dictionary options

type Sense

type Sense struct {
	Offset uint64
	Size   uint64
}

Sense has information belonging to single item position in dictionary

type Translation

type Translation struct {
	Parts []*TranslationItem
}

Translation contains translation items

type TranslationItem

type TranslationItem struct {
	Type rune
	Data []byte
}

TranslationItem contain single translation item

Jump to

Keyboard shortcuts

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