PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/ictclas4j/src/org/ictclas4j/bean/WordTable.java

http://ictclas4j.googlecode.com/
Java | 77 lines | 50 code | 17 blank | 10 comment | 7 complexity | 5e6520d041e70d0d802d0ccbe2a10f47 MD5 | raw file
 1package org.ictclas4j.bean;
 2
 3import java.util.HashMap;
 4
 5
 6/**
 7 * ???????????.
 8 * 
 9 * @author sinboy
10 * @since 2006.7
11 * @update 2007.12.22
12 * 
13 */
14public class WordTable implements Cloneable {
15	// ???????????
16	private int wordCount;
17
18	// ????????????
19	private int wordMaxLen;
20
21	private HashMap<String, SegAtom> wordMap;
22
23	public WordTable() {
24		wordMap = new HashMap<String, SegAtom>();
25	}
26
27	public int getWordCount() {
28		return wordCount;
29	}
30
31	public void setWordCount(int count) {
32		this.wordCount = count;
33	}
34
35	public int getWordMaxLen() {
36		return wordMaxLen;
37	}
38
39	public void setWordMaxLen(int wordMaxLen) {
40		this.wordMaxLen = wordMaxLen;
41	}
42
43	public void addSegAtom(SegAtom atom) {
44		if (atom != null) {
45			String word = atom.getWord();
46			if (word != null) {
47				SegAtom sa=wordMap.get(word);
48				atom.merge(sa);
49				wordCount++;
50				wordMap.put(word, atom);
51				if (word.length() > wordMaxLen)
52					wordMaxLen = word.length();
53			}
54		}
55	}
56
57	public SegAtom getSegAtom(String word) {
58		if (wordMap != null) {
59			return wordMap.get(word);
60		}
61
62		return null;
63	}
64
65	public HashMap<String, SegAtom> getWordMap() {
66		return wordMap;
67	}
68
69	public void setWordMap(HashMap<String, SegAtom> wordMap) {
70		this.wordMap = wordMap;
71	}
72
73	public WordTable clone() throws CloneNotSupportedException {
74		return (WordTable) super.clone();
75	}
76 
77}