-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTireNode.java
More file actions
67 lines (56 loc) · 1.66 KB
/
TireNode.java
File metadata and controls
67 lines (56 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nlp;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author quincy1994
*/
public class TireNode {
private String character; // 单个汉字
private int frequency = -1; // 词频, -1来区别某条路径上的字串是否是一个词组
private double antilog = -1; // 对数化的词频
private Map<String, TireNode> children; //下一个节点
public String getCharacter(){
return character;
}
public void setCharacter(String character){
this.character = character;
}
public int getFrequency(){
return frequency;
}
public void setFrequency(int frequency){
this.frequency = frequency;
}
public double getAntilog(){
return antilog;
}
public void setAntilog(double antilog){
this.antilog = antilog;
}
public void addChild(TireNode node){
if (children == null){
children = new HashMap<String, TireNode>();
}
if (!children.containsKey(node.getCharacter())){
children.put(node.getCharacter(), node);
}
}
public TireNode getChild(String ch){
if (children == null || ! children.containsKey(ch)){
return null;
}
return children.get(ch);
}
public void removeChildren(String ch){
if (children == null || !children.containsKey(ch)){
return;
}
children.remove(ch);
}
}