/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

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