public static TreeMap<String, CoreDictionary.Attribute> loadDictionary(String... pathArray) throws IOException
    {
        TreeMap<String, CoreDictionary.Attribute> map = new TreeMap<String, CoreDictionary.Attribute>();
        for (String path : pathArray)
        {
            File file = new File(path);
            String fileName = file.getName();
            int natureIndex = fileName.lastIndexOf(' ');
            Nature defaultNature = Nature.n;
            if (natureIndex > 0)
            {
                String natureString = fileName.substring(natureIndex + 1);
                path = file.getParent() + File.separator + fileName.substring(0, natureIndex);
                if (natureString.length() > 0 && !natureString.endsWith(".txt") && !natureString.endsWith(".csv"))
                {
                    defaultNature = Nature.create(natureString);
                }
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(IOUtil.newInputStream(path), "UTF-8"));
            loadDictionary(br, map, path.endsWith(".csv"), defaultNature);
        }

        return map;
    }
public static TreeMap < String , CoreDictionary . Attribute > loadDictionary ( String ... pathArray ) throws IOException { TreeMap < String , CoreDictionary . Attribute > map = new TreeMap < String , CoreDictionary . Attribute > ( ) ; for ( String path : pathArray ) { File file = new File ( path ) ; String fileName = file . getName ( ) ; int natureIndex = fileName . lastIndexOf ( ' ' ) ; Nature defaultNature = Nature . n ; if ( natureIndex > 0 ) { String natureString = fileName . substring ( natureIndex + 1 ) ; path = file . getParent ( ) + File . separator + fileName . substring ( 0 , natureIndex ) ; if ( natureString . length ( ) > 0 && ! natureString . endsWith ( ".txt" ) && ! natureString . endsWith ( ".csv" ) ) { defaultNature = Nature . create ( natureString ) ; } } BufferedReader br = new BufferedReader ( new InputStreamReader ( IOUtil . newInputStream ( path ) , "UTF-8" ) ) ; loadDictionary ( br , map , path . endsWith ( ".csv" ) , defaultNature ) ; } return map ; }
加载词典，词典必须遵守HanLP核心词典格式
@param pathArray 词典路径，可以有任意个。每个路径支持用空格表示默认词性，比如“全国地名大全.txt ns”
@return 一个储存了词条的map
@throws IOException 异常表示加载失败