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) SenseCount ¶
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 ¶
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.
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 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 Section ¶
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.