From 6717e6895546da4739355506abf7000a8d794f51 Mon Sep 17 00:00:00 2001 From: siddharth Date: Sat, 19 Jun 2021 11:48:29 -0400 Subject: lib: update AlphaPunchScore - Use AsciiScores for scores - Remove isAlphaPunch --- lib/str.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'lib/str.go') diff --git a/lib/str.go b/lib/str.go index ee8667f..8fd6344 100644 --- a/lib/str.go +++ b/lib/str.go @@ -89,30 +89,11 @@ func StripSpaceChars(s string) string { func AlphaPunchScore(bs []byte) int { s := 0 for i := 0; i < len(bs); i++ { - if isAlphaPunch(bs[i]) { - s += 1 - } + s += AsciiScores[bs[i]] } return s } -// Returns true if byte 'c' is a non-numeric character in the English language. -func isAlphaPunch(c byte) bool { - switch { - case 'A' <= c && c <= 'Z': - return true - case 'a' <= c && c <= 'z': - return true - case c == ' ' || c == '.': - return true - case c == ',' || c == '\'': - return true - case c == '"': - return true - } - return false -} - func NumToChar(n int64) byte { if 0 <= n && n <= 9 { return byte(48 + n) -- cgit v1.2.3