com.aliasi.dict
Class DictionaryEntry<C>

java.lang.Object
  extended by com.aliasi.dict.DictionaryEntry<C>
Type Parameters:
C - the type of object stored in the dictionary
All Implemented Interfaces:
Compilable, Scored

public class DictionaryEntry<C>
extends Object
implements Compilable, Scored

A DictionaryEntry provides a phrase as a string, an object-based category for the phrase, and a double-valued score. Equality for dictionary entries involves equality of the phrase and category components; dictionaries should not contain entries with the same phrase and category and different scores.

Since:
LingPipe2.1
Version:
3.8.3
Author:
Bob Carpenter

Field Summary
 
Fields inherited from interface com.aliasi.util.Scored
REVERSE_SCORE_COMPARATOR, SCORE_COMPARATOR
 
Constructor Summary
DictionaryEntry(String phrase, C category)
          Construct a dictionary entry with the specified phrase and category, with count and score set to 1.
DictionaryEntry(String phrase, C category, double score)
          Construct a dictionary entry with the specified phrase, category and score, with a count of zero.
DictionaryEntry(String phrase, C category, int count)
          Construct a dictionary entry with the specified phrase, category and count, with the score set to the count value.
DictionaryEntry(String phrase, C category, int count, double score)
          Construct a dictionary entry with the specified phrase, category, count and score.
 
Method Summary
 C category()
          Returns the category for this dictionary entry.
 void compileTo(ObjectOutput objOut)
          Compiles this dictionary entry to the specified object output.
 int count()
          Returns the count for this dictionary entry.
 boolean equals(Object that)
          Returns true if the specified object is a dictionary object equal to this one.
 int hashCode()
          Returns the hash code for this entry.
 String phrase()
          Returns the phrase for this dictionary entry.
 double score()
          Returns the score for this dictionary entry.
 String toString()
          Returns a string-based representation of this entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DictionaryEntry

public DictionaryEntry(String phrase,
                       C category,
                       int count,
                       double score)
Construct a dictionary entry with the specified phrase, category, count and score.

Parameters:
phrase - Phrase for the constructed entry.
category - Category for the constructed entry.
count - Count for the constructed entry.
score - Score for the constructed entry.

DictionaryEntry

public DictionaryEntry(String phrase,
                       C category,
                       double score)
Construct a dictionary entry with the specified phrase, category and score, with a count of zero.

Parameters:
phrase - Phrase for the constructed entry.
category - Category for the constructed entry.
score - Score for the constructed entry.

DictionaryEntry

public DictionaryEntry(String phrase,
                       C category,
                       int count)
Construct a dictionary entry with the specified phrase, category and count, with the score set to the count value.

Parameters:
phrase - Phrase for the constructed entry.
category - Category for the constructed entry.
count - Count for the constructed entry.

DictionaryEntry

public DictionaryEntry(String phrase,
                       C category)
Construct a dictionary entry with the specified phrase and category, with count and score set to 1.

Parameters:
phrase - Phrase for the constructed entry.
category - Category for the constructed entry.
Method Detail

phrase

public String phrase()
Returns the phrase for this dictionary entry.

Returns:
The phrase.

category

public C category()
Returns the category for this dictionary entry.

Returns:
The category.

score

public double score()
Returns the score for this dictionary entry.

Specified by:
score in interface Scored
Returns:
The score.

count

public int count()
Returns the count for this dictionary entry.

Returns:
The count for this entry.

toString

public String toString()
Returns a string-based representation of this entry.

Overrides:
toString in class Object
Returns:
A string-based representation of this entry.

equals

public boolean equals(Object that)
Returns true if the specified object is a dictionary object equal to this one. Equality is defined in terms of equality of phrases, categories, counts and scores; all must be equal for entries to be equal. Equality is defined consistently with hashCode().

Overrides:
equals in class Object
Parameters:
that - Object to compare with this entry.
Returns:
true if the sepcified object is equal to this entry.

hashCode

public int hashCode()
Returns the hash code for this entry. Hash codes are defined in terms of phrase and category hashCodes and are consistent with equals(Object).

Overrides:
hashCode in class Object
Returns:
The hash code for this entry.

compileTo

public void compileTo(ObjectOutput objOut)
               throws IOException
Compiles this dictionary entry to the specified object output. This method will throw a class-cast exception if it encounters a dictionary entry whose category object is not serializable.

Specified by:
compileTo in interface Compilable
Parameters:
objOut - Output to which object is written.
Throws:
IOException - If there is an I/O error compiling the object.