Skip to content

Commit

Permalink
统一使用logger输出错误信息
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Jan 9, 2017
1 parent f0516cf commit c748819
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/hankcs/hanlp/HanLP.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static final class Config
}
catch (Exception e)
{
StringBuilder sbInfo = new StringBuilder("========Tips========\n请将HanLP.properties放在下列目录:\n"); // 打印一些友好的tips
StringBuilder sbInfo = new StringBuilder("========Tips========\n请将hanlp.properties放在下列目录:\n"); // 打印一些友好的tips
String classPath = (String) System.getProperties().get("java.class.path");
if (classPath != null)
{
Expand All @@ -292,7 +292,7 @@ public static final class Config
"JRE/lib\n");
sbInfo.append("并且编辑root=PARENT/path/to/your/data\n");
sbInfo.append("现在HanLP将尝试从").append(System.getProperties().get("user.dir")).append("读取data……");
logger.severe("没有找到HanLP.properties,可能会导致找不到data\n" + sbInfo);
logger.severe("没有找到hanlp.properties,可能会导致找不到data\n" + sbInfo);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CoreDictionary
long start = System.currentTimeMillis();
if (!load(path))
{
System.err.printf("核心词典%s加载失败\n", path);
logger.severe("核心词典" + path + "加载失败");
System.exit(-1);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CoreDictionaryTransformMatrixDictionary
long start = System.currentTimeMillis();
if (!transformMatrixDictionary.load(HanLP.Config.CoreDictionaryTransformMatrixDictionaryPath))
{
System.err.println("加载核心词典词性转移矩阵" + HanLP.Config.CoreDictionaryTransformMatrixDictionaryPath + "失败");
logger.severe("加载核心词典词性转移矩阵" + HanLP.Config.CoreDictionaryTransformMatrixDictionaryPath + "失败");
System.exit(-1);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CoreSynonymDictionary
}
catch (Exception e)
{
System.err.println("载入核心同义词词典失败" + e);
logger.severe("载入核心同义词词典失败" + e);
System.exit(-1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CoreSynonymDictionaryEx
}
catch (Exception e)
{
System.err.println("载入核心同义词词典失败" + e);
logger.severe("载入核心同义词词典失败" + e);
System.exit(-1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class PersonDictionary
dictionary = new NRDictionary();
if (!dictionary.load(HanLP.Config.PersonDictionaryPath))
{
System.err.println("人名词典加载失败:" + HanLP.Config.PersonDictionaryPath);
logger.severe("人名词典加载失败:" + HanLP.Config.PersonDictionaryPath);
System.exit(-1);
}
transformMatrixDictionary = new TransformMatrixDictionary<NR>(NR.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class CharType
ByteArray byteArray = ByteArray.createByteArray(HanLP.Config.CharTypePath);
if (byteArray == null)
{
System.err.println("字符类型对应表加载失败:" + HanLP.Config.CharTypePath);
logger.severe("字符类型对应表加载失败:" + HanLP.Config.CharTypePath);
System.exit(-1);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.ListIterator;
import static com.hankcs.hanlp.utility.Predefine.logger;


/**
Expand All @@ -46,7 +46,7 @@ public class CoreStopWordDictionary
}
catch (Exception e)
{
System.err.println("载入停用词词典" + HanLP.Config.CoreStopWordDictionaryPath + "失败" + TextUtility.exceptionToString(e));
logger.severe("载入停用词词典" + HanLP.Config.CoreStopWordDictionaryPath + "失败" + TextUtility.exceptionToString(e));
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected List<Term> segSentence(char[] sentence)
{
if (trie == null)
{
System.err.println("还未加载任何词典");
logger.warning("还未加载任何词典");
return Collections.emptyList();
}
final int[] wordNet = new int[sentence.length];
Expand Down

0 comments on commit c748819

Please sign in to comment.