commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1302191 - /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
Date Sun, 18 Mar 2012 18:13:49 GMT
Author: tn
Date: Sun Mar 18 18:13:49 2012
New Revision: 1302191

URL: http://svn.apache.org/viewvc?rev=1302191&view=rev
Log:
[CODEC-132] Make phoneme order deterministic by using a LinkedHashSet, detected as part of
the test case in lucene.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java?rev=1302191&r1=1302190&r2=1302191&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
Sun Mar 18 18:13:49 2012
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -82,10 +83,10 @@ public class PhoneticEngine {
          * Creates a new phoneme builder containing all phonemes in this one extended by
<code>str</code>.
          *
          * @param str   the characters to append to the phonemes
-         * @return  a new phoneme builder lenghened by <code>str</code>
+         * @return  a new phoneme builder lenghtened by <code>str</code>
          */
         public PhonemeBuilder append(CharSequence str) {
-            Set<Rule.Phoneme> newPhonemes = new HashSet<Rule.Phoneme>();
+            Set<Rule.Phoneme> newPhonemes = new LinkedHashSet<Rule.Phoneme>();
 
             for (Rule.Phoneme ph : this.phonemes) {
                 newPhonemes.add(ph.append(str));
@@ -106,7 +107,7 @@ public class PhoneticEngine {
          *      in turn
          */
         public PhonemeBuilder apply(Rule.PhonemeExpr phonemeExpr, int maxPhonemes) {
-            Set<Rule.Phoneme> newPhonemes = new HashSet<Rule.Phoneme>();
+            Set<Rule.Phoneme> newPhonemes = new LinkedHashSet<Rule.Phoneme>();
 
             EXPR: for (Rule.Phoneme left : this.phonemes) {
                 for (Rule.Phoneme right : phonemeExpr.getPhonemes()) {



Mime
View raw message