Skip to content

Commit 4fe2a11

Browse files
committed
cleanup
1 parent 18239c6 commit 4fe2a11

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func deduplicateAndLowerToBytes(str string) []byte {
8686
seen := map[byte]bool{}
8787
bytes := []byte{}
8888
characters := strings.ToLower(str)
89-
for i := 0; i < len(characters); i++ {
89+
for i := range characters {
9090
value := characters[i]
9191
if !seen[value] {
9292
bytes = append(bytes, value)

pron.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ func (p *Pronounceable) WordScore(word string) float64 {
8989
}
9090

9191
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
9695
if p.unigram[word[i:i+1]] == 0 {
9796
return 0.0
9897
}
@@ -106,13 +105,8 @@ func (p *Pronounceable) WordScore(word string) float64 {
106105
score += p.uniweight * float64(p.unigram[word[i:i+1]]) / p.uninorm
107106
}
108107

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
116110
}
117111

118112
// IsPronounceable determines whether a word is pronounceable by comparing the word

0 commit comments

Comments
 (0)