entryir

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: GPL-3.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package entryir defines the dictionary-neutral intermediate representation that every parser produces and every output adapter consumes.

The IR deliberately models what dictionaries contain, not what Bob can display. Keeping the two apart means a richer Bob release only needs a new adapter, never a change to the MDX or parsing layers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	// ResourceRef is the raw reference as it appeared in the entry HTML,
	// e.g. "sound://synthetic/uk/example.mp3" in a test fixture.
	ResourceRef string `json:"resourceRef"`
	// Token is the opaque handle the resource endpoint accepts. It never
	// contains a filesystem path.
	Token string `json:"token"`
	// URL is the fully-qualified loopback URL Bob can play.
	URL string `json:"url"`
	// MIMEType is the type the resource endpoint will serve, after any
	// transcoding (SPX is served as WAV).
	MIMEType string `json:"mimeType"`
}

Audio is a playable pronunciation asset that exists inside a user's MDD. There is no synthesized speech anywhere in this project: if no MDD resource backs a pronunciation, Audio is simply absent.

type Entry

type Entry struct {
	Headword        string          `json:"headword"`
	Source          Source          `json:"source"`
	Pronunciations  []Pronunciation `json:"pronunciations,omitempty"`
	Parts           []Part          `json:"parts,omitempty"`
	Forms           []Form          `json:"forms,omitempty"`
	Phrases         []PhraseEntry   `json:"phrases,omitempty"`
	Idioms          []PhraseEntry   `json:"idioms,omitempty"`
	PhrasalVerbs    []PhraseEntry   `json:"phrasalVerbs,omitempty"`
	Derivatives     []PhraseEntry   `json:"derivatives,omitempty"`
	Collocations    []string        `json:"collocations,omitempty"`
	UsageNotes      []Section       `json:"usageNotes,omitempty"`
	GrammarNotes    []Section       `json:"grammarNotes,omitempty"`
	Synonyms        []string        `json:"synonyms,omitempty"`
	Antonyms        []string        `json:"antonyms,omitempty"`
	CrossReferences []string        `json:"crossReferences,omitempty"`
	Related         []string        `json:"related,omitempty"`
	WordFamily      []string        `json:"wordFamily,omitempty"`
	Etymology       string          `json:"etymology,omitempty"`
	Sections        []Section       `json:"sections,omitempty"`
	// Notes carries parser diagnostics. Populated only in debug mode.
	Notes []string `json:"notes,omitempty"`
}

Entry is the complete parsed dictionary entry.

func (*Entry) IsEmpty

func (e *Entry) IsEmpty() bool

IsEmpty reports whether the parse yielded nothing worth showing.

func (*Entry) SenseCount

func (e *Entry) SenseCount() int

SenseCount returns the total number of senses and subsenses across all parts. It is the cheapest signal of whether a parse produced anything useful.

type EntryRecord

type EntryRecord struct {
	RecordOrdinal int    `json:"recordOrdinal"`
	Entry         *Entry `json:"entry"`
}

EntryRecord preserves one independently parsed semantic record. Its ordinal is assigned only after safe dedupe and empty filtering, so visible records are always numbered consecutively in source order.

type EntrySet

type EntrySet struct {
	// LookupKey is the actual MDX key selected for the aggregate before
	// duplicate expansion. It is the stable, re-lookupable presentation alias;
	// redirects and parser-discovered titles do not rewrite it.
	LookupKey string `json:"lookupKey"`
	// Headword is the parser-discovered display headword of the first semantic
	// record. It is a content fact and need not equal LookupKey.
	Headword string        `json:"headword"`
	Records  []EntryRecord `json:"records"`
}

EntrySet is the dictionary-neutral aggregate produced for one selected key. Parser remains strictly one raw record -> one Entry; adapters decide how to present the preserved record boundaries.

func (*EntrySet) Primary

func (s *EntrySet) Primary() *Entry

Primary returns the first semantic record, if one exists.

type Example

type Example struct {
	Text        string `json:"text"`
	Translation string `json:"translation,omitempty"`
	Audio       *Audio `json:"audio,omitempty"`
}

Example is a usage example, optionally with a translation and its own audio.

type Form

type Form struct {
	Name  string   `json:"name"`
	Words []string `json:"words"`
	Audio *Audio   `json:"audio,omitempty"`
}

Form is an inflected form, e.g. plural or past participle.

type Image added in v1.1.0

type Image struct {
	ResourceRef string `json:"resourceRef"`
	Token       string `json:"token"`
	URL         string `json:"url"`
	MIMEType    string `json:"mimeType"`
	Alt         string `json:"alt,omitempty"`
}

Image is an illustration that exists inside the selected dictionary's MDD. Like Audio, it carries only an opaque loopback resource URL; dictionary and filesystem identity never cross the service boundary.

type Part

