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

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

package org.rx.util.pinyin;

import java.util.Map;
import java.util.Set;

/**
 * 基于{@link Map}的字典实现,利于添加自定义字典
 *
 * Created by guyacong on 2016/12/23.
 */

public abstract class PinyinMapDict implements PinyinDict {

    /**
     * Key为字典的词,Value为该词所对应的拼音
     *
     * @return 包含词和对应拼音的 {@link Map}
     */
    public abstract Map mapping();


    @Override
    public Set words() {
        return mapping() != null ? mapping().keySet() : null;
    }

    @Override
    public String[] toPinyin(String word) {
        return mapping() != null ? mapping().get(word) : null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy