Documentation
¶
Overview ¶
Package gomanize transliterates Devanagari (Hindi) text into readable Latin script, using a rule-based engine with optional embedded learned components (a schwa classifier, an attested-spelling lexicon, and a character-LM re-ranker). It targets colloquial, diacritic-free romanization of the kind used for song lyrics.
Basic use:
g, err := gomanize.New("hindi")
out := g.Translit("नमस्ते दुनिया") // "namaste duniya"
A Gomanize instance is safe for concurrent Translit calls. TranslitDebug and runtime rule toggling (DisableRule/EnableRule) mutate engine state and must not run concurrently with other calls on the same instance. TranslitDebug returns nil debug info when the Lexicon or Rerank options short-circuit the rule pipeline.
Index ¶
- Variables
- type DebugInfo
- type EngineOption
- type ExtendedRomanizer
- type Gomanize
- func (g *Gomanize) DisableRule(pattern string) int
- func (g *Gomanize) EnableRule(pattern string) int
- func (g *Gomanize) GetOptions() Options
- func (g *Gomanize) ListRules(pattern string) []RuleStatus
- func (g *Gomanize) SetOptions(opts Options)
- func (g Gomanize) Test()
- func (g Gomanize) Translit(sentence string) string
- func (g Gomanize) TranslitDebug(word string) (string, *DebugInfo)
- type Options
- type Romanizer
- type RuleStatus
Constants ¶
This section is empty.
Variables ¶
var WithDisabledRules = core.WithDisabledRules
WithDisabledRules returns an option that disables rules matching the given patterns. Patterns can be exact names or glob patterns (e.g., "schwa.*", "vowel.long-aa.*").
var WithEnabledRules = core.WithEnabledRules
WithEnabledRules returns an option that enables rules matching the given patterns. Useful for enabling rules that are disabled by default.
Functions ¶
This section is empty.
Types ¶
type EngineOption ¶ added in v1.0.0
type EngineOption = core.EngineOption
EngineOption configures engine creation.
type ExtendedRomanizer ¶ added in v1.0.0
type ExtendedRomanizer interface {
Romanizer
// ListRules returns all rules with their enabled/disabled status.
// If pattern is empty, returns all rules.
ListRules(pattern string) []RuleStatus
// DisableRule disables rules matching the given pattern.
DisableRule(pattern string) int
// EnableRule enables rules matching the given pattern.
EnableRule(pattern string) int
}
ExtendedRomanizer extends Romanizer with rule management capabilities.
type Gomanize ¶
type Gomanize struct {
// contains filtered or unexported fields
}
func NewWithOptions ¶ added in v1.0.0
func NewWithOptions(language string, opts Options, engineOpts ...EngineOption) (*Gomanize, error)
NewWithOptions creates a Gomanize instance with custom options.
func (*Gomanize) DisableRule ¶ added in v1.0.0
DisableRule disables rules matching the given pattern. Returns the number of rules disabled, or 0 if not supported.
func (*Gomanize) EnableRule ¶ added in v1.0.0
EnableRule enables rules matching the given pattern. Returns the number of rules enabled, or 0 if not supported.
func (*Gomanize) GetOptions ¶ added in v1.0.0
GetOptions returns the current options.
func (*Gomanize) ListRules ¶ added in v1.0.0
func (g *Gomanize) ListRules(pattern string) []RuleStatus
ListRules returns all rules with their enabled/disabled status. If pattern is empty, returns all rules. Supports glob patterns (e.g., "schwa.*"). Returns nil if the romanizer doesn't support rule listing.
func (*Gomanize) SetOptions ¶ added in v1.0.0
SetOptions updates the options for this instance.
func (Gomanize) Translit ¶
Translit transliterates text using the configured options. Words are segmented on ALL whitespace (spaces, tabs, newlines) AND punctuation — both preserved verbatim — so multi-line input romanizes line by line and attached punctuation (danda: "जीत।") no longer defeats word-final rules. Devanagari combining marks (matras, halant, nukta) are marks, not punctuation, so words are never split internally.
type Options ¶ added in v1.0.0
Options configures transliteration behavior. Use NewOptions() to get defaults, then modify as needed.
func NewOptions ¶ added in v1.0.0
func NewOptions() Options
NewOptions returns Options with default values.
type RuleStatus ¶ added in v1.0.0
type RuleStatus = core.RuleStatus
RuleStatus represents a rule and its current enabled/disabled state.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gomanize
command
|
|
|
gomanize-wasm
command
Command gomanize-wasm is the WebAssembly entry point for the browser demo in web/.
|
Command gomanize-wasm is the WebAssembly entry point for the browser demo in web/. |
|
Package core provides universal types and mechanics for transliteration.
|
Package core provides universal types and mechanics for transliteration. |
|
lang
|
|
|
hindi
Package hindi provides Hindi-specific symbol mappings and rules using the core architecture.
|
Package hindi provides Hindi-specific symbol mappings and rules using the core architecture. |
|
scheme
|
|
|
colloquial
Package colloquial provides a colloquial romanization scheme.
|
Package colloquial provides a colloquial romanization scheme. |
|
script
|
|
|
brahmic
Package brahmic provides a romanization engine for Brahmic script family.
|
Package brahmic provides a romanization engine for Brahmic script family. |
|
tools
|
|
|
regression
command
Command regression is the before/after transition-matrix diff for gomanize engine changes (F-0010 / T-0043, per the Codex design review in docs/reviews/2026-09-08-structured-parser-qa.md).
|
Command regression is the before/after transition-matrix diff for gomanize engine changes (F-0010 / T-0043, per the Codex design review in docs/reviews/2026-09-08-structured-parser-qa.md). |
|
Package webdemo holds the host-testable pieces shared by the WebAssembly build of gomanize (cmd/gomanize-wasm).
|
Package webdemo holds the host-testable pieces shared by the WebAssembly build of gomanize (cmd/gomanize-wasm). |