Encoder
, StringEncoder
public class MatchRatingApproachEncoder extends java.lang.Object implements StringEncoder
Modifier and Type | Field | Description |
---|---|---|
private static java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String |
UNICODE |
Unicode characters corresponding to various accented letters.
|
Constructor | Description |
---|---|
MatchRatingApproachEncoder() |
Modifier and Type | Method | Description |
---|---|---|
(package private) java.lang.String |
cleanName(java.lang.String name) |
Cleans up a name: 1.
|
java.lang.Object |
encode(java.lang.Object pObject) |
Encodes an Object using the Match Rating Approach algorithm.
|
java.lang.String |
encode(java.lang.String name) |
Encodes a String using the Match Rating Approach (MRA) algorithm.
|
(package private) java.lang.String |
getFirst3Last3(java.lang.String name) |
Gets the first and 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(java.lang.String name1,
java.lang.String name2) |
Determines if two names are homophonous via Match Rating Approach (MRA) algorithm.
|
(package private) boolean |
isVowel(java.lang.String letter) |
Determines if a letter is a vowel.
|
(package private) int |
leftToRightThenRightToLeftProcessing(java.lang.String name1,
java.lang.String name2) |
Processes the names from left to right (first) then right to left removing identical letters in same positions.
|
(package private) java.lang.String |
removeAccents(java.lang.String accentedWord) |
Removes accented letters and replaces with non-accented ascii equivalent Case is preserved.
|
(package private) java.lang.String |
removeDoubleConsonants(java.lang.String name) |
Replaces any double consonant pair with the single letter equivalent.
|
(package private) java.lang.String |
removeVowels(java.lang.String name) |
Deletes all vowels unless the vowel begins the word.
|
private static final java.lang.String SPACE
private static final java.lang.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 java.lang.String PLAIN_ASCII
private static final java.lang.String UNICODE
private static final java.lang.String[] DOUBLE_CONSONANT
java.lang.String cleanName(java.lang.String name)
Consider this method private, it is package protected for unit testing only.
name
- The name to be cleanedpublic final java.lang.Object encode(java.lang.Object pObject) throws EncoderException
encode
in interface Encoder
pObject
- Object to encodeEncoderException
- if the parameter supplied is not of type java.lang.Stringpublic final java.lang.String encode(java.lang.String name)
encode
in interface StringEncoder
name
- String object to encodejava.lang.String getFirst3Last3(java.lang.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(java.lang.String name1, java.lang.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(java.lang.String letter)
Consider this method private, it is package protected for unit testing only.
letter
- The letter under investiagtionint leftToRightThenRightToLeftProcessing(java.lang.String name1, java.lang.String name2)
Consider this method private, it is package protected for unit testing only.
name1
- name2java.lang.String removeAccents(java.lang.String accentedWord)
accentedWord
- The word that may have accents in it.java.lang.String removeDoubleConsonants(java.lang.String name)
Consider this method private, it is package protected for unit testing only.
name
- String to have double consonants removedjava.lang.String removeVowels(java.lang.String name)
Consider this method private, it is package protected for unit testing only.
name
- The name to have vowels removedcommons-codec version 1.10 - Copyright © 2002-2017 - Apache Software Foundation