Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (21 sloc) 508 Bytes
package tokipona
import (
"strings"
"unicode"
)
// Relex does a very literal translation of Toki Pona to English. See http://tokipona.net/tp/Relex.aspx for the idea.
func Relex(inp string) string {
f := func(c rune) bool {
return !unicode.IsLetter(c)
}
words := strings.FieldsFunc(inp, f)
result := []string{}
for _, word := range words {
if en, ok := relexMap[word]; ok {
result = append(result, en)
} else {
result = append(result, word)
}
}
return strings.Join(result, " ")
}
You can’t perform that action at this time.