type Part struct {
	POS        string  `json:"pos"`
	Grammar    string  `json:"grammar,omitempty"`
	Senses     []Sense `json:"senses"`
	Confidence float64 `json:"confidence"`
	Rule       string  `json:"rule,omitempty"`
}

Part groups senses under one part of speech.

type PhraseEntry

type PhraseEntry struct {
	Phrase     string    `json:"phrase"`
	Definition string    `json:"definition,omitempty"`
	Examples   []Example `json:"examples,omitempty"`
}

PhraseEntry covers phrases, idioms, phrasal verbs and collocations, which all share the same shape: a lemma plus explanatory content.

type Pronunciation

type Pronunciation struct {
	IPARegion   Region  `json:"ipaRegion,omitempty"`
	IPA         string  `json:"ipa,omitempty"`
	AudioRegion Region  `json:"audioRegion,omitempty"`
	Audio       *Audio  `json:"audio,omitempty"`
	Label       string  `json:"label,omitempty"`
	Confidence  float64 `json:"confidence"`
	// Rule records which parser rule produced this node. Debug only.
	Rule string `json:"rule,omitempty"`
}

Pronunciation preserves transcription and recording provenance separately. A shared IPA can therefore coexist with distinct UK and US recordings, and an unlabelled recording never inherits the IPA's region by accident.

type Region

type Region string

Region identifies a pronunciation variety.

const (
	RegionUK Region = "uk"
	RegionUS Region = "us"
	// RegionNeutral means the dictionary presents a transcription as shared
	// across varieties rather than assigning it to one accent.
	RegionNeutral Region = "neutral"
	// RegionOther means the source did not provide enough evidence to classify
	// the variety. It must never be silently promoted to UK or US inside the IR.
	RegionOther Region = "other"
)

type RichBlock added in v1.1.0

type RichBlock struct {
	Kind  RichBlockKind `json:"kind"`
	Text  string        `json:"text,omitempty"`
	Image *Image        `json:"image,omitempty"`
	Rows  [][]string    `json:"rows,omitempty"`
	// Header is the table's own header row, present only when the source
	// marked one with <th> cells. Absent means the source declared no header,
	// which is a different fact from having an empty one.
	Header []string `json:"header,omitempty"`
}

RichBlock preserves ordered text, image, and conventional table content. Exactly one of Text, Image, or Rows/Header is populated according to Kind.

type RichBlockKind added in v1.1.0

type RichBlockKind string

RichBlockKind is the deliberately small vocabulary used inside free-form prose. Core dictionary semantics remain typed fields; these blocks only preserve presentation content whose order matters.

const (
	RichText     RichBlockKind = "text"
	RichHeading  RichBlockKind = "heading"
	RichListItem RichBlockKind = "listItem"
	RichImage    RichBlockKind = "image"
	RichTable    RichBlockKind = "table"
)

type Section

type Section struct {
	Title  string      `json:"title"`
	Body   string      `json:"body"`
	Blocks []RichBlock `json:"blocks,omitempty"`
}

Section is free-form extended content that did not fit a typed field. Anything the parser is not confident about lands here rather than being mis-filed as a definition.

type Sense

type Sense struct {
	Number      string    `json:"number,omitempty"`
	Definition  string    `json:"definition"`
	Translation string    `json:"translation,omitempty"`
	Labels      []string  `json:"labels,omitempty"`
	Grammar     string    `json:"grammar,omitempty"`
	Topic       string    `json:"topic,omitempty"`
	Patterns    []string  `json:"patterns,omitempty"`
	Examples    []Example `json:"examples,omitempty"`
	Subsenses   []Sense   `json:"subsenses,omitempty"`
	Synonyms    []string  `json:"synonyms,omitempty"`
	Antonyms    []string  `json:"antonyms,omitempty"`
	Confidence  float64   `json:"confidence"`
	Rule        string    `json:"rule,omitempty"`
}

Sense is one numbered meaning, possibly with nested subsenses.

type Source

type Source struct {
	DictionaryID    string `json:"dictionaryId"`
	DictionaryTitle string `json:"dictionaryTitle"`
	MatchedKey      string `json:"matchedKey"`
	// RedirectedFrom is set when @@@LINK or entry:// redirection was followed.
	RedirectedFrom string `json:"redirectedFrom,omitempty"`
	// Profile names the parser profile that handled this entry, or "generic".
	Profile string `json:"profile"`
	// RawRecordOrdinal is the one-based position among the exact MDX records
	// for MatchedKey, before resolved-content dedupe and empty filtering.
	RawRecordOrdinal int `json:"rawRecordOrdinal,omitempty"`
	// RecordStartOffset is a stable low-level locator for local diagnostics.
	RecordStartOffset int64 `json:"recordStartOffset,omitempty"`
}

Source records where an entry came from.

Jump to

Keyboard shortcuts

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