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 ¶
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.