From d20fdad72c7ff1b1b6ee1623626c16ea50284745 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 5 Sep 2020 19:06:21 -0400 Subject: lib: add AlphaScore * lib/str.go (AlphaScore): New function. --- lib/str.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/str.go') diff --git a/lib/str.go b/lib/str.go index 7129136..e4df4b4 100644 --- a/lib/str.go +++ b/lib/str.go @@ -29,6 +29,16 @@ func stripSpaceChars(s string) string { return ss } +func AlphaScore(bs []byte) int { + s := 0 + for i := 0; i < len(bs); i++ { + if isAlpha(bs[i]) { + s += 1 + } + } + return s +} + func isAlpha(c byte) bool { switch { case 'A' <= c && c <= 'Z': -- cgit v1.2.3