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