All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.util.pinyin.PinyinRules Maven / Gradle / Ivy

package org.rx.util.pinyin;

import java.util.HashMap;
import java.util.Map;

public final class PinyinRules {
    private final Map mOverrides = new HashMap();

    public PinyinRules add(char c, String pinyin) {
        mOverrides.put(String.valueOf(c), new String[]{pinyin});
        return this;
    }

    public PinyinRules add(String str, String pinyin) {
        mOverrides.put(str, new String[]{pinyin});
        return this;
    }

    String toPinyin(char c) {
        return mOverrides.get(String.valueOf(c))[0];
    }

    PinyinMapDict toPinyinMapDict() {
        return new PinyinMapDict() {
            @Override
            public Map mapping() {
                return mOverrides;
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy