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