dict

package
v0.0.0-...-cf3773c Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package dict implements reading .dict files.

Index

Constants

View Source
const (
	// UTFTextType is utf-8 text.
	UTFTextType = DataType('m')

	// LocaleTextType is text in a locale encoding.
	LocaleTextType = DataType('l')

	// PangoTextType is utf-8 text in the Pango text format.
	PangoTextType = DataType('g')

	// PhoneticType is utf-8 text representing an English phonetic string.
	PhoneticType = DataType('t')

	// XDXFType is utf-8 encoded xml in XDXF format.
	XDXFType = DataType('x')

	// YinBiaoOrKataType is utf-8 encoded Yin Biao or Kana phonetic string.
	YinBiaoOrKataType = DataType('y')

	// PowerWordType is a utf-8 encoded KingSoft PowerWord XML format.
	PowerWordType = DataType('p')

	// MediaWikiType is utf-8 encoded text in MediaWiki format.
	MediaWikiType = DataType('w')

	// HTMLType is utf-8 encoded HTML text.
	HTMLType = DataType('h')

	// WordNetType is WordNet data.
	WordNetType = DataType('n')

	// ResourceFileListType is a list of files in resource storage.
	ResourceFileListType = DataType('r')

	// WavType is .wav sound file data.
	WavType = DataType('W')

	// PictureType is image file data. This was used by the
	// stardict-advertisement-plugin. Images are better stored in a resource
	// file list.
	PictureType = DataType('P')

	// ExperimentalType is reserved for experimental features.
	ExperimentalType = DataType('X')
)

Variables

This section is empty.

Functions

func MakeDict

func MakeDict(words []*Word, sametypesequence []DataType) []byte

MakeDict creates a test .dict file.

Types

type Data

type Data struct {
	Type DataType
	Data []byte
}

Data is a data entry in a Word.

type DataType

type DataType byte

DataType is a type of data in a word. Data types are specified by a single byte at the beginning of a word. Lower case characters represent string-like data that is terminated by a null terminator ('\0'). Upper case characters represent file-like data that starts with a 32-bit size followed by file data.

type Dict

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

Dict represents a Stardict dictionary's dictionary data.

func New

func New(r io.ReaderAt, sametypesequence []DataType) (*Dict, error)

New returns a new Dict from the given reader. Dict takes ownership of the reader. The reader can be closed via the Dict's Close method.

func (*Dict) Word

func (d *Dict) Word(e *idx.Word) (*Word, error)

Word retrieves the word for the given index entry from the dictionary.

type Word

type Word struct {
	Data []*Data
}

Word is a full dictionary entry.

Jump to

Keyboard shortcuts

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