categoryvocab

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(t string) string

Normalize converts a token to canonical lowercase-hyphenated form. "Canadian Politics" → "canadian-politics", "go-language" → "go-language". This is applied to every token regardless of whether a Vocab is loaded.

Types

type Vocab

type Vocab struct {
	// Aliases maps a non-canonical form to its canonical replacement.
	// Keys and values should be lowercase-hyphenated; Title Case forms are
	// normalised automatically before lookup.
	Aliases map[string]string `yaml:"aliases"`

	// Drop lists tokens to silently remove after alias resolution.
	Drop []string `yaml:"drop"`
	// contains filtered or unexported fields
}

Vocab holds the canonical tag/category vocabulary loaded from categories.yaml.

func Load

func Load(path string) (Vocab, error)

Load reads and parses a categories.yaml file. Returns an empty Vocab if the file does not exist, so callers can treat "no file" as "no rules".

func Parse added in v0.2.4

func Parse(data []byte) (Vocab, error)

Parse parses categories.yaml bytes and initialises lookup maps.

func (Vocab) ApplyToCSV

func (v Vocab) ApplyToCSV(raw string) (string, bool)

ApplyToCSV applies normalisation and rules to a comma-separated user_tags string and returns the result plus whether anything changed.

func (Vocab) ApplyToTokens

func (v Vocab) ApplyToTokens(tokens []string) []string

ApplyToTokens normalises every token to lowercase-hyphenated form, applies alias resolution and drop rules, and collapses duplicates. It always normalises — even when no Vocab rules are loaded.

func (Vocab) Empty

func (v Vocab) Empty() bool

Empty returns true when no rules are defined.

func (Vocab) PromptSection

func (v Vocab) PromptSection() string

PromptSection renders a concise vocabulary block for the LLM system prompt.

Jump to

Keyboard shortcuts

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