Skip to content

Commit

Permalink
支持禁用自动刷新词典缓存(CustomDictionaryAutoRefreshCache=false)fix #1655
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Jun 18, 2021
1 parent 61631b0 commit 8ee039b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/com/hankcs/hanlp/HanLP.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public static final class Config
* 用户自定义词典路径
*/
public static String CustomDictionaryPath[] = new String[]{"data/dictionary/custom/CustomDictionary.txt"};
/**
* 用户自定义词典是否自动重新生成缓存(根据词典文件的最后修改时间是否大于缓存文件的时间判断)
*/
public static boolean CustomDictionaryAutoRefreshCache = true;
/**
* 2元语法词典路径
*/
Expand Down Expand Up @@ -274,6 +278,7 @@ public static final class Config
}
}
CustomDictionaryPath = pathArray;
CustomDictionaryAutoRefreshCache = "true".equals(p.getProperty("CustomDictionaryAutoRefreshCache", "true"));
tcDictionaryRoot = root + p.getProperty("tcDictionaryRoot", tcDictionaryRoot);
if (!tcDictionaryRoot.endsWith("/")) tcDictionaryRoot += '/';
PinyinDictionaryPath = root + p.getProperty("PinyinDictionaryPath", PinyinDictionaryPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static boolean loadDat(String path, String customDicPath[], DoubleArrayTr
{
try
{
if (isDicNeedUpdate(path, customDicPath))
if (HanLP.Config.CustomDictionaryAutoRefreshCache && isDicNeedUpdate(path, customDicPath))
{
return false;
}
Expand Down

0 comments on commit 8ee039b

Please # to comment.