Skip to content

Commit

Permalink
修复词典reload的空指针异常
Browse files Browse the repository at this point in the history
  • Loading branch information
孙健 committed Jan 5, 2017
1 parent 1b508d2 commit 0113a3c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
5 changes: 4 additions & 1 deletion library/ambiguity.dic
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
大 a 和尚 n
张三 nr 和 c
动漫 n 游戏 n
邓颖超 nr 生前 t
邓颖超 nr 生前 t



Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void main(String[] args) {

Map<String, String> map = new HashMap<String, String>();

map.put("type", TYPE.index.name());
map.put("type", "dic_ansj");
map.put(SynonymsLibrary.DEFAULT, SynonymsLibrary.DEFAULT);


Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>ansj_seg</artifactId>
<packaging>jar</packaging>
<name>ansj_seg</name>
<version>5.1.0</version>
<version>5.1.1</version>
<description>best java chinese word seg ! </description>
<url>https://github.com/NLPchina/ansj_seg</url>
<licenses>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/ansj/library/AmbiguityLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ public static KV<String, Forest> remove(String key) {
* @return
*/
public static void reload(String key) {
AMBIGUITY.get(key).setV(null);
KV<String, Forest> kv = AMBIGUITY.get(key);
if (kv != null) {
AMBIGUITY.get(key).setV(null);
}
get(key);
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/ansj/library/CrfLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;

import org.ansj.app.crf.Model;
import org.ansj.app.crf.SplitWord;
Expand Down Expand Up @@ -123,8 +123,10 @@ public static KV<String, SplitWord> remove(String key) {
* @return
*/
public static void reload(String key) {

CRF.get(key).setV(null);
KV<String, SplitWord> kv = CRF.get(key);
if (kv != null) {
CRF.get(key).setV(null);
}
get(key);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/ansj/library/DicLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ public static Set<String> keys() {
}

public static void reload(String key) {
DIC.get(key).setV(null);
KV<String, Forest> kv = DIC.get(key);
if (kv != null) {
DIC.get(key).setV(null);
}
get(key);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/ansj/library/StopLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ public static Set<String> keys() {
}

public static void reload(String key) {
STOP.get(key).setV(null);
KV<String, StopRecognition> kv = STOP.get(key);
if (kv != null) {
STOP.get(key).setV(null);
}
get(key);
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/ansj/library/SynonymsLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ public static KV<String, SmartForest<List<String>>> remove(String key) {
* @return
*/
public static void reload(String key) {

SYNONYMS.get(key).setV(null);
KV<String, SmartForest<List<String>>> kv = SYNONYMS.get(key);
if (kv != null) {
SYNONYMS.get(key).setV(null);
}
get(key);
}

Expand Down

0 comments on commit 0113a3c

Please sign in to comment.