lang

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package lang detects the dominant human language of prose, for Ken's curation-language guardrail (a curator can only promote what they can read).

It wraps whatlanggo behind a tiny interface so the detector is swappable and unit-testable, and so callers depend on the interface rather than the library. Results are lowercased BCP-47 PRIMARY subtags ("en", "es", "fr", "zh") or Und when the text is too short or the guess is not reliable. Detection is open-set (it can recognize a language that is NOT one the curator reads), which is what a membership/flagging test actually needs — a biased classifier over a small known set could not tell "foreign" from "one of mine".

Index

Constants

View Source
const Und = "und"

Und is the "undetermined" language tag: too short, no letters, or a low-confidence guess. The guardrail treats Und (and a NULL content_lang) as never-flagged and always-promotable — detection failures fail OPEN for availability, never trapping a proposal the curator could actually read.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	// Detect returns a lowercased BCP-47 primary subtag, or [Und] when it can't
	// decide. It must be a pure function of text (no I/O, no state) so writes stay
	// cheap and deterministic.
	Detect(text string) string
}

Detector identifies the dominant language of prose text.

func New

func New() Detector

New returns the default whatlanggo-backed detector.

Jump to

Keyboard shortcuts

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