org.ansj.dic.DicReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ansj_seg Show documentation
Show all versions of ansj_seg Show documentation
best java chinese word seg !
package org.ansj.dic;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import org.ansj.util.MyStaticValue;
import org.nlpcn.commons.lang.util.logging.Log;
/**
* 加载词典用的类
*
* @author ansj
*/
public class DicReader {
private static final Log logger = MyStaticValue.getLog() ;
public static BufferedReader getReader(String name) {
// maven工程修改词典加载方式
InputStream in = DicReader.class.getResourceAsStream("/" + name);
try {
return new BufferedReader(new InputStreamReader(in, "UTF-8"));
} catch (UnsupportedEncodingException e) {
logger.warn("不支持的编码", e);
}
return null;
}
public static InputStream getInputStream(String name) {
// maven工程修改词典加载方式
InputStream in = DicReader.class.getResourceAsStream("/" + name);
return in;
}
}