Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultNormalizer = NewDefaultNormalizer()
DefaultNormalizer is a statically allocated default normalizer for strings.
Functions ¶
func NormalizeForMatching ¶ added in v1.10.0
NormalizeForMatching applies full normalization for cross-seed matching:
- Unicode normalization (removes diacritics, decomposes ligatures)
- Lowercase
- Strip apostrophes (including Unicode variants)
- Strip colons
- Convert ampersand to "and"
- Convert hyphens to spaces
- Collapse multiple spaces to single space
Examples:
- "Shōgun S01" → "shogun s01"
- "Bob's Burgers" → "bobs burgers"
- "CSI: Miami" → "csi miami"
- "Spider-Man" → "spider man"
- "His & Hers" → "his and hers"
func NormalizeUnicode ¶ added in v1.10.0
NormalizeUnicode removes diacritics and decomposes ligatures. Examples:
- "Shōgun" → "Shogun"
- "Amélie" → "Amelie"
- "naïve" → "naive"
- "Björk" → "Bjork"
- "æ" → "ae"
- "fi" → "fi"
Types ¶
type Normalizer ¶
type Normalizer[K comparable, V any] struct { // contains filtered or unexported fields }
Normalizer caches transformed results so we do not repeatedly transform the same inputs.
func NewDefaultNormalizer ¶
func NewDefaultNormalizer() *Normalizer[string, string]
NewDefaultNormalizer returns a normalizer using the default TTL and default transform (ToLower + TrimSpace).
func NewNormalizer ¶
func NewNormalizer[K comparable, V any](ttl time.Duration, transform TransformFunc[K, V]) *Normalizer[K, V]
NewNormalizer returns a normalizer with the provided TTL and transform function for cached entries.
func (*Normalizer[K, V]) Clear ¶
func (n *Normalizer[K, V]) Clear(key K)
Clear removes a cached entry.
func (*Normalizer[K, V]) Normalize ¶
func (n *Normalizer[K, V]) Normalize(key K) V
Normalize returns the transformed value.
type TransformFunc ¶
type TransformFunc[K, V any] func(K) V
TransformFunc is a function that transforms K to V.
Click to show internal directories.
Click to hide internal directories.