daTrie例子--工作相关

	private void initTrie() throws IOException {
		File dict = new File(home, "dict");
		Collection<File> fs =
			(Collection<File>) FileUtils.listFiles(dict, new String[] { "txt" }, false);
		Collection<String>[] cs = new Collection[fs.size()];
		int i = 0;
		for (File f : fs) {
			cs[i] = FileUtils.readLines(f, "UTF-8");
			i++;
		}
		UnionCollection<String> uc = new UnionCollection<String>(cs);
		logger.info("读取词库完毕,开始构建词典树");
		trie = new DATrie(uc);
	}

 

构造DATrie,首先从目录读出所有以txt结尾的文件(

(Collection<File>) FileUtils.listFiles(dict, new String[] { "txt" }, false);

),用apache.commons.io的FileUtils API,工作中的DATrie的构造带Collection<String>的参数。

 

你可能感兴趣的:(apache,工作,F#)