glossary

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package glossary auto-extracts korean → english keyword mappings from markdown documents (typically a project's .claude/docs/ tree) and emits the AliasMap YAML that `ckv query --alias` consumes.

Pattern coverage (v1):

  1. Markdown table rows with a korean key cell and an english value cell: `| 합의 알고리즘 | WBFT (Weemix Byzantine Fault Tolerance) |` extracts `합의 알고리즘 → [WBFT, Weemix Byzantine Fault Tolerance]`.

  2. Inline parenthetical glosses: `합의 알고리즘 (consensus engine)` or `검증인 (validator)`. Body-text pattern, picks up terminology that never makes it into a table.

Both patterns require the *key* to contain at least one Hangul syllable so we never alias an english phrase to itself. Values are deduplicated and sorted before being written to YAML.

Non-goals for v1: section headings, bold-bold rewriting, semantic translation. Add only when a measurement shows the existing extractor misses a class of useful entries.

Output format matches internal/query.AliasFile so the produced YAML is directly consumable by `ckv query --alias`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(root string) (map[string][]string, error)

Extract walks every *.md / *.markdown file under root and returns the union AliasMap of all extracted patterns. Files are read with streaming line scanning so the function handles repo-sized doc trees without loading everything into memory.

Returns an empty (non-nil) map when no aliases are found — callers can write it out unconditionally.

func ExtractLine

func ExtractLine(line string, accum map[string]map[string]struct{})

ExtractLine applies the v1 patterns to one line and merges into accum. Exposed so callers (tests, future stream sources) can drive extraction without a file system.

func WriteYAML

func WriteYAML(w io.Writer, aliases map[string][]string) error

WriteYAML serializes the extracted AliasMap to w. Keys + values are sorted so reruns produce byte-identical output (good for diffs and for "ckv query --alias" fingerprint stability).

Types

type AliasFile

type AliasFile struct {
	Aliases map[string][]string `yaml:"aliases"`
}

AliasFile mirrors internal/query.AliasFile so we can emit YAML without depending on the query package (avoiding an import cycle if glossary ever moves under internal/query).

Jump to

Keyboard shortcuts

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