summaryrefslogtreecommitdiff
path: root/hoelai.go
diff options
context:
space:
mode:
authoruakci <uakci@uakci.pl>2021-09-15 01:19:55 +0200
committeruakci <uakci@uakci.pl>2021-09-15 01:19:55 +0200
commit20ef8a090c2bc552e8f1e5dd773cd086c9782a21 (patch)
tree89b7efba3f301c11eaba53ce13bcca87a9648240 /hoelai.go
downloadnuogai-20ef8a090c2bc552e8f1e5dd773cd086c9782a21.tar.gz
nuogai-20ef8a090c2bc552e8f1e5dd773cd086c9782a21.zip
initial
Diffstat (limited to 'hoelai.go')
-rw-r--r--hoelai.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/hoelai.go b/hoelai.go
new file mode 100644
index 0000000..bf0e7eb
--- /dev/null
+++ b/hoelai.go
@@ -0,0 +1,56 @@
+package main
+
+import (
+ "fmt"
+ "git.uakci.pl/toaq/nuogai/vietoaq"
+ "strings"
+)
+
+func Hoelai(s string) string {
+ viet := vietoaq.To(s)
+ parts := vietoaq.Syllables(viet, vietoaq.VietoaqSyllable)
+ var sb strings.Builder
+ for i, part := range parts {
+ if i%2 == 0 {
+ sb.WriteString(part[0])
+ continue
+ }
+ onset, nucleus, coda := part[1], part[2], part[3]
+ switch onset {
+ case "ch":
+ onset = "w"
+ case "sh":
+ onset = "x"
+ case "x":
+ onset = "q"
+ }
+ diph := ""
+ if len(nucleus) >= 2 {
+ flag := true
+ switch nucleus[len(nucleus)-2:] {
+ case "ai":
+ diph = "y"
+ case "ao":
+ diph = "v"
+ case "oi":
+ diph = "z"
+ case "ei":
+ diph = "W"
+ default:
+ flag = false
+ }
+ if flag {
+ nucleus = nucleus[:len(nucleus)-2]
+ }
+ }
+ if len(nucleus) >= 2 {
+ diph = strings.ToUpper(nucleus[1:])
+ nucleus = nucleus[:1]
+ } else if nucleus == "a" && diph == "" {
+ nucleus = ""
+ }
+ fmt.Fprintf(&sb, "%s%s%s%s",
+ diph, onset, strings.ToUpper(coda), nucleus)
+ }
+ return sb.String()
+}