Skip to content

Commit

Permalink
fix user dict load.
Browse files Browse the repository at this point in the history
  • Loading branch information
piaolingxue committed Sep 2, 2013
1 parent 3a0de75 commit 9534a78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions conf/jieba/user.dict → conf/user.dict
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
显瘦 3
又拍云 3
iphone 3
鲜芋仙 3
12 changes: 6 additions & 6 deletions src/main/java/com/huaban/analysis/jieba/WordDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
public class WordDictionary {
private static WordDictionary singleInstance;
private static final String MAIN_DICT = "/dict.txt";
private static String SOUGOU_DICT = "jieba/sougou.dict";
private static String USER_DICT = "jieba/user.dict";
private static String USER_DICT_SUFFIX = ".dict";

public final TrieNode trie = new TrieNode();
public final Map<String, Double> freqs = new HashMap<String, Double>();
Expand All @@ -42,10 +41,11 @@ public synchronized static WordDictionary getInstance() {
*/
public synchronized void init(File configFile) {
if (!isLoaded) {
File sougouDict = new File(configFile, SOUGOU_DICT);
File userDict = new File(configFile, USER_DICT);
singleInstance.loadUserDict(sougouDict);
singleInstance.loadUserDict(userDict);
for (File userDict : configFile.listFiles()) {
if (userDict.getPath().endsWith(USER_DICT_SUFFIX)) {
singleInstance.loadUserDict(userDict);
}
}
isLoaded = true;
}
}
Expand Down

0 comments on commit 9534a78

Please sign in to comment.