commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
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 GMT
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) + ")";
-                }
             }
         }
 



Mime
View raw message