Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 33EBE6A25 for ; Sat, 6 Aug 2011 16:51:40 +0000 (UTC) Received: (qmail 89943 invoked by uid 500); 6 Aug 2011 16:51:39 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 89862 invoked by uid 500); 6 Aug 2011 16:51:39 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 89855 invoked by uid 99); 6 Aug 2011 16:51:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Aug 2011 16:51:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Aug 2011 16:51:37 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0AAC823889ED for ; Sat, 6 Aug 2011 16:51:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1154541 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java Date: Sat, 06 Aug 2011 16:51:17 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110806165118.0AAC823889ED@eris.apache.org> Author: ggregory Date: Sat Aug 6 16:51:17 2011 New Revision: 1154541 URL: http://svn.apache.org/viewvc?rev=1154541&view=rev Log: [CODEC-125] Implement a Beider-Morse phonetic matching codec. Apply Matthew's patch https://issues.apache.org/jira/secure/attachment/12489569/fixmeInvariant.patch. This patch hoists the l-invariant code out of the loop over l. The d'ortley test input string exercises this branch. The "van helsing" input string should be exercising the alternate branch. Thank you MP! Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java?rev=1154541&r1=1154540&r2=1154541&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java Sat Aug 6 16:51:17 2011 @@ -287,6 +287,11 @@ public class PhoneticEngine { input = input.toLowerCase(Locale.ENGLISH).replace('-', ' ').trim(); if (this.nameType == NameType.GENERIC) { + if (input.length() >= 2 && input.substring(0, 2).equals("d'")) { // check for d' + String remainder = input.substring(2); + String combined = "d" + remainder; + return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; + } for (String l : NAME_PREFIXES.get(this.nameType)) { // handle generic prefixes if (input.startsWith(l + " ")) { @@ -295,12 +300,6 @@ public class PhoneticEngine { String combined = l + remainder; // input with prefix without space return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; } - // fixme: this case is invariant on l - else if (input.length() >= 2 && input.substring(0, 2).equals("d'")) { // check for d' - String remainder = input.substring(2); - String combined = "d" + remainder; - return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; - } } }