001 package org.maltparser.parser.history.kbest;
002
003
004 /**
005 * A candidate in the k-best list.
006 *
007 * @author Johan Hall
008 * @since 1.1
009 */
010 public class Candidate {
011 /**
012 * The integer representation of the predicted action
013 */
014 protected int actionCode;
015
016 /**
017 * Constructs a candidate object
018 */
019 public Candidate() {
020 reset();
021 }
022
023 /**
024 * Returns an integer representation of the predicted action
025 *
026 * @return an integer representation of the predicted action
027 */
028 public int getActionCode() {
029 return actionCode;
030 }
031
032 /**
033 * Sets the integer representation of the predicted action
034 *
035 * @param actionCode an integer representation of the predicted action
036 */
037 public void setActionCode(int actionCode) {
038 this.actionCode = actionCode;
039 }
040
041 /**
042 * Resets the candidate object
043 */
044 public void reset() {
045 this.actionCode = -1;
046 }
047
048 @Override
049 public int hashCode() {
050 return 31 * 1 + actionCode;
051 }
052
053 @Override
054 public boolean equals(Object obj) {
055 if (this == obj)
056 return true;
057 if (obj == null)
058 return false;
059 if (getClass() != obj.getClass())
060 return false;
061 return actionCode == ((Candidate)obj).actionCode;
062 }
063
064 /* (non-Javadoc)
065 * @see java.lang.Object#toString()
066 */
067 public String toString() {
068 return Integer.toString(actionCode);
069 }
070 }
071