/ictclas4j/src/org/ictclas4j/bean/Pos.java

http://ictclas4j.googlecode.com/ · Java · 96 lines · 69 code · 20 blank · 7 comment · 4 complexity · f73c3fe8a061211d36c4ad4e0e08882a MD5 · raw file

  1. package org.ictclas4j.bean;
  2. import java.io.DataInputStream;
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5. import java.io.Serializable;
  6. /**
  7. * ??
  8. *
  9. * @author sinboy
  10. * @since 2008.6.4
  11. *
  12. */
  13. public class Pos implements Cloneable, Serializable {
  14. private int tag;// ????4?????????????????ASCII??????POSTag
  15. private int freq;// ??
  16. private boolean isVisible;// ??????????????????????
  17. private static final long serialVersionUID = 10000L;
  18. public Pos() {
  19. }
  20. public Pos(int tag, int freq, boolean isVisible) {
  21. this.tag = tag;
  22. this.freq = freq;
  23. this.isVisible = isVisible;
  24. }
  25. public int read(DataInputStream in) throws IOException {
  26. int offset = 0;
  27. if (in != null) {
  28. tag = in.readInt();
  29. freq = in.readInt();
  30. offset += 8;
  31. }
  32. return offset;
  33. }
  34. public int write(DataOutputStream out) throws IOException {
  35. int offset = 0;
  36. if (out != null) {
  37. out.writeInt(tag);
  38. out.writeInt(freq);
  39. offset += 8;
  40. }
  41. return offset;
  42. }
  43. public int getTag() {
  44. return tag;
  45. }
  46. public void setTag(int tag) {
  47. this.tag = tag;
  48. }
  49. public int getFreq() {
  50. return freq;
  51. }
  52. public void setFreq(int freq) {
  53. this.freq = freq;
  54. }
  55. public boolean isVisible() {
  56. return isVisible;
  57. }
  58. public void setVisible(boolean isVisible) {
  59. this.isVisible = isVisible;
  60. }
  61. public String toString() {
  62. StringBuffer sb = new StringBuffer();
  63. sb.append(POSTag.int2str(tag));
  64. return sb.toString();
  65. }
  66. public String toString2() {
  67. StringBuffer sb = new StringBuffer();
  68. sb.append(POSTag.int2str(tag));
  69. sb.append(",").append(freq);
  70. sb.append(",").append(isVisible ? 1 : 0);
  71. return sb.toString();
  72. }
  73. public Pos clone() throws CloneNotSupportedException {
  74. return (Pos) super.clone();
  75. }
  76. }