001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.codec.language;
019
020 import org.junit.Assert;
021
022 import org.apache.commons.codec.EncoderException;
023 import org.apache.commons.codec.StringEncoderAbstractTest;
024 import org.junit.Test;
025
026 /**
027 * Tests Caverphone2.
028 *
029 * @version $Id: Caverphone2Test.html 889935 2013-12-11 05:05:13Z ggregory $
030 * @since 1.5
031 */
032 public class Caverphone2Test extends StringEncoderAbstractTest<Caverphone2> {
033
034 @Override
035 protected Caverphone2 createStringEncoder() {
036 return new Caverphone2();
037 }
038
039 /**
040 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
041 *
042 * AT11111111 words: add, aid, at, art, eat, earth, head, hit, hot, hold, hard, heart, it, out, old
043 *
044 * @throws EncoderException
045 */
046 @Test
047 public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderException {
048 this.checkEncodingVariations("AT11111111", new String[]{
049 "add",
050 "aid",
051 "at",
052 "art",
053 "eat",
054 "earth",
055 "head",
056 "hit",
057 "hot",
058 "hold",
059 "hard",
060 "heart",
061 "it",
062 "out",
063 "old"});
064 }
065
066 /**
067 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
068 *
069 * @throws EncoderException
070 */
071 @Test
072 public void testCaverphoneRevisitedExamples() throws EncoderException {
073 final String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}};
074 this.checkEncodings(data);
075 }
076
077 /**
078 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
079 *
080 * @throws EncoderException
081 */
082 @Test
083 public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderException {
084 this.checkEncodingVariations("KLN1111111", new String[]{
085 "Cailean",
086 "Calan",
087 "Calen",
088 "Callahan",
089 "Callan",
090 "Callean",
091 "Carleen",
092 "Carlen",
093 "Carlene",
094 "Carlin",
095 "Carline",
096 "Carlyn",
097 "Carlynn",
098 "Carlynne",
099 "Charlean",
100 "Charleen",
101 "Charlene",
102 "Charline",
103 "Cherlyn",
104 "Chirlin",
105 "Clein",
106 "Cleon",
107 "Cline",
108 "Cohleen",
109 "Colan",
110 "Coleen",
111 "Colene",
112 "Colin",
113 "Colleen",
114 "Collen",
115 "Collin",
116 "Colline",
117 "Colon",
118 "Cullan",
119 "Cullen",
120 "Cullin",
121 "Gaelan",
122 "Galan",
123 "Galen",
124 "Garlan",
125 "Garlen",
126 "Gaulin",
127 "Gayleen",
128 "Gaylene",
129 "Giliane",
130 "Gillan",
131 "Gillian",
132 "Glen",
133 "Glenn",
134 "Glyn",
135 "Glynn",
136 "Gollin",
137 "Gorlin",
138 "Kalin",
139 "Karlan",
140 "Karleen",
141 "Karlen",
142 "Karlene",
143 "Karlin",
144 "Karlyn",
145 "Kaylyn",
146 "Keelin",
147 "Kellen",
148 "Kellene",
149 "Kellyann",
150 "Kellyn",
151 "Khalin",
152 "Kilan",
153 "Kilian",
154 "Killen",
155 "Killian",
156 "Killion",
157 "Klein",
158 "Kleon",
159 "Kline",
160 "Koerlin",
161 "Kylen",
162 "Kylynn",
163 "Quillan",
164 "Quillon",
165 "Qulllon",
166 "Xylon"});
167 }
168
169 /**
170 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
171 *
172 * @throws EncoderException
173 */
174 @Test
175 public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderException {
176 this.checkEncodingVariations("TN11111111", new String[]{
177 "Dan",
178 "Dane",
179 "Dann",
180 "Darn",
181 "Daune",
182 "Dawn",
183 "Ddene",
184 "Dean",
185 "Deane",
186 "Deanne",
187 "DeeAnn",
188 "Deeann",
189 "Deeanne",
190 "Deeyn",
191 "Den",
192 "Dene",
193 "Denn",
194 "Deonne",
195 "Diahann",
196 "Dian",
197 "Diane",
198 "Diann",
199 "Dianne",
200 "Diannne",
201 "Dine",
202 "Dion",
203 "Dione",
204 "Dionne",
205 "Doane",
206 "Doehne",
207 "Don",
208 "Donn",
209 "Doone",
210 "Dorn",
211 "Down",
212 "Downe",
213 "Duane",
214 "Dun",
215 "Dunn",
216 "Duyne",
217 "Dyan",
218 "Dyane",
219 "Dyann",
220 "Dyanne",
221 "Dyun",
222 "Tan",
223 "Tann",
224 "Teahan",
225 "Ten",
226 "Tenn",
227 "Terhune",
228 "Thain",
229 "Thaine",
230 "Thane",
231 "Thanh",
232 "Thayne",
233 "Theone",
234 "Thin",
235 "Thorn",
236 "Thorne",
237 "Thun",
238 "Thynne",
239 "Tien",
240 "Tine",
241 "Tjon",
242 "Town",
243 "Towne",
244 "Turne",
245 "Tyne"});
246 }
247
248 /**
249 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
250 *
251 * @throws EncoderException
252 */
253 @Test
254 public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderException {
255 this.checkEncodingVariations("TTA1111111", new String[]{
256 "Darda",
257 "Datha",
258 "Dedie",
259 "Deedee",
260 "Deerdre",
261 "Deidre",
262 "Deirdre",
263 "Detta",
264 "Didi",
265 "Didier",
266 "Dido",
267 "Dierdre",
268 "Dieter",
269 "Dita",
270 "Ditter",
271 "Dodi",
272 "Dodie",
273 "Dody",
274 "Doherty",
275 "Dorthea",
276 "Dorthy",
277 "Doti",
278 "Dotti",
279 "Dottie",
280 "Dotty",
281 "Doty",
282 "Doughty",
283 "Douty",
284 "Dowdell",
285 "Duthie",
286 "Tada",
287 "Taddeo",
288 "Tadeo",
289 "Tadio",
290 "Tati",
291 "Teador",
292 "Tedda",
293 "Tedder",
294 "Teddi",
295 "Teddie",
296 "Teddy",
297 "Tedi",
298 "Tedie",
299 "Teeter",
300 "Teodoor",
301 "Teodor",
302 "Terti",
303 "Theda",
304 "Theodor",
305 "Theodore",
306 "Theta",
307 "Thilda",
308 "Thordia",
309 "Tilda",
310 "Tildi",
311 "Tildie",
312 "Tildy",
313 "Tita",
314 "Tito",
315 "Tjader",
316 "Toddie",
317 "Toddy",
318 "Torto",
319 "Tuddor",
320 "Tudor",
321 "Turtle",
322 "Tuttle",
323 "Tutto"});
324 }
325
326 /**
327 * See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
328 *
329 * @throws EncoderException
330 */
331 @Test
332 public void testCaverphoneRevisitedRandomWords() throws EncoderException {
333 this.checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"});
334 this.checkEncoding("SSA1111111", "social");
335 this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"});
336 }
337
338 @Test
339 public void testEndMb() throws EncoderException {
340 final String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
341 this.checkEncodings(data);
342 }
343
344 // Caverphone Revisited
345 @Test
346 public void testIsCaverphoneEquals() throws EncoderException {
347 final Caverphone2 caverphone = new Caverphone2();
348 Assert.assertFalse("Caverphone encodings should not be equal", caverphone.isEncodeEqual("Peter", "Stevenson"));
349 Assert.assertTrue("Caverphone encodings should be equal", caverphone.isEncodeEqual("Peter", "Peady"));
350 }
351
352 @Test
353 public void testSpecificationExamples() throws EncoderException {
354 final String[][] data = {
355 {"Peter", "PTA1111111"},
356 {"ready", "RTA1111111"},
357 {"social", "SSA1111111"},
358 {"able", "APA1111111"},
359 {"Tedder", "TTA1111111"},
360 {"Karleen", "KLN1111111"},
361 {"Dyun", "TN11111111"}};
362 this.checkEncodings(data);
363 }
364
365 }