edgedict

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 15 Imported by: 1

README

edgedict

Go library to parse dictionaries from Microsoft Edge's Immersive Reader.

Documentation

Overview

Package edgedict interacts with MS Edge dictionaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

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

Dictionary provides read access to the contents of a MS Edge dictionary.

func New

func New(r io.ReaderAt) (*Dictionary, error)

New opens a MS Edge dictionary from a ReaderAt supporting seeking.

func Open

func Open(name string) (*Dictionary, error)

Open opens a MS Edge dictionary from a path.

func (*Dictionary) Close

func (d *Dictionary) Close() error

Close cleans up any open resources.

func (*Dictionary) Entries

func (d *Dictionary) Entries() ([]Ref, error)

Entries gets references to all unique definitions from the dictionary.

func (*Dictionary) Get

func (d *Dictionary) Get(r Ref) ([]byte, error)

Get gets the raw entry referenced by r.

func (*Dictionary) Lookup

func (d *Dictionary) Lookup(word string) ([]Entry, error)

Lookup finds a word in the dictionary and returns the definition(s). If the word does not exist, a nil slice will be returned.

func (*Dictionary) LookupRef

func (d *Dictionary) LookupRef(word string) ([]Ref, error)

LookupRef finds an entry in the dictionary. If the word does not exist, a nil err and slice will be returned.

func (*Dictionary) Walk

func (d *Dictionary) Walk(fn func(ref Ref, buf []byte) error) error

Walk efficiently iterates over all unique definitions from the dictionary, breaking if fn returns a non-nil error.

func (*Dictionary) WalkRefs added in v0.0.3

func (d *Dictionary) WalkRefs(fn func(term string, ref Ref) error) error

WalkRefs efficiently iterates over all word references from the dictionary, breaking if fn returns a non-nil error.

func (*Dictionary) Words

func (d *Dictionary) Words() ([]string, error)

Words gets all words from the dictionary.

type Entry

type Entry struct {
	Name                   string             `json:"name"`
	PhoneticName           string             `json:"phoneticName"`
	Pronunciation          string             `json:"pronunciation"`
	PronunciationAudio     PronunciationAudio `json:"pronunciationAudio"`
	MeaningGroups          []MeaningGroup     `json:"meaningGroups"`
	WordOrigin             string             `json:"wordOrigin"`
	AggregatePartsOfSpeech Item               `json:"aggregatePartsOfSpeech"`
}

type Item

type Item struct {
	Name string `json:"name"`
}

type Meaning

type Meaning struct {
	RichDefinitions []RichDefinition `json:"richDefinitions"`
}

type MeaningGroup

type MeaningGroup struct {
	Meanings      []Meaning  `json:"meanings"`
	WordForms     []WordForm `json:"wordForms"`
	PartsOfSpeech []Item     `json:"partsOfSpeech"`
}

type PronunciationAudio

type PronunciationAudio struct {
	ContentURL string `json:"contentUrl"`
}

type Ref

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

Ref points to a definition.

func (Ref) String

func (r Ref) String() string

type RichDefinition

type RichDefinition struct {
	Fragments      []RichDefinitionFragment `json:"fragments"`
	Domains        []string                 `json:"domains"`
	Synonyms       []Item                   `json:"synonyms"`
	Examples       []string                 `json:"examples"`
	LabelTags      []string                 `json:"labelTags"`
	Antonyms       []Item                   `json:"antonyms"`
	SubDefinitions []RichDefinition         `json:"subDefinitions"`
}

type RichDefinitionFragment

type RichDefinitionFragment struct {
	Type        string  `json:"_type"`
	Text        string  `json:"text"`
	URL         *string `json:"url"`
	Format      *string `json:"format"`
	Numerator   *string `json:"numerator"`
	Denominator *string `json:"denominator"`
}

type WordForm

type WordForm struct {
	Form string `json:"form"`
	Word Item   `json:"word"`
}

Directories

Path Synopsis
cmd
edgedict-fetch
Command edgedict-fetch downloads and extracts MS Edge dictionaries.
Command edgedict-fetch downloads and extracts MS Edge dictionaries.

Jump to

Keyboard shortcuts

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