public final String encode()

in src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java [125:152]


    public final String encode(String name) {
        // Bulletproof for trivial input - NINO
        if (name == null || EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) || name.length() == 1) {
            return EMPTY;
        }

        // Preprocessing
        name = cleanName(name);

        // Bulletproof if name becomes empty after cleanName(name)
        if (SPACE.equals(name) || name.isEmpty()) {
            return EMPTY;
        }

        // BEGIN: Actual encoding part of the algorithm...
        // 1. Delete all vowels unless the vowel begins the word
        name = removeVowels(name);

        // Bulletproof if name becomes empty after removeVowels(name)
        if (SPACE.equals(name) || name.isEmpty()) {
            return EMPTY;
        }

        // 2. Remove second consonant from any double consonant
        name = removeDoubleConsonants(name);

        return getFirst3Last3(name);
    }