1670
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#MetaphoneStringComparatorTest
|
|
6 |
instanceVariableNames:'sc'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression-Collections-Utilities'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
2164
|
13 |
!MetaphoneStringComparatorTest methodsFor:'initialize / release'!
|
1670
|
14 |
|
|
15 |
setUp
|
|
16 |
sc := PhoneticStringUtilities::MetaphoneStringComparator new
|
|
17 |
|
|
18 |
"Modified: / 02-08-2017 / 13:03:33 / cg"
|
|
19 |
! !
|
|
20 |
|
|
21 |
!MetaphoneStringComparatorTest methodsFor:'tests'!
|
|
22 |
|
|
23 |
test01_SomeCombinations
|
|
24 |
"tests if all char combinations up to size 4 can be soundexed"
|
|
25 |
|
|
26 |
|code s|
|
|
27 |
|
|
28 |
^ self.
|
|
29 |
|
|
30 |
self skip:'this test does not really test anything (except if all 4-char string combinations can be soundexed)'.
|
|
31 |
|
|
32 |
$A to:$Z do:[:c1 |
|
|
33 |
s := String with:c1.
|
|
34 |
code := (sc phoneticStringsFor:s) first.
|
|
35 |
|
|
36 |
$A to:$Z do:[:c2 |
|
|
37 |
s := String with:c1 with:c2.
|
|
38 |
code := (sc phoneticStringsFor:s) first.
|
|
39 |
|
|
40 |
$A to:$Z do:[:c3 |
|
|
41 |
s := String with:c1 with:c2 with:c3.
|
|
42 |
code := (sc phoneticStringsFor:s) first.
|
|
43 |
|
|
44 |
$A to:$Z do:[:c4 |
|
|
45 |
s := String with:c1 with:c2 with:c3 with:c4.
|
|
46 |
code := (sc phoneticStringsFor:s) first.
|
|
47 |
self assert:( code = s asSoundexCode).
|
|
48 |
].
|
|
49 |
].
|
|
50 |
].
|
|
51 |
].
|
|
52 |
|
|
53 |
"Created: / 27-07-2017 / 15:14:53 / cg"
|
|
54 |
"Modified: / 31-07-2017 / 17:51:21 / cg"
|
|
55 |
!
|
|
56 |
|
|
57 |
test02_WellKnownResults
|
1675
|
58 |
"tests some wellknown metaphone codes"
|
1670
|
59 |
|
|
60 |
#(
|
1675
|
61 |
'a' 'A'
|
1670
|
62 |
'Miller' 'MLR'
|
1675
|
63 |
'ch' 'X'
|
|
64 |
|
|
65 |
'ANASTHA' 'ANS0'
|
|
66 |
'DAVIS-CARTER' 'TFSKRTR'
|
|
67 |
'ESCARMANT' 'ESKRMNT'
|
|
68 |
'MERSEAL' 'MRSL'
|
|
69 |
'PIEURISSAINT' 'PRSNT'
|
|
70 |
'ROTMAN' 'RTMN'
|
|
71 |
'SEAL' 'SL'
|
|
72 |
'SPARR' 'SPR'
|
|
73 |
'STARLEPER' 'STRLPR'
|
|
74 |
'THRASH' '0RX'
|
|
75 |
|
|
76 |
'LOGGING' 'LKNK'
|
|
77 |
'LOGIC' 'LJK'
|
|
78 |
'JUDGES' 'JJS'
|
|
79 |
|
|
80 |
'SHOOS' 'XS'
|
|
81 |
'SHOES' 'XS'
|
|
82 |
|
|
83 |
'OTTO' 'OT'
|
|
84 |
'ERIC' 'ERK'
|
|
85 |
'DAVE' 'TF'
|
|
86 |
'CATHERINE' 'K0RN'
|
|
87 |
'KATHERINE' 'K0RN'
|
|
88 |
'AUBREY' 'ABR'
|
|
89 |
'BRYAN' 'BRYN'
|
|
90 |
'BRYCE' 'BRS'
|
|
91 |
'STEVEN' 'STFN'
|
|
92 |
'HEIDI' 'HT'
|
|
93 |
'AUTO' 'AT'
|
|
94 |
'MAURICE' 'MRS'
|
|
95 |
'RANDY' 'RNT'
|
|
96 |
'CAMBRILLO' 'KMBRL'
|
|
97 |
'BRIAN' 'BRN'
|
|
98 |
'RAY' 'R'
|
|
99 |
'GEOFF' 'JF'
|
|
100 |
'BOB' 'BB'
|
|
101 |
|
|
102 |
'AHA' 'AH'
|
|
103 |
'AAH' 'A'
|
|
104 |
|
|
105 |
'PAUL' 'PL'
|
|
106 |
'BATTLEY' 'BTL'
|
|
107 |
'WROTE' 'RT'
|
|
108 |
'THIS' '0S'
|
|
109 |
|
|
110 |
'MCCALL' 'MKL'
|
|
111 |
'MCCROREY' 'MKRR'
|
|
112 |
|
|
113 |
'Sch' 'SX'
|
|
114 |
'Schi' 'SX'
|
1670
|
115 |
'Schmid' 'SXMT'
|
1675
|
116 |
'Schmidt' 'SXMTT' "/ bad, but that is how metaphone works
|
|
117 |
'Schmit' 'SXMT'
|
|
118 |
'Schmitt' 'SXMDT'
|
|
119 |
|
|
120 |
'CHUTE' 'XT'
|
|
121 |
'SCHEVEL' 'SXFL'
|
|
122 |
'SCHROM' 'SXRM'
|
|
123 |
'SCHUSS' 'SXS'
|
|
124 |
'RICHARD' 'RXRT'
|
|
125 |
|
1670
|
126 |
) pairWiseDo:[:word :expected |
|
|
127 |
|whatIGot|
|
|
128 |
|
|
129 |
whatIGot := sc encode:word.
|
|
130 |
self assert: (whatIGot = expected).
|
|
131 |
].
|
|
132 |
|
|
133 |
"Created: / 27-07-2017 / 15:14:59 / cg"
|
1675
|
134 |
"Modified (comment): / 03-08-2017 / 14:57:10 / cg"
|
|
135 |
!
|
|
136 |
|
|
137 |
test03_SomeCombinations
|
|
138 |
|code|
|
|
139 |
|
|
140 |
"/ code := (sc phoneticStringsFor:'AAH') first.
|
|
141 |
code := (sc encode:'AAH').
|
|
142 |
self assert:( code = 'A').
|
|
143 |
|
|
144 |
"Created: / 03-08-2017 / 14:53:40 / cg"
|
1670
|
145 |
! !
|
|
146 |
|
|
147 |
!MetaphoneStringComparatorTest class methodsFor:'documentation'!
|
|
148 |
|
|
149 |
version
|
|
150 |
^ '$Header$'
|
|
151 |
!
|
|
152 |
|
|
153 |
version_CVS
|
|
154 |
^ '$Header$'
|
|
155 |
! !
|
|
156 |
|