bobadapter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 4 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 bobadapter renders the dictionary-neutral Entry IR into Bob's documented toDict structure. Bob-specific compatibility decisions stay here and never rewrite dictionary facts in the IR.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactPOS added in v1.1.0

func CompactPOS(pos string) string

CompactPOS applies Bob-only abbreviations. Unknown non-empty labels are preserved verbatim: an unfamiliar publisher category must never disappear.

func ShouldUsePlainFallback added in v1.1.0

func ShouldUsePlainFallback(set *entryir.EntrySet, opts Options) bool

ShouldUsePlainFallback reports whether the selected Bob presentation would be an empty shell around untyped free-form Entry/headword sections. The test is intentionally conservative: long or dense structured entries remain Bob cards, and a single structured record keeps combined mode in Bob as well.

Types

type Addition

type Addition struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Dict

type Dict struct {
	Word             string            `json:"word"`
	Phonetics        []Phonetic        `json:"phonetics,omitempty"`
	Parts            []Part            `json:"parts,omitempty"`
	Exchanges        []Exchange        `json:"exchanges,omitempty"`
	RelatedWordParts []RelatedWordPart `json:"relatedWordParts,omitempty"`
	Additions        []Addition        `json:"additions,omitempty"`
}

func Render

func Render(entry *entryir.Entry, opts Options) *Dict

Render is the single-record convenience renderer. RenderEntrySet owns the presentation implementation so single- and multi-record paths cannot drift.

func RenderEntrySet

func RenderEntrySet(set *entryir.EntrySet, opts Options) *Dict

RenderEntrySet presents one cached semantic EntrySet. Combined mode renders every record with ordinal labels. Separate mode (and any explicit ordinal) renders one ordinary record plus native related-word sibling navigation.

type Exchange

type Exchange struct {
	Name  string   `json:"name"`
	Words []string `json:"words"`
}

type MultiRecordMode

type MultiRecordMode string

MultiRecordMode controls only Bob presentation. The service cache always keeps the complete EntrySet, regardless of this value.

const (
	MultiRecordSeparate MultiRecordMode = "separate"
	MultiRecordCombined MultiRecordMode = "combined"
)

type Options

type Options struct {
	IncludeExamples     bool
	IncludeExtras       bool
	MaxExamplesPerSense int
	MultiRecordMode     MultiRecordMode
	RecordOrdinal       int
	IncludeGrammar      bool
}

func DefaultOptions

func DefaultOptions() Options

type Part

type Part struct {
	Part  string   `json:"part"`
	Means []string `json:"means"`
}

type Phonetic

type Phonetic struct {
	// Bob documents only "uk" and "us" carrier slots.
	Type  string `json:"type"`
	Value string `json:"value,omitempty"`
	TTS   *TTS   `json:"tts,omitempty"`
}

type RelatedWord

type RelatedWord struct {
	Word  string   `json:"word"`
	Means []string `json:"means,omitempty"`
}

type RelatedWordPart

type RelatedWordPart struct {
	Part  string        `json:"part,omitempty"`
	Words []RelatedWord `json:"words"`
}

RelatedWordPart and RelatedWord mirror Bob's documented related-word presentation schema. Means is optional, so cross-references can be expressed without inventing definitions that are not present in the dictionary.

type TTS

type TTS struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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