summaryrefslogtreecommitdiffstats
path: root/lib/str.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-06-19 11:48:29 -0400
committersiddharth <s@ricketyspace.net>2021-06-19 11:48:29 -0400
commit6717e6895546da4739355506abf7000a8d794f51 (patch)
tree4482db4a8bbb4e1bb469740ac331403a61074fa5 /lib/str.go
parentd90053b1bb6620dc999f723d64aadccfbe6e0bbf (diff)
lib: update AlphaPunchScore
- Use AsciiScores for scores - Remove isAlphaPunch
Diffstat (limited to 'lib/str.go')
-rw-r--r--lib/str.go21
1 files changed, 1 insertions, 20 deletions
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)