View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.codec.language;
19  
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  import static org.junit.jupiter.api.Assertions.assertFalse;
22  import static org.junit.jupiter.api.Assertions.assertNull;
23  import static org.junit.jupiter.api.Assertions.assertTrue;
24  import static org.junit.jupiter.api.Assertions.fail;
25  
26  import java.util.stream.Stream;
27  
28  import org.apache.commons.codec.AbstractStringEncoderTest;
29  import org.apache.commons.codec.EncoderException;
30  import org.junit.jupiter.api.Test;
31  import org.junit.jupiter.params.ParameterizedTest;
32  import org.junit.jupiter.params.provider.Arguments;
33  import org.junit.jupiter.params.provider.MethodSource;
34  
35  /**
36   * Tests {@link DoubleMetaphone}.
37   *
38   * <p>
39   * Keep this file in UTF-8 encoding for proper Javadoc processing.
40   * </p>
41   *
42   * @see "http://www.cuj.com/documents/s=8038/cuj0006philips/"
43   */
44  class DoubleMetaphoneTest extends AbstractStringEncoderTest<DoubleMetaphone> {
45  
46      /**
47       * Test data from https://aspell.net/test/orig/batch0.tab.
48       *
49       * "Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org). Verbatim copying
50       * and distribution of this entire article is permitted in any medium,
51       * provided this notice is preserved."
52       *
53       * Massaged the test data in the array below.
54       */
55      private static final String[][] FIXTURE = { { "Accosinly", "Occasionally" }, {
56              "Ciculer", "Circler" }, {
57              "Circue", "Circle" }, {
58              "Maddness", "Madness" }, {
59              "Occusionaly", "Occasionally" }, {
60              "Steffen", "Stephen" }, {
61              "Thw", "The" }, {
62              "Unformanlly", "Unfortunately" }, {
63              "Unfortally", "Unfortunately" }, {
64              "abilitey", "ability" }, {
65              "abouy", "about" }, {
66              "absorbtion", "absorption" }, {
67              "accidently", "accidentally" }, {
68              "accomodate", "accommodate" }, {
69              "acommadate", "accommodate" }, {
70              "acord", "accord" }, {
71              "adultry", "adultery" }, {
72              "aggresive", "aggressive" }, {
73              "alchohol", "alcohol" }, {
74              "alchoholic", "alcoholic" }, {
75              "allieve", "alive" }, {
76              "alot", "a lot" }, {
77              "alright", "all right" }, {
78              "amature", "amateur" }, {
79              "ambivilant", "ambivalent" }, {
80              "amification", "amplification" }, {
81              "amourfous", "amorphous" }, {
82              "annoint", "anoint" }, {
83              "annonsment", "announcement" }, {
84              "annoyting", "anting" }, {
85              "annuncio", "announce" }, {
86              "anonomy", "anatomy" }, {
87              "anotomy", "anatomy" }, {
88              "antidesestablishmentarianism", "antidisestablishmentarianism" }, {
89              "antidisestablishmentarism", "antidisestablishmentarianism" }, {
90              "anynomous", "anonymous" }, {
91              "appelet", "applet" }, {
92              "appreceiated", "appreciated" }, {
93              "appresteate", "appreciate" }, {
94              "aquantance", "acquaintance" }, {
95              "aratictature", "architecture" }, {
96              "archeype", "archetype" }, {
97              "aricticure", "architecture" }, {
98              "artic", "arctic" }, {
99              "asentote", "asymptote" }, {
100             "ast", "at" }, {
101             "asterick", "asterisk" }, {
102             "asymetric", "asymmetric" }, {
103             "atentively", "attentively" }, {
104             "autoamlly", "automatically" }, {
105             "bankrot", "bankrupt" }, {
106             "basicly", "basically" }, {
107             "batallion", "battalion" }, {
108             "bbrose", "browse" }, {
109             "beauro", "bureau" }, {
110             "beaurocracy", "bureaucracy" }, {
111             "beggining", "beginning" }, {
112             "beging", "beginning" }, {
113             "behaviour", "behavior" }, {
114             "beleive", "believe" }, {
115             "belive", "believe" }, {
116             "benidifs", "benefits" }, {
117             "bigginging", "beginning" }, {
118             "blait", "bleat" }, {
119             "bouyant", "buoyant" }, {
120             "boygot", "boycott" }, {
121             "brocolli", "broccoli" }, {
122             "buch", "bush" }, {
123             "buder", "butter" }, {
124             "budr", "butter" }, {
125             "budter", "butter" }, {
126             "buracracy", "bureaucracy" }, {
127             "burracracy", "bureaucracy" }, {
128             "buton", "button" }, {
129             "byby", "by by" }, {
130             "cauler", "caller" }, {
131             "ceasar", "caesar" }, {
132             "cemetary", "cemetery" }, {
133             "changeing", "changing" }, {
134             "cheet", "cheat" }, {
135             "cicle", "circle" }, {
136             "cimplicity", "simplicity" }, {
137             "circumstaces", "circumstances" }, {
138             "clob", "club" }, {
139             "coaln", "colon" }, {
140             "cocamena", "cockamamie" }, {
141             "colleaque", "colleague" }, {
142             "colloquilism", "colloquialism" }, {
143             "columne", "column" }, {
144             "comiler", "compiler" }, {
145             "comitmment", "commitment" }, {
146             "comitte", "committee" }, {
147             "comittmen", "commitment" }, {
148             "comittmend", "commitment" }, {
149             "commerciasl", "commercials" }, {
150             "commited", "committed" }, {
151             "commitee", "committee" }, {
152             "companys", "companies" }, {
153             "compicated", "complicated" }, {
154             "comupter", "computer" }, {
155             "concensus", "consensus" }, {
156             "confusionism", "confucianism" }, {
157             "congradulations", "congratulations" }, {
158             "conibation", "contribution" }, {
159             "consident", "consistent" }, {
160             "consident", "consonant" }, {
161             "contast", "constant" }, {
162             "contastant", "constant" }, {
163             "contunie", "continue" }, {
164             "cooly", "coolly" }, {
165             "copping", "coping" }, {
166             "cosmoplyton", "cosmopolitan" }, {
167             "courst", "court" }, {
168             "crasy", "crazy" }, {
169             "cravets", "caveats" }, {
170             "credetability", "credibility" }, {
171             "criqitue", "critique" }, {
172             "croke", "croak" }, {
173             "crucifiction", "crucifixion" }, {
174             "crusifed", "crucified" }, {
175             "ctitique", "critique" }, {
176             "cumba", "combo" }, {
177             "custamisation", "customization" }, {
178             "dag", "dog" }, {
179             "daly", "daily" }, {
180             "danguages", "dangerous" }, {
181             "deaft", "draft" }, {
182             "defence", "defense" }, {
183             "defenly", "defiantly" }, {
184             "definate", "definite" }, {
185             "definately", "definitely" }, {
186             "dependeble", "dependable" }, {
187             "descrption", "description" }, {
188             "descrptn", "description" }, {
189             "desparate", "desperate" }, {
190             "dessicate", "desiccate" }, {
191             "destint", "distant" }, {
192             "develepment", "developments" }, {
193             "developement", "development" }, {
194             "develpond", "development" }, {
195             "devulge", "divulge" }, {
196             "diagree", "disagree" }, {
197             "dieties", "deities" }, {
198             "dinasaur", "dinosaur" }, {
199             "dinasour", "dinosaur" }, {
200             "direcyly", "directly" }, {
201             "discuess", "discuss" }, {
202             "disect", "dissect" }, {
203             "disippate", "dissipate" }, {
204             "disition", "decision" }, {
205             "dispair", "despair" }, {
206             "disssicion", "discussion" }, {
207             "distarct", "distract" }, {
208             "distart", "distort" }, {
209             "distroy", "destroy" }, {
210             "documtations", "documentation" }, {
211             "doenload", "download" }, {
212             "dongle", "dangle" }, {
213             "doog", "dog" }, {
214             "dramaticly", "dramatically" }, {
215             "drunkeness", "drunkenness" }, {
216             "ductioneery", "dictionary" }, {
217             "dur", "due" }, {
218             "duren", "during" }, {
219             "dymatic", "dynamic" }, {
220             "dynaic", "dynamic" }, {
221             "ecstacy", "ecstasy" }, {
222             "efficat", "efficient" }, {
223             "efficity", "efficacy" }, {
224             "effots", "efforts" }, {
225             "egsistence", "existence" }, {
226             "eitiology", "etiology" }, {
227             "elagent", "elegant" }, {
228             "elligit", "elegant" }, {
229             "embarass", "embarrass" }, {
230             "embarassment", "embarrassment" }, {
231             "embaress", "embarrass" }, {
232             "encapsualtion", "encapsulation" }, {
233             "encyclapidia", "encyclopedia" }, {
234             "encyclopia", "encyclopedia" }, {
235             "engins", "engine" }, {
236             "enhence", "enhance" }, {
237             "enligtment", "Enlightenment" }, {
238             "ennuui", "ennui" }, {
239             "enought", "enough" }, {
240             "enventions", "inventions" }, {
241             "envireminakl", "environmental" }, {
242             "enviroment", "environment" }, {
243             "epitomy", "epitome" }, {
244             "equire", "acquire" }, {
245             "errara", "error" }, {
246             "erro", "error" }, {
247             "evaualtion", "evaluation" }, {
248             "evething", "everything" }, {
249             "evtually", "eventually" }, {
250             "excede", "exceed" }, {
251             "excercise", "exercise" }, {
252             "excpt", "except" }, {
253             "excution", "execution" }, {
254             "exhileration", "exhilaration" }, {
255             "existance", "existence" }, {
256             "expleyly", "explicitly" }, {
257             "explity", "explicitly" }, {
258             "expresso", "espresso" }, {
259             "exspidient", "expedient" }, {
260             "extions", "extensions" }, {
261             "factontion", "factorization" }, {
262             "failer", "failure" }, {
263             "famdasy", "fantasy" }, {
264             "faver", "favor" }, {
265             "faxe", "fax" }, {
266             "febuary", "february" }, {
267             "firey", "fiery" }, {
268             "fistival", "festival" }, {
269             "flatterring", "flattering" }, {
270             "fluk", "flux" }, {
271             "flukse", "flux" }, {
272             "fone", "phone" }, {
273             "forsee", "foresee" }, {
274             "frustartaion", "frustrating" }, {
275             "fuction", "function" }, {
276             "funetik", "phonetic" }, {
277             "futs", "guts" }, {
278             "gamne", "came" }, {
279             "gaurd", "guard" }, {
280             "generly", "generally" }, {
281             "ghandi", "gandhi" }, {
282             "goberment", "government" }, {
283             "gobernement", "government" }, {
284             "gobernment", "government" }, {
285             "gotton", "gotten" }, {
286             "gracefull", "graceful" }, {
287             "gradualy", "gradually" }, {
288             "grammer", "grammar" }, {
289             "hallo", "hello" }, {
290             "hapily", "happily" }, {
291             "harrass", "harass" }, {
292             "havne", "have" }, {
293             "heellp", "help" }, {
294             "heighth", "height" }, {
295             "hellp", "help" }, {
296             "helo", "hello" }, {
297             "herlo", "hello" }, {
298             "hifin", "hyphen" }, {
299             "hifine", "hyphen" }, {
300             "higer", "higher" }, {
301             "hiphine", "hyphen" }, {
302             "hippie", "hippy" }, {
303             "hippopotamous", "hippopotamus" }, {
304             "hlp", "help" }, {
305             "hourse", "horse" }, {
306             "houssing", "housing" }, {
307             "howaver", "however" }, {
308             "howver", "however" }, {
309             "humaniti", "humanity" }, {
310             "hyfin", "hyphen" }, {
311             "hypotathes", "hypothesis" }, {
312             "hypotathese", "hypothesis" }, {
313             "hystrical", "hysterical" }, {
314             "ident", "indent" }, {
315             "illegitament", "illegitimate" }, {
316             "imbed", "embed" }, {
317             "imediaetly", "immediately" }, {
318             "imfamy", "infamy" }, {
319             "immenant", "immanent" }, {
320             "implemtes", "implements" }, {
321             "inadvertant", "inadvertent" }, {
322             "incase", "in case" }, {
323             "incedious", "insidious" }, {
324             "incompleet", "incomplete" }, {
325             "incomplot", "incomplete" }, {
326             "inconvenant", "inconvenient" }, {
327             "inconvience", "inconvenience" }, {
328             "independant", "independent" }, {
329             "independenent", "independent" }, {
330             "indepnends", "independent" }, {
331             "indepth", "in depth" }, {
332             "indispensible", "indispensable" }, {
333             "inefficite", "inefficient" }, {
334             "inerface", "interface" }, {
335             "infact", "in fact" }, {
336             "influencial", "influential" }, {
337             "inital", "initial" }, {
338             "initinized", "initialized" }, {
339             "initized", "initialized" }, {
340             "innoculate", "inoculate" }, {
341             "insistant", "insistent" }, {
342             "insistenet", "insistent" }, {
343             "instulation", "installation" }, {
344             "intealignt", "intelligent" }, {
345             "intejilent", "intelligent" }, {
346             "intelegent", "intelligent" }, {
347             "intelegnent", "intelligent" }, {
348             "intelejent", "intelligent" }, {
349             "inteligent", "intelligent" }, {
350             "intelignt", "intelligent" }, {
351             "intellagant", "intelligent" }, {
352             "intellegent", "intelligent" }, {
353             "intellegint", "intelligent" }, {
354             "intellgnt", "intelligent" }, {
355             "intensionality", "intensionally" }, {
356             "interate", "iterate" }, {
357             "internation", "international" }, {
358             "interpretate", "interpret" }, {
359             "interpretter", "interpreter" }, {
360             "intertes", "interested" }, {
361             "intertesd", "interested" }, {
362             "invermeantial", "environmental" }, {
363             "irregardless", "regardless" }, {
364             "irresistable", "irresistible" }, {
365             "irritible", "irritable" }, {
366             "islams", "muslims" }, {
367             "isotrop", "isotope" }, {
368             "isreal", "israel" }, {
369             "johhn", "john" }, {
370             "judgement", "judgment" }, {
371             "kippur", "kipper" }, {
372             "knawing", "knowing" }, {
373             "latext", "latest" }, {
374             "leasve", "leave" }, {
375             "lesure", "leisure" }, {
376             "liasion", "lesion" }, {
377             "liason", "liaison" }, {
378             "libary", "library" }, {
379             "likly", "likely" }, {
380             "lilometer", "kilometer" }, {
381             "liquify", "liquefy" }, {
382             "lloyer", "layer" }, {
383             "lossing", "losing" }, {
384             "luser", "laser" }, {
385             "maintanence", "maintenance" }, {
386             "majaerly", "majority" }, {
387             "majoraly", "majority" }, {
388             "maks", "masks" }, {
389             "mandelbrot", "Mandelbrot" }, {
390             "mant", "want" }, {
391             "marshall", "marshal" }, {
392             "maxium", "maximum" }, {
393             "meory", "memory" }, {
394             "metter", "better" }, {
395             "mic", "mike" }, {
396             "midia", "media" }, {
397             "millenium", "millennium" }, {
398             "miniscule", "minuscule" }, {
399             "minkay", "monkey" }, {
400             "minum", "minimum" }, {
401             "mischievious", "mischievous" }, {
402             "misilous", "miscellaneous" }, {
403             "momento", "memento" }, {
404             "monkay", "monkey" }, {
405             "mosaik", "mosaic" }, {
406             "mostlikely", "most likely" }, {
407             "mousr", "mouser" }, {
408             "mroe", "more" }, {
409             "neccessary", "necessary" }, {
410             "necesary", "necessary" }, {
411             "necesser", "necessary" }, {
412             "neice", "niece" }, {
413             "neighbour", "neighbor" }, {
414             "nemonic", "pneumonic" }, {
415             "nevade", "Nevada" }, {
416             "nickleodeon", "nickelodeon" }, {
417             "nieve", "naive" }, {
418             "noone", "no one" }, {
419             "noticably", "noticeably" }, {
420             "notin", "not in" }, {
421             "nozled", "nuzzled" }, {
422             "objectsion", "objects" }, {
423             "obsfuscate", "obfuscate" }, {
424             "ocassion", "occasion" }, {
425             "occuppied", "occupied" }, {
426             "occurence", "occurrence" }, {
427             "octagenarian", "octogenarian" }, {
428             "olf", "old" }, {
429             "opposim", "opossum" }, {
430             "organise", "organize" }, {
431             "organiz", "organize" }, {
432             "orientate", "orient" }, {
433             "oscilascope", "oscilloscope" }, {
434             "oving", "moving" }, {
435             "paramers", "parameters" }, {
436             "parametic", "parameter" }, {
437             "paranets", "parameters" }, {
438             "partrucal", "particular" }, {
439             "pataphysical", "metaphysical" }, {
440             "patten", "pattern" }, {
441             "permissable", "permissible" }, {
442             "permition", "permission" }, {
443             "permmasivie", "permissive" }, {
444             "perogative", "prerogative" }, {
445             "persue", "pursue" }, {
446             "phantasia", "fantasia" }, {
447             "phenominal", "phenomenal" }, {
448             "picaresque", "picturesque" }, {
449             "playwrite", "playwright" }, {
450             "poeses", "poesies" }, {
451             "polation", "politician" }, {
452             "poligamy", "polygamy" }, {
453             "politict", "politic" }, {
454             "pollice", "police" }, {
455             "polypropalene", "polypropylene" }, {
456             "pompom", "pompon" }, {
457             "possable", "possible" }, {
458             "practicle", "practical" }, {
459             "pragmaticism", "pragmatism" }, {
460             "preceeding", "preceding" }, {
461             "precion", "precision" }, {
462             "precios", "precision" }, {
463             "preemptory", "peremptory" }, {
464             "prefices", "prefixes" }, {
465             "prefixt", "prefixed" }, {
466             "presbyterian", "Presbyterian" }, {
467             "presue", "pursue" }, {
468             "presued", "pursued" }, {
469             "privielage", "privilege" }, {
470             "priviledge", "privilege" }, {
471             "proceedures", "procedures" }, {
472             "pronensiation", "pronunciation" }, {
473             "pronisation", "pronunciation" }, {
474             "pronounciation", "pronunciation" }, {
475             "properally", "properly" }, {
476             "proplematic", "problematic" }, {
477             "protray", "portray" }, {
478             "pscolgst", "psychologist" }, {
479             "psicolagest", "psychologist" }, {
480             "psycolagest", "psychologist" }, {
481             "quoz", "quiz" }, {
482             "radious", "radius" }, {
483             "ramplily", "rampantly" }, {
484             "reccomend", "recommend" }, {
485             "reccona", "raccoon" }, {
486             "recieve", "receive" }, {
487             "reconise", "recognize" }, {
488             "rectangeles", "rectangle" }, {
489             "redign", "redesign" }, {
490             "reoccurring", "recurring" }, {
491             "repitition", "repetition" }, {
492             "replasments", "replacement" }, {
493             "reposable", "responsible" }, {
494             "reseblence", "resemblance" }, {
495             "respct", "respect" }, {
496             "respecally", "respectfully" }, {
497             "roon", "room" }, {
498             "rought", "roughly" }, {
499             "rsx", "RSX" }, {
500             "rudemtry", "rudimentary" }, {
501             "runnung", "running" }, {
502             "sacreligious", "sacrilegious" }, {
503             "saftly", "safely" }, {
504             "salut", "salute" }, {
505             "satifly", "satisfy" }, {
506             "scrabdle", "scrabble" }, {
507             "searcheable", "searchable" }, {
508             "secion", "section" }, {
509             "seferal", "several" }, {
510             "segements", "segments" }, {
511             "sence", "sense" }, {
512             "seperate", "separate" }, {
513             "sherbert", "sherbet" }, {
514             "sicolagest", "psychologist" }, {
515             "sieze", "seize" }, {
516             "simpfilty", "simplicity" }, {
517             "simplye", "simply" }, {
518             "singal", "signal" }, {
519             "sitte", "site" }, {
520             "situration", "situation" }, {
521             "slyph", "sylph" }, {
522             "smil", "smile" }, {
523             "snuck", "sneaked" }, {
524             "sometmes", "sometimes" }, {
525             "soonec", "sonic" }, {
526             "specificialy", "specifically" }, {
527             "spel", "spell" }, {
528             "spoak", "spoke" }, {
529             "sponsered", "sponsored" }, {
530             "stering", "steering" }, {
531             "straightjacket", "straitjacket" }, {
532             "stumach", "stomach" }, {
533             "stutent", "student" }, {
534             "styleguide", "style guide" }, {
535             "subisitions", "substitutions" }, {
536             "subjecribed", "subscribed" }, {
537             "subpena", "subpoena" }, {
538             "substations", "substitutions" }, {
539             "suger", "sugar" }, {
540             "supercede", "supersede" }, {
541             "superfulous", "superfluous" }, {
542             "susan", "Susan" }, {
543             "swimwear", "swim wear" }, {
544             "syncorization", "synchronization" }, {
545             "taff", "tough" }, {
546             "taht", "that" }, {
547             "tattos", "tattoos" }, {
548             "techniquely", "technically" }, {
549             "teh", "the" }, {
550             "tem", "team" }, {
551             "teo", "two" }, {
552             "teridical", "theoretical" }, {
553             "tesst", "test" }, {
554             "tets", "tests" }, {
555             "thanot", "than or" }, {
556             "theirselves", "themselves" }, {
557             "theridically", "theoretical" }, {
558             "thredically", "theoretically" }, {
559             "thruout", "throughout" }, {
560             "ths", "this" }, {
561             "titalate", "titillate" }, {
562             "tobagan", "tobaggon" }, {
563             "tommorrow", "tomorrow" }, {
564             "tomorow", "tomorrow" }, {
565             "tradegy", "tragedy" }, {
566             "trubbel", "trouble" }, {
567             "ttest", "test" }, {
568             "tunnellike", "tunnel like" }, {
569             "tured", "turned" }, {
570             "tyrrany", "tyranny" }, {
571             "unatourral", "unnatural" }, {
572             "unaturral", "unnatural" }, {
573             "unconisitional", "unconstitutional" }, {
574             "unconscience", "unconscious" }, {
575             "underladder", "under ladder" }, {
576             "unentelegible", "unintelligible" }, {
577             "unfortunently", "unfortunately" }, {
578             "unnaturral", "unnatural" }, {
579             "upcast", "up cast" }, {
580             "upmost", "utmost" }, {
581             "uranisium", "uranium" }, {
582             "verison", "version" }, {
583             "vinagarette", "vinaigrette" }, {
584             "volumptuous", "voluptuous" }, {
585             "volunteerism", "voluntarism" }, {
586             "volye", "volley" }, {
587             "wadting", "wasting" }, {
588             "waite", "wait" }, {
589             "wan't", "won't" }, {
590             "warloord", "warlord" }, {
591             "whaaat", "what" }, {
592             "whard", "ward" }, {
593             "whimp", "wimp" }, {
594             "wicken", "weaken" }, {
595             "wierd", "weird" }, {
596             "wrank", "rank" }, {
597             "writeen", "righten" }, {
598             "writting", "writing" }, {
599             "wundeews", "windows" }, {
600             "yeild", "yield" }, {
601             "youe", "your" }
602     };
603 
604     /**
605      * A subset of FIXTURE generated by this test.
606      */
607     private static final String[][] MATCHES = { { "Accosinly", "Occasionally" }, {
608             "Maddness", "Madness" }, {
609             "Occusionaly", "Occasionally" }, {
610             "Steffen", "Stephen" }, {
611             "Thw", "The" }, {
612             "Unformanlly", "Unfortunately" }, {
613             "Unfortally", "Unfortunately" }, {
614             "abilitey", "ability" }, {
615             "absorbtion", "absorption" }, {
616             "accidently", "accidentally" }, {
617             "accomodate", "accommodate" }, {
618             "acommadate", "accommodate" }, {
619             "acord", "accord" }, {
620             "adultry", "adultery" }, {
621             "aggresive", "aggressive" }, {
622             "alchohol", "alcohol" }, {
623             "alchoholic", "alcoholic" }, {
624             "allieve", "alive" }, {
625             "alot", "a lot" }, {
626             "alright", "all right" }, {
627             "amature", "amateur" }, {
628             "ambivilant", "ambivalent" }, {
629             "amourfous", "amorphous" }, {
630             "annoint", "anoint" }, {
631             "annonsment", "announcement" }, {
632             "annoyting", "anting" }, {
633             "annuncio", "announce" }, {
634             "anotomy", "anatomy" }, {
635             "antidesestablishmentarianism", "antidisestablishmentarianism" }, {
636             "antidisestablishmentarism", "antidisestablishmentarianism" }, {
637             "anynomous", "anonymous" }, {
638             "appelet", "applet" }, {
639             "appreceiated", "appreciated" }, {
640             "appresteate", "appreciate" }, {
641             "aquantance", "acquaintance" }, {
642             "aricticure", "architecture" }, {
643             "asterick", "asterisk" }, {
644             "asymetric", "asymmetric" }, {
645             "atentively", "attentively" }, {
646             "bankrot", "bankrupt" }, {
647             "basicly", "basically" }, {
648             "batallion", "battalion" }, {
649             "bbrose", "browse" }, {
650             "beauro", "bureau" }, {
651             "beaurocracy", "bureaucracy" }, {
652             "beggining", "beginning" }, {
653             "behaviour", "behavior" }, {
654             "beleive", "believe" }, {
655             "belive", "believe" }, {
656             "blait", "bleat" }, {
657             "bouyant", "buoyant" }, {
658             "boygot", "boycott" }, {
659             "brocolli", "broccoli" }, {
660             "buder", "butter" }, {
661             "budr", "butter" }, {
662             "budter", "butter" }, {
663             "buracracy", "bureaucracy" }, {
664             "burracracy", "bureaucracy" }, {
665             "buton", "button" }, {
666             "byby", "by by" }, {
667             "cauler", "caller" }, {
668             "ceasar", "caesar" }, {
669             "cemetary", "cemetery" }, {
670             "changeing", "changing" }, {
671             "cheet", "cheat" }, {
672             "cimplicity", "simplicity" }, {
673             "circumstaces", "circumstances" }, {
674             "clob", "club" }, {
675             "coaln", "colon" }, {
676             "colleaque", "colleague" }, {
677             "colloquilism", "colloquialism" }, {
678             "columne", "column" }, {
679             "comitmment", "commitment" }, {
680             "comitte", "committee" }, {
681             "comittmen", "commitment" }, {
682             "comittmend", "commitment" }, {
683             "commerciasl", "commercials" }, {
684             "commited", "committed" }, {
685             "commitee", "committee" }, {
686             "companys", "companies" }, {
687             "comupter", "computer" }, {
688             "concensus", "consensus" }, {
689             "confusionism", "confucianism" }, {
690             "congradulations", "congratulations" }, {
691             "contunie", "continue" }, {
692             "cooly", "coolly" }, {
693             "copping", "coping" }, {
694             "cosmoplyton", "cosmopolitan" }, {
695             "crasy", "crazy" }, {
696             "croke", "croak" }, {
697             "crucifiction", "crucifixion" }, {
698             "crusifed", "crucified" }, {
699             "cumba", "combo" }, {
700             "custamisation", "customization" }, {
701             "dag", "dog" }, {
702             "daly", "daily" }, {
703             "defence", "defense" }, {
704             "definate", "definite" }, {
705             "definately", "definitely" }, {
706             "dependeble", "dependable" }, {
707             "descrption", "description" }, {
708             "descrptn", "description" }, {
709             "desparate", "desperate" }, {
710             "dessicate", "desiccate" }, {
711             "destint", "distant" }, {
712             "develepment", "developments" }, {
713             "developement", "development" }, {
714             "develpond", "development" }, {
715             "devulge", "divulge" }, {
716             "dieties", "deities" }, {
717             "dinasaur", "dinosaur" }, {
718             "dinasour", "dinosaur" }, {
719             "discuess", "discuss" }, {
720             "disect", "dissect" }, {
721             "disippate", "dissipate" }, {
722             "disition", "decision" }, {
723             "dispair", "despair" }, {
724             "distarct", "distract" }, {
725             "distart", "distort" }, {
726             "distroy", "destroy" }, {
727             "doenload", "download" }, {
728             "dongle", "dangle" }, {
729             "doog", "dog" }, {
730             "dramaticly", "dramatically" }, {
731             "drunkeness", "drunkenness" }, {
732             "ductioneery", "dictionary" }, {
733             "ecstacy", "ecstasy" }, {
734             "egsistence", "existence" }, {
735             "eitiology", "etiology" }, {
736             "elagent", "elegant" }, {
737             "embarass", "embarrass" }, {
738             "embarassment", "embarrassment" }, {
739             "embaress", "embarrass" }, {
740             "encapsualtion", "encapsulation" }, {
741             "encyclapidia", "encyclopedia" }, {
742             "encyclopia", "encyclopedia" }, {
743             "engins", "engine" }, {
744             "enhence", "enhance" }, {
745             "ennuui", "ennui" }, {
746             "enventions", "inventions" }, {
747             "envireminakl", "environmental" }, {
748             "enviroment", "environment" }, {
749             "epitomy", "epitome" }, {
750             "equire", "acquire" }, {
751             "errara", "error" }, {
752             "evaualtion", "evaluation" }, {
753             "excede", "exceed" }, {
754             "excercise", "exercise" }, {
755             "excpt", "except" }, {
756             "exhileration", "exhilaration" }, {
757             "existance", "existence" }, {
758             "expleyly", "explicitly" }, {
759             "explity", "explicitly" }, {
760             "failer", "failure" }, {
761             "faver", "favor" }, {
762             "faxe", "fax" }, {
763             "firey", "fiery" }, {
764             "fistival", "festival" }, {
765             "flatterring", "flattering" }, {
766             "flukse", "flux" }, {
767             "fone", "phone" }, {
768             "forsee", "foresee" }, {
769             "frustartaion", "frustrating" }, {
770             "funetik", "phonetic" }, {
771             "gaurd", "guard" }, {
772             "generly", "generally" }, {
773             "ghandi", "gandhi" }, {
774             "gotton", "gotten" }, {
775             "gracefull", "graceful" }, {
776             "gradualy", "gradually" }, {
777             "grammer", "grammar" }, {
778             "hallo", "hello" }, {
779             "hapily", "happily" }, {
780             "harrass", "harass" }, {
781             "heellp", "help" }, {
782             "heighth", "height" }, {
783             "hellp", "help" }, {
784             "helo", "hello" }, {
785             "hifin", "hyphen" }, {
786             "hifine", "hyphen" }, {
787             "hiphine", "hyphen" }, {
788             "hippie", "hippy" }, {
789             "hippopotamous", "hippopotamus" }, {
790             "hourse", "horse" }, {
791             "houssing", "housing" }, {
792             "howaver", "however" }, {
793             "howver", "however" }, {
794             "humaniti", "humanity" }, {
795             "hyfin", "hyphen" }, {
796             "hystrical", "hysterical" }, {
797             "illegitament", "illegitimate" }, {
798             "imbed", "embed" }, {
799             "imediaetly", "immediately" }, {
800             "immenant", "immanent" }, {
801             "implemtes", "implements" }, {
802             "inadvertant", "inadvertent" }, {
803             "incase", "in case" }, {
804             "incedious", "insidious" }, {
805             "incompleet", "incomplete" }, {
806             "incomplot", "incomplete" }, {
807             "inconvenant", "inconvenient" }, {
808             "inconvience", "inconvenience" }, {
809             "independant", "independent" }, {
810             "independenent", "independent" }, {
811             "indepnends", "independent" }, {
812             "indepth", "in depth" }, {
813             "indispensible", "indispensable" }, {
814             "inefficite", "inefficient" }, {
815             "infact", "in fact" }, {
816             "influencial", "influential" }, {
817             "innoculate", "inoculate" }, {
818             "insistant", "insistent" }, {
819             "insistenet", "insistent" }, {
820             "instulation", "installation" }, {
821             "intealignt", "intelligent" }, {
822             "intelegent", "intelligent" }, {
823             "intelegnent", "intelligent" }, {
824             "intelejent", "intelligent" }, {
825             "inteligent", "intelligent" }, {
826             "intelignt", "intelligent" }, {
827             "intellagant", "intelligent" }, {
828             "intellegent", "intelligent" }, {
829             "intellegint", "intelligent" }, {
830             "intellgnt", "intelligent" }, {
831             "intensionality", "intensionally" }, {
832             "internation", "international" }, {
833             "interpretate", "interpret" }, {
834             "interpretter", "interpreter" }, {
835             "intertes", "interested" }, {
836             "intertesd", "interested" }, {
837             "invermeantial", "environmental" }, {
838             "irresistable", "irresistible" }, {
839             "irritible", "irritable" }, {
840             "isreal", "israel" }, {
841             "johhn", "john" }, {
842             "kippur", "kipper" }, {
843             "knawing", "knowing" }, {
844             "lesure", "leisure" }, {
845             "liasion", "lesion" }, {
846             "liason", "liaison" }, {
847             "likly", "likely" }, {
848             "liquify", "liquefy" }, {
849             "lloyer", "layer" }, {
850             "lossing", "losing" }, {
851             "luser", "laser" }, {
852             "maintanence", "maintenance" }, {
853             "mandelbrot", "Mandelbrot" }, {
854             "marshall", "marshal" }, {
855             "maxium", "maximum" }, {
856             "mic", "mike" }, {
857             "midia", "media" }, {
858             "millenium", "millennium" }, {
859             "miniscule", "minuscule" }, {
860             "minkay", "monkey" }, {
861             "mischievious", "mischievous" }, {
862             "momento", "memento" }, {
863             "monkay", "monkey" }, {
864             "mosaik", "mosaic" }, {
865             "mostlikely", "most likely" }, {
866             "mousr", "mouser" }, {
867             "mroe", "more" }, {
868             "necesary", "necessary" }, {
869             "necesser", "necessary" }, {
870             "neice", "niece" }, {
871             "neighbour", "neighbor" }, {
872             "nemonic", "pneumonic" }, {
873             "nevade", "Nevada" }, {
874             "nickleodeon", "nickelodeon" }, {
875             "nieve", "naive" }, {
876             "noone", "no one" }, {
877             "notin", "not in" }, {
878             "nozled", "nuzzled" }, {
879             "objectsion", "objects" }, {
880             "ocassion", "occasion" }, {
881             "occuppied", "occupied" }, {
882             "occurence", "occurrence" }, {
883             "octagenarian", "octogenarian" }, {
884             "opposim", "opossum" }, {
885             "organise", "organize" }, {
886             "organiz", "organize" }, {
887             "orientate", "orient" }, {
888             "oscilascope", "oscilloscope" }, {
889             "parametic", "parameter" }, {
890             "permissable", "permissible" }, {
891             "permmasivie", "permissive" }, {
892             "persue", "pursue" }, {
893             "phantasia", "fantasia" }, {
894             "phenominal", "phenomenal" }, {
895             "playwrite", "playwright" }, {
896             "poeses", "poesies" }, {
897             "poligamy", "polygamy" }, {
898             "politict", "politic" }, {
899             "pollice", "police" }, {
900             "polypropalene", "polypropylene" }, {
901             "possable", "possible" }, {
902             "practicle", "practical" }, {
903             "pragmaticism", "pragmatism" }, {
904             "preceeding", "preceding" }, {
905             "precios", "precision" }, {
906             "preemptory", "peremptory" }, {
907             "prefixt", "prefixed" }, {
908             "presbyterian", "Presbyterian" }, {
909             "presue", "pursue" }, {
910             "presued", "pursued" }, {
911             "privielage", "privilege" }, {
912             "priviledge", "privilege" }, {
913             "proceedures", "procedures" }, {
914             "pronensiation", "pronunciation" }, {
915             "pronounciation", "pronunciation" }, {
916             "properally", "properly" }, {
917             "proplematic", "problematic" }, {
918             "protray", "portray" }, {
919             "pscolgst", "psychologist" }, {
920             "psicolagest", "psychologist" }, {
921             "psycolagest", "psychologist" }, {
922             "quoz", "quiz" }, {
923             "radious", "radius" }, {
924             "reccomend", "recommend" }, {
925             "reccona", "raccoon" }, {
926             "recieve", "receive" }, {
927             "reconise", "recognize" }, {
928             "rectangeles", "rectangle" }, {
929             "reoccurring", "recurring" }, {
930             "repitition", "repetition" }, {
931             "replasments", "replacement" }, {
932             "respct", "respect" }, {
933             "respecally", "respectfully" }, {
934             "rsx", "RSX" }, {
935             "runnung", "running" }, {
936             "sacreligious", "sacrilegious" }, {
937             "salut", "salute" }, {
938             "searcheable", "searchable" }, {
939             "seferal", "several" }, {
940             "segements", "segments" }, {
941             "sence", "sense" }, {
942             "seperate", "separate" }, {
943             "sicolagest", "psychologist" }, {
944             "sieze", "seize" }, {
945             "simplye", "simply" }, {
946             "sitte", "site" }, {
947             "slyph", "sylph" }, {
948             "smil", "smile" }, {
949             "sometmes", "sometimes" }, {
950             "soonec", "sonic" }, {
951             "specificialy", "specifically" }, {
952             "spel", "spell" }, {
953             "spoak", "spoke" }, {
954             "sponsered", "sponsored" }, {
955             "stering", "steering" }, {
956             "straightjacket", "straitjacket" }, {
957             "stumach", "stomach" }, {
958             "stutent", "student" }, {
959             "styleguide", "style guide" }, {
960             "subpena", "subpoena" }, {
961             "substations", "substitutions" }, {
962             "supercede", "supersede" }, {
963             "superfulous", "superfluous" }, {
964             "susan", "Susan" }, {
965             "swimwear", "swim wear" }, {
966             "syncorization", "synchronization" }, {
967             "taff", "tough" }, {
968             "taht", "that" }, {
969             "tattos", "tattoos" }, {
970             "techniquely", "technically" }, {
971             "teh", "the" }, {
972             "tem", "team" }, {
973             "teo", "two" }, {
974             "teridical", "theoretical" }, {
975             "tesst", "test" }, {
976             "theridically", "theoretical" }, {
977             "thredically", "theoretically" }, {
978             "thruout", "throughout" }, {
979             "ths", "this" }, {
980             "titalate", "titillate" }, {
981             "tobagan", "tobaggon" }, {
982             "tommorrow", "tomorrow" }, {
983             "tomorow", "tomorrow" }, {
984             "trubbel", "trouble" }, {
985             "ttest", "test" }, {
986             "tyrrany", "tyranny" }, {
987             "unatourral", "unnatural" }, {
988             "unaturral", "unnatural" }, {
989             "unconisitional", "unconstitutional" }, {
990             "unconscience", "unconscious" }, {
991             "underladder", "under ladder" }, {
992             "unentelegible", "unintelligible" }, {
993             "unfortunently", "unfortunately" }, {
994             "unnaturral", "unnatural" }, {
995             "upcast", "up cast" }, {
996             "verison", "version" }, {
997             "vinagarette", "vinaigrette" }, {
998             "volunteerism", "voluntarism" }, {
999             "volye", "volley" }, {
1000             "waite", "wait" }, {
1001             "wan't", "won't" }, {
1002             "warloord", "warlord" }, {
1003             "whaaat", "what" }, {
1004             "whard", "ward" }, {
1005             "whimp", "wimp" }, {
1006             "wicken", "weaken" }, {
1007             "wierd", "weird" }, {
1008             "wrank", "rank" }, {
1009             "writeen", "righten" }, {
1010             "writting", "writing" }, {
1011             "wundeews", "windows" }, {
1012             "yeild", "yield" }, };
1013 
1014     static Stream<Arguments> matchingNames() {
1015         validateFixture(MATCHES);
1016         return Stream.of(MATCHES).map(pair -> Arguments.of(pair[0], pair[1]));
1017     }
1018 
1019     private static void validateFixture(final String[][] pairs) {
1020         if (pairs.length == 0) {
1021             fail("Test fixture is empty");
1022         }
1023         for (int i = 0; i < pairs.length; i++) {
1024             if (pairs[i].length != 2) {
1025                 fail("Error in test fixture in the data array at index " + i);
1026             }
1027         }
1028     }
1029 
1030     /**
1031      * Tests encoding APIs in one place.
1032      */
1033     private void assertDoubleMetaphone(final String expected, final String source) {
1034         assertEquals(expected, getStringEncoder().encode(source));
1035         try {
1036             assertEquals(expected, getStringEncoder().encode((Object) source));
1037         } catch (final EncoderException e) {
1038             fail("Unexpected exception: " + e);
1039         }
1040         assertEquals(expected, getStringEncoder().doubleMetaphone(source));
1041         assertEquals(expected, getStringEncoder().doubleMetaphone(source, false));
1042     }
1043 
1044     /**
1045      * Tests encoding APIs in one place.
1046      */
1047     private void assertDoubleMetaphoneAlt(final String expected, final String source) {
1048         assertEquals(expected, getStringEncoder().doubleMetaphone(source, true));
1049     }
1050 
1051     @Override
1052     protected DoubleMetaphone createStringEncoder() {
1053         return new DoubleMetaphone();
1054     }
1055 
1056     private void doubleMetaphoneEqualTest(final String[][] pairs, final boolean useAlternate) {
1057         validateFixture(pairs);
1058         for (final String[] pair : pairs) {
1059             final String name0 = pair[0];
1060             final String name1 = pair[1];
1061             final String failMsg = "Expected match between " + name0 + " and " + name1 + " (use alternate: " + useAlternate + ")";
1062             assertTrue(getStringEncoder().isDoubleMetaphoneEqual(name0, name1, useAlternate), failMsg);
1063             assertTrue(getStringEncoder().isDoubleMetaphoneEqual(name1, name0, useAlternate), failMsg);
1064             if (!useAlternate) {
1065                 assertTrue(getStringEncoder().isDoubleMetaphoneEqual(name0, name1), failMsg);
1066                 assertTrue(getStringEncoder().isDoubleMetaphoneEqual(name1, name0), failMsg);
1067             }
1068         }
1069     }
1070 
1071     private void doubleMetaphoneNotEqualTest(final boolean alternate) {
1072         assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Brain", "Band", alternate));
1073         assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Band", "Brain", alternate));
1074 
1075         if (!alternate) {
1076             assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Brain", "Band"));
1077             assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Band", "Brain"));
1078         }
1079     }
1080 
1081     @Test
1082     void testCCedilla() {
1083         assertTrue(getStringEncoder().isDoubleMetaphoneEqual("\u00e7", "S")); // c-cedilla
1084     }
1085 
1086     @Test
1087     void testCodec184() {
1088         assertTrue(new DoubleMetaphone().isDoubleMetaphoneEqual("", "", false));
1089         assertTrue(new DoubleMetaphone().isDoubleMetaphoneEqual("", "", true));
1090         assertFalse(new DoubleMetaphone().isDoubleMetaphoneEqual("aa", "", false));
1091         assertFalse(new DoubleMetaphone().isDoubleMetaphoneEqual("aa", "", true));
1092         assertFalse(new DoubleMetaphone().isDoubleMetaphoneEqual("", "aa", false));
1093         assertFalse(new DoubleMetaphone().isDoubleMetaphoneEqual("", "aa", true));
1094     }
1095 
1096     @Test
1097     void testCodec320() {
1098         assertTrue(new DoubleMetaphone().isDoubleMetaphoneEqual("ANGHELINA", "ANKL", false));
1099     }
1100 
1101     @Test
1102     void testDoubleMetaphone() {
1103         assertDoubleMetaphone("TSTN", "testing");
1104         assertDoubleMetaphone("0", "The");
1105         assertDoubleMetaphone("KK", "quick");
1106         assertDoubleMetaphone("PRN", "brown");
1107         assertDoubleMetaphone("FKS", "fox");
1108         assertDoubleMetaphone("JMPT", "jumped");
1109         assertDoubleMetaphone("AFR", "over");
1110         assertDoubleMetaphone("0", "the");
1111         assertDoubleMetaphone("LS", "lazy");
1112         assertDoubleMetaphone("TKS", "dogs");
1113         assertDoubleMetaphone("MKFR", "MacCafferey");
1114         assertDoubleMetaphone("STFN", "Stephan");
1115         assertDoubleMetaphone("KSSK", "Kuczewski");
1116         assertDoubleMetaphone("MKLL", "McClelland");
1117         assertDoubleMetaphone("SNHS", "san jose");
1118         assertDoubleMetaphone("SNFP", "xenophobia");
1119 
1120         assertDoubleMetaphoneAlt("TSTN", "testing");
1121         assertDoubleMetaphoneAlt("T", "The");
1122         assertDoubleMetaphoneAlt("KK", "quick");
1123         assertDoubleMetaphoneAlt("PRN", "brown");
1124         assertDoubleMetaphoneAlt("FKS", "fox");
1125         assertDoubleMetaphoneAlt("AMPT", "jumped");
1126         assertDoubleMetaphoneAlt("AFR", "over");
1127         assertDoubleMetaphoneAlt("T", "the");
1128         assertDoubleMetaphoneAlt("LS", "lazy");
1129         assertDoubleMetaphoneAlt("TKS", "dogs");
1130         assertDoubleMetaphoneAlt("MKFR", "MacCafferey");
1131         assertDoubleMetaphoneAlt("STFN", "Stephan");
1132         assertDoubleMetaphoneAlt("KXFS", "Kutchefski");
1133         assertDoubleMetaphoneAlt("MKLL", "McClelland");
1134         assertDoubleMetaphoneAlt("SNHS", "san jose");
1135         assertDoubleMetaphoneAlt("SNFP", "xenophobia");
1136         assertDoubleMetaphoneAlt("FKR", "Fokker");
1137         assertDoubleMetaphoneAlt("AK", "Joqqi");
1138         assertDoubleMetaphoneAlt("HF", "Hovvi");
1139         assertDoubleMetaphoneAlt("XRN", "Czerny");
1140     }
1141 
1142     @Test
1143     void testEmpty() {
1144         assertNull(getStringEncoder().doubleMetaphone(null));
1145         assertNull(getStringEncoder().doubleMetaphone(""));
1146         assertNull(getStringEncoder().doubleMetaphone(" "));
1147         assertNull(getStringEncoder().doubleMetaphone("\t\n\r "));
1148     }
1149 
1150     @Test
1151     void testIsDoubleMetaphoneEqualBasic() {
1152         final String[][] testFixture = { {
1153                 "", "" }, {
1154                 "Case", "case" }, {
1155                 "CASE", "Case" }, {
1156                 "caSe", "cAsE" }, {
1157                 "cookie", "quick" }, {
1158                 "quick", "cookie" }, {
1159                 "Brian", "Bryan" }, {
1160                 "Auto", "Otto" }, {
1161                 "Steven", "Stefan" }, {
1162                 "Philipowitz", "Filipowicz" }
1163         };
1164         doubleMetaphoneEqualTest(testFixture, false);
1165         doubleMetaphoneEqualTest(testFixture, true);
1166     }
1167 
1168     /**
1169      * Example in the original article but failures in this Java impl:
1170      */
1171     @Test
1172     void testIsDoubleMetaphoneEqualExtended1() {
1173         //        String[][] testFixture = new String[][] { { "Smith", "Schmidt" }
1174         //        };
1175         //        doubleMetaphoneEqualTest(testFixture, false);
1176         //        doubleMetaphoneEqualTest(testFixture, true);
1177     }
1178 
1179     @Test
1180     void testIsDoubleMetaphoneEqualExtended2() {
1181         final String[][] testFixture = { { "Jablonski", "Yablonsky" }
1182         };
1183         //doubleMetaphoneEqualTest(testFixture, false);
1184         doubleMetaphoneEqualTest(testFixture, true);
1185     }
1186 
1187     /**
1188      * Used to generate the MATCHES array and test possible matches from the
1189      * FIXTURE array.
1190      */
1191     @Test
1192     void testIsDoubleMetaphoneEqualExtended3() {
1193         validateFixture(FIXTURE);
1194         final StringBuilder failures = new StringBuilder();
1195         final StringBuilder matches = new StringBuilder();
1196         final String cr = System.lineSeparator();
1197         matches.append("private static final String[][] MATCHES = {" + cr);
1198         int failCount = 0;
1199         for (int i = 0; i < FIXTURE.length; i++) {
1200             final String name0 = FIXTURE[i][0];
1201             final String name1 = FIXTURE[i][1];
1202             final boolean match1 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
1203             final boolean match2 = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
1204             if (!match1 && !match2) {
1205                 final String failMsg = "[" + i + "] " + name0 + " and " + name1 + cr;
1206                 failures.append(failMsg);
1207                 failCount++;
1208             } else {
1209                 matches.append("{\"" + name0 + "\", \"" + name1 + "\"}," + cr);
1210             }
1211         }
1212         matches.append("};");
1213         // Turn on to print a new MATCH array
1214         //System.out.println(matches.toString());
1215         if (failCount > 0) {
1216             // Turn on to see which pairs do NOT match.
1217             // String msg = failures.toString();
1218             //fail(failCount + " failures out of " + FIXTURE.length + ". The
1219             // following could be made to match: " + cr + msg);
1220         }
1221     }
1222 
1223     @ParameterizedTest(name = "[{index}] {0}, {1}")
1224     @MethodSource("matchingNames")
1225     void testIsDoubleMetaphoneEqualWithMATCHES(final String name0, final String name1) {
1226         final boolean primaryMatch = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
1227         final boolean alternateMatch = getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
1228         assertTrue(primaryMatch || alternateMatch, "Expected a primary or alternate match");
1229     }
1230 
1231     @Test
1232     void testIsDoubleMetaphoneNotEqual() {
1233         doubleMetaphoneNotEqualTest(false);
1234         doubleMetaphoneNotEqualTest(true);
1235     }
1236 
1237     @Test
1238     void testNTilde() {
1239         assertTrue(getStringEncoder().isDoubleMetaphoneEqual("\u00f1", "N")); // n-tilde
1240     }
1241 
1242     /**
1243      * Test setting maximum length
1244      */
1245     @Test
1246     void testSetMaxCodeLength() {
1247         final String value = "jumped";
1248 
1249         final DoubleMetaphone doubleMetaphone = new DoubleMetaphone();
1250 
1251         // Sanity check of default settings
1252         assertEquals(4, doubleMetaphone.getMaxCodeLen(), "Default Max Code Length");
1253         assertEquals("JMPT", doubleMetaphone.doubleMetaphone(value, false), "Default Primary");
1254         assertEquals("AMPT", doubleMetaphone.doubleMetaphone(value, true), "Default Alternate");
1255 
1256         // Check setting Max Code Length
1257         doubleMetaphone.setMaxCodeLen(3);
1258         assertEquals(3, doubleMetaphone.getMaxCodeLen(), "Set Max Code Length");
1259         assertEquals("JMP", doubleMetaphone.doubleMetaphone(value, false), "Max=3 Primary");
1260         assertEquals("AMP", doubleMetaphone.doubleMetaphone(value, true), "Max=3 Alternate");
1261     }
1262 }