Documentation
¶
Overview ¶
Package stardict implements a library for reading stardict dictionaries in pure Go.
Stardict dictionaries contain several files:
- An .ifo file that contains metadata about the dictionary.
- An .idx file that contains the dictionary index. It contains search entries and associated offsets into the .dict file. The index file can be compressed using gzip.
- A .dict file that contains the dictionary's main article data. The dict file can be compressed using the dictzip format.
- An optional .syn file that contains synonyms which link index entries.
- A .tdx file is present for "tree dictionaries" and is used instead of the .idx file.
More info on on the dictionary format can be found at this URL: https://github.com/huzheng001/stardict-3/blob/master/dict/doc/StarDictFileFormat
Index ¶
- type DataList
- type Entry
- type Options
- type Stardict
- func (s *Stardict) Author() string
- func (s *Stardict) Bookname() string
- func (s *Stardict) Close() error
- func (s *Stardict) Description() string
- func (s *Stardict) Dict() (*dict.Dict, error)
- func (s *Stardict) Email() string
- func (s *Stardict) Index() (*idx.Idx, error)
- func (s *Stardict) IndexScanner() (*idx.Scanner, error)
- func (s *Stardict) Search(query string) ([]*Entry, error)
- func (s *Stardict) Syn() (*syn.Syn, error)
- func (s *Stardict) SynWordCount() int64
- func (s *Stardict) Version() string
- func (s *Stardict) Website() string
- func (s *Stardict) WordCount() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a dictionary entry.
type Options ¶ added in v0.2.0
type Options struct { // Folder returns a [transform.Transformer] that performs folding (e.g. // case folding, whitespace folding, etc.) on dictionary entries. Folder func() transform.Transformer }
Options are options for the Stardict dictionary.
type Stardict ¶
type Stardict struct {
// contains filtered or unexported fields
}
Stardict is a stardict dictionary.
func OpenAll ¶
OpenAll opens all dictionaries under a directory. This function will return all successfully opened dictionaries along with any errors that occurred.
func (*Stardict) Author ¶
Author returns the dictionary author. This field is optional for dictionaries.
func (*Stardict) Description ¶
Description returns the dictionary description. This field is optional for dictionaries. <br> has been replaced with '\n'.
func (*Stardict) IndexScanner ¶
IndexScanner returns a new index scanner. The caller assumes ownership of the underlying reader so Close should be called on the scanner when finished.
func (*Stardict) Search ¶
Search performs a simple full text search of the dictionary for the given query and returns dictionary entries. The query supports glob patterns whose pattern syntax is:
pattern: { term } term: `*` matches any sequence of non-separator characters `**` matches any sequence of characters `?` matches any single non-separator character `[` [ `!` ] { character-range } `]` character class (must be non-empty) `{` pattern-list `}` pattern alternatives c matches character c (c != `*`, `**`, `?`, `\`, `[`, `{`, `}`) `\` c matches character c character-range: c matches character c (c != `\\`, `-`, `]`) `\` c matches character c lo `-` hi matches character c for lo <= c <= hi pattern-list: pattern { `,` pattern } comma-separated (without spaces) patterns
The pattern is folded using the given folding transformer and matches the folded word in the index.
func (*Stardict) Syn ¶ added in v0.2.0
Syn returns a simple in-memory version of the dictionary's synonym index.
func (*Stardict) SynWordCount ¶ added in v0.2.0
SynWordCount returns the wordcount in the synonym index.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
Package dict implements reading .dict files.
|
Package dict implements reading .dict files. |
Package idx implements reading .idx files.
|
Package idx implements reading .idx files. |
Package ifo implements reading .ifo files.
|
Package ifo implements reading .ifo files. |
internal
|
|