File tree 2 files changed +6
-12
lines changed
2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ func deduplicateAndLowerToBytes(str string) []byte {
86
86
seen := map [byte ]bool {}
87
87
bytes := []byte {}
88
88
characters := strings .ToLower (str )
89
- for i := 0 ; i < len ( characters ); i ++ {
89
+ for i := range characters {
90
90
value := characters [i ]
91
91
if ! seen [value ] {
92
92
bytes = append (bytes , value )
Original file line number Diff line number Diff line change @@ -89,10 +89,9 @@ func (p *Pronounceable) WordScore(word string) float64 {
89
89
}
90
90
91
91
score := 0.0
92
- for i := 0 ; i < len (word ); i += 1 {
93
- // If a character does not exist in unigram, it is unclassifiable and
94
- // any statement about pronounceability
95
- // cannot say anything about its pronounceability anymore. Just bail.
92
+ for i := 0 ; i < len (word ); i ++ {
93
+ // If it contains a character outside of the allowed character set we cannot say anything
94
+ // about its pronounceableness
96
95
if p .unigram [word [i :i + 1 ]] == 0 {
97
96
return 0.0
98
97
}
@@ -106,13 +105,8 @@ func (p *Pronounceable) WordScore(word string) float64 {
106
105
score += p .uniweight * float64 (p .unigram [word [i :i + 1 ]]) / p .uninorm
107
106
}
108
107
109
- // Normalize by how many scores have been computed
110
- lengthnorm := 1.0
111
- if len (word ) > 1 {
112
- lengthnorm = float64 (len (word )- 1 ) * 3.0
113
- }
114
-
115
- return score / lengthnorm
108
+ // Normalize by how many scores have been summarized
109
+ return score / float64 (len (word )- 1 ) * 3.0
116
110
}
117
111
118
112
// IsPronounceable determines whether a word is pronounceable by comparing the word
You can’t perform that action at this time.
0 commit comments