public class MatchRatingApproachEncoder extends Object implements StringEncoder
Modifier and Type | Field and Description |
---|---|
private static String[] |
DOUBLE_CONSONANT |
private static int |
EIGHT
Constants used mainly for the min rating value.
|
private static int |
ELEVEN
Constants used mainly for the min rating value.
|
private static String |
EMPTY |
private static int |
FIVE
Constants used mainly for the min rating value.
|
private static int |
FOUR
Constants used mainly for the min rating value.
|
private static int |
ONE
Constants used mainly for the min rating value.
|
private static String |
PLAIN_ASCII
The plain letter equivalent of the accented letters.
|
private static int |
SEVEN
Constants used mainly for the min rating value.
|
private static int |
SIX
Constants used mainly for the min rating value.
|
private static String |
SPACE |
private static int |
THREE
Constants used mainly for the min rating value.
|
private static int |
TWELVE
Constants used mainly for the min rating value.
|
private static int |
TWO
Constants used mainly for the min rating value.
|
private static String |
UNICODE
Unicode characters corresponding to various accented letters.
|
Constructor and Description |
---|
MatchRatingApproachEncoder() |
Modifier and Type | Method and Description |
---|---|
(package private) String |
cleanName(String name)
Cleans up a name: 1.
|
Object |
encode(Object pObject)
Encodes an Object using the Match Rating Approach algorithm.
|
String |
encode(String name)
Encodes a String using the Match Rating Approach (MRA) algorithm.
|
(package private) String |
getFirst3Last3(String name)
Gets the first & last 3 letters of a name (if > 6 characters) Else just returns the name.
|
(package private) int |
getMinRating(int sumLength)
Obtains the min rating of the length sum of the 2 names.
|
boolean |
isEncodeEquals(String name1,
String name2)
Determines if two names are homophonous via Match Rating Approach (MRA) algorithm.
|
(package private) boolean |
isVowel(String letter)
Determines if a letter is a vowel.
|
(package private) int |
leftToRightThenRightToLeftProcessing(String name1,
String name2)
Processes the names from left to right (first) then right to left removing identical letters in same positions.
|
(package private) String |
removeAccents(String accentedWord)
Removes accented letters and replaces with non-accented ascii equivalent Case is preserved.
|
(package private) String |
removeDoubleConsonants(String name)
Replaces any double consonant pair with the single letter equivalent.
|
(package private) String |
removeVowels(String name)
Deletes all vowels unless the vowel begins the word.
|
private static final String SPACE
private static final String EMPTY
private static final int ONE
private static final int TWO
private static final int THREE
private static final int FOUR
private static final int FIVE
private static final int SIX
private static final int SEVEN
private static final int EIGHT
private static final int ELEVEN
private static final int TWELVE
private static final String PLAIN_ASCII
private static final String UNICODE
private static final String[] DOUBLE_CONSONANT
public MatchRatingApproachEncoder()
String cleanName(String name)
Consider this method private, it is package protected for unit testing only.
name
- The name to be cleanedpublic final Object encode(Object pObject) throws EncoderException
encode
in interface Encoder
pObject
- Object to encodeEncoderException
- if the parameter supplied is not of type java.lang.Stringpublic final String encode(String name)
encode
in interface StringEncoder
name
- String object to encodeString getFirst3Last3(String name)
Consider this method private, it is package protected for unit testing only.
name
- The string to get the substrings fromint getMinRating(int sumLength)
Consider this method private, it is package protected for unit testing only.
sumLength
- The length of 2 strings sent downpublic boolean isEncodeEquals(String name1, String name2)
encode(String)
.name1
- First of the 2 strings (names) to comparename2
- Second of the 2 names to comparetrue
if the encodings are identical false
otherwise.boolean isVowel(String letter)
Consider this method private, it is package protected for unit testing only.
letter
- The letter under investiagtionint leftToRightThenRightToLeftProcessing(String name1, String name2)
Consider this method private, it is package protected for unit testing only.
name1
- name2String removeAccents(String accentedWord)
accentedWord
- The word that may have accents in it.String removeDoubleConsonants(String name)
Consider this method private, it is package protected for unit testing only.
name
- String to have double consonants removedString removeVowels(String name)
Consider this method private, it is package protected for unit testing only.
name
- The name to have vowels removedWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses