Java String Accent getDeAccentLoweredChars(String word)

Here you can find the source of getDeAccentLoweredChars(String word)

Description

get De Accent Lowered Chars

License

Apache License

Declaration

public static char[] getDeAccentLoweredChars(String word) 

Method Source Code

//package com.java2s;
/**//  w w  w.j  av a2  s  .c  o m
   * 
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
   * 
   * @author Wei Zhang,  Language Technology Institute, School of Computer Science, Carnegie-Mellon University.
   * email: wei.zhang@cs.cmu.edu
   * 
   */

import java.text.Normalizer;

import java.util.regex.Pattern;

public class Main {
    static Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");

    public static char[] getDeAccentLoweredChars(String word) {
        char[] chars = deAccent(word.toLowerCase()).toCharArray();
        return chars;
    }

    /**
       * Strip the accent of the Spanish characters.
       */

    public static String deAccent(String str) {
        String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
        return pattern.matcher(nfdNormalizedString).replaceAll("");
    }

    public static String[] replaceAll(String[] toks, String string, String string2) {
        // TODO Auto-generated method stub
        for (int i = 0; i < toks.length; i++) {
            toks[i] = toks[i].replaceAll(string, string2).trim();
        }
        return toks;
    }
}

Related

  1. deleteAccents(String text)
  2. equalsIgnoreAccents(String lhs, String rhs, Locale locale)
  3. equalsIgnoreAccentsAndCase(String s1, String s2)
  4. equalsIgnoreCaseAndAccent(String string1, String string2, Locale locale)
  5. equalsStringIgnoringAccents(String str1, String str2)
  6. normalizeByRemovingAccent(final String string)
  7. removeAccent(String s)
  8. removeAccent(String s)
  9. removeAccent(String strIn)