Use canonical names for the letters, and fix comparisons where one letter's name is a strict initial substring of another.

This commit is contained in:
Anna Rose 2021-04-06 04:17:49 +00:00
parent ffb9d1a09f
commit aef8baee0a

View File

@ -10,31 +10,31 @@ import (
)
var SPELLINGS = map[rune]string{
'A': "AY",
'A': "A",
'B': "BEE",
'C': "SEE",
'C': "CEE",
'D': "DEE",
'E': "EE",
'F': "EFF",
'E': "E",
'F': "EF",
'G': "GEE",
'H': "AITCH",
'I': "EYE",
'I': "I",
'J': "JAY",
'K': "KAY",
'L': "ELL",
'M': "EMM",
'N': "ENN",
'O': "OH",
'L': "EL",
'M': "EM",
'N': "EN",
'O': "O",
'P': "PEE",
'Q': "CUE",
'R': "ARR",
'R': "AR",
'S': "ESS",
'T': "TEE",
'U': "EWE",
'U': "U",
'V': "VEE",
'W': "DOUBLE EWE",
'X': "ECKS",
'Y': "WHY",
'W': "DOUBLE U",
'X': "EX",
'Y': "WYE",
'Z': "ZEE",
}
@ -114,7 +114,11 @@ func sortAlphabet(alphabet []rune) []rune {
j_index := -1
k := 0
for k = 0; k < len(i_spelling) && k < len(j_spelling); k++ {
for k = 0; ; k++ {
if k >= len(i_spelling) || k >= len(j_spelling) {
return len(i_spelling) < len(j_spelling)
}
i_index = findIndex(alphabet, rune(i_spelling[k]))
j_index = findIndex(alphabet, rune(j_spelling[k]))