package org.diagbot.nlp.util;

import org.diagbot.nlp.participle.cfg.Configuration;
import org.diagbot.nlp.participle.cfg.DefaultConfig;
import org.diagbot.nlp.participle.word.Segment;

import java.util.Map;

/**
 * @ClassName org.diagbot.nlp.util.NlpCache
 * @Description 词典库 同义词 大小类缓存
 * @Author fyeman
 * @Date 2019/1/11/011 14:04
 * @Version 1.0
 **/
public class NlpCache {
    //词典库
    public static Segment segment_cache = null;
    //推送字典
    public static Map<String, String> standard_info_push_map = null;
    //词库同义词定义
    public static Map<String, String> standard_info_synonym_map = null;
    //词库大小类定义
    public static Map<String, String> standard_info_classify_map = null;;

    public static void createSegmentCache() {
        Configuration configuration = new DefaultConfig();
        segment_cache = configuration.loadMainDict("tc.dict");
    }

    public static void createPushCache() {
        Configuration configuration = new DefaultConfig();
        standard_info_push_map = configuration.loadMapDict("push-tc.dict");
    }

    public static void createSynonymCache() {
        Configuration configuration = new DefaultConfig();
        standard_info_synonym_map = configuration.loadMapDict("synonym.dict");
    }

    public static void createClassifyCache() {
        Configuration configuration = new DefaultConfig();
        standard_info_classify_map = configuration.loadMapDict("classify.dict");
    }

    public static Segment getSegment_cache() {
        if (segment_cache == null) {
            createSegmentCache();
        }
        return segment_cache;
    }

    public static Map<String, String> getStandard_info_push_map() {
        if (standard_info_push_map == null) {
            createPushCache();
        }
        return standard_info_push_map;
    }

    public static Map<String, String> getStandard_info_synonym_map() {
        if (standard_info_synonym_map == null) {
            createSynonymCache();
        }
        return standard_info_synonym_map;
    }

    public static Map<String, String> getStandard_info_classify_map() {
        if (standard_info_classify_map == null) {
            createClassifyCache();
        }
        return standard_info_classify_map;
    }
}
