chore: initial public commit

This commit is contained in:
Gabe Farrell 2025-06-11 19:45:39 -04:00
commit fc9054b78c
250 changed files with 32809 additions and 0 deletions

27
romanizer/romanizer.go Normal file
View file

@ -0,0 +1,27 @@
// unused
package romanizer
import (
"regexp"
"strings"
"github.com/gosimple/unidecode"
)
// regex to match only Latin letters, numbers, basic punctuation and spaces
var latinCharset = regexp.MustCompile(`^[\p{Latin}\p{P}\p{N}\p{Zs}]+$`)
// Romanize returns a romanized version of the input string if it contains non-Latin characters.
// If the input is already in Latin script, it returns an empty string.
func Romanize(input string) string {
trimmed := strings.TrimSpace(input)
if trimmed == "" {
return ""
}
if latinCharset.MatchString(trimmed) {
return ""
}
return strings.TrimSpace(unidecode.Unidecode(trimmed))
}