Skip to content

Commit

Permalink
维特比分词设置默认自定义词典
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyListen committed Dec 3, 2018
1 parent 4a29ae0 commit 4b03c2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class ExtendViterbiSegment extends ViterbiSegment
public ExtendViterbiSegment()
{
super();
super.setDat(CustomDictionary.dat);
}

/**
Expand Down Expand Up @@ -100,7 +99,6 @@ private void loadCustomDic(String customPath, boolean cache)
if (map.size() == 0)
{
logger.warning("没有加载到任何词条,使用默认词典");
super.setDat(CustomDictionary.dat);
return;
}
logger.info("正在构建DoubleArrayTrie……");
Expand Down Expand Up @@ -139,7 +137,6 @@ private void loadCustomDic(String customPath, boolean cache)
catch (Exception e)
{
logger.warning("自定义词典" + customPath + "缓存失败!\n" + TextUtility.exceptionToString(e));
super.setDat(CustomDictionary.dat);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.collection.trie.DoubleArrayTrie;
import com.hankcs.hanlp.dictionary.CoreDictionary;
import com.hankcs.hanlp.dictionary.CustomDictionary;
import com.hankcs.hanlp.recognition.nr.JapanesePersonRecognition;
import com.hankcs.hanlp.recognition.nr.PersonRecognition;
import com.hankcs.hanlp.recognition.nr.TranslatedPersonRecognition;
Expand All @@ -37,6 +38,11 @@ public class ViterbiSegment extends WordBasedSegment
{
private DoubleArrayTrie<CoreDictionary.Attribute> dat = new DoubleArrayTrie<CoreDictionary.Attribute>();

public ViterbiSegment()
{
this.dat = CustomDictionary.dat;
}

public DoubleArrayTrie<CoreDictionary.Attribute> getDat()
{
return dat;
Expand Down

0 comments on commit 4b03c2b

Please sign in to comment.