Skip to content

Commit

Permalink
Merge pull request #48 from melehin/master
Browse files Browse the repository at this point in the history
Fix Soundex table to match the one in soundex.c
  • Loading branch information
syyongx authored Jul 30, 2024
2 parents ab9cd97 + 9cb6891 commit 481c9a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions php.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"golang.org/x/text/cases"
"hash/crc32"
"html"
"io"
Expand All @@ -34,6 +33,8 @@ import (
"time"
"unicode"
"unicode/utf8"

"golang.org/x/text/cases"
)

//////////// Date/Time Functions ////////////
Expand Down Expand Up @@ -950,21 +951,21 @@ func Soundex(str string) string {
}
table := [26]rune{
// A, B, C, D
'0', '1', '2', '3',
0, '1', '2', '3',
// E, F, G
'0', '1', '2',
0, '1', '2',
// H
'0',
0,
// I, J, K, L, M, N
'0', '2', '2', '4', '5', '5',
0, '2', '2', '4', '5', '5',
// O, P, Q, R, S, T
'0', '1', '2', '6', '2', '3',
0, '1', '2', '6', '2', '3',
// U, V
'0', '1',
0, '1',
// W, X
'0', '2',
0, '2',
// Y, Z
'0', '2',
0, '2',
}
last, code, small := -1, 0, 0
sd := make([]rune, 4)
Expand Down
1 change: 1 addition & 0 deletions php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestString(t *testing.T) {
equal(t, float64(50), percent)

equal(t, "H416", Soundex("Heilbronn"))
equal(t, "M520", Soundex("Mansa"))

equal(t, 14, len(Uniqid("x")))
equal(t, true, bytes.HasPrefix([]byte(Uniqid("x")), []byte("x")))
Expand Down

0 comments on commit 481c9a3

Please sign in to comment.