edu.stanford.nlp.ling
Class CyclicCoreLabel

java.lang.Object
  extended by edu.stanford.nlp.util.ArrayCoreMap
      extended by edu.stanford.nlp.ling.CoreLabel
          extended by edu.stanford.nlp.ling.CyclicCoreLabel
All Implemented Interfaces:
HasCategory, HasContext, HasIndex, HasTag, HasWord, Label, CoreMap, TypesafeMap<CoreMap>, Serializable

public class CyclicCoreLabel
extends CoreLabel

Version of CoreLabel that allows for cycles in values/keys. Equals is defined as object equality, hashcode is defined on object address, and toString will not print cycles. TODO: This class may be removable if it is the case that TreeGraphNode (it's main user) doesn't actually need the cyclic semantics (because we fixed a bug in its lack of hashCode).

Author:
rafferty
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.stanford.nlp.ling.CoreLabel
CoreLabel.GenericAnnotation<T>
 
Nested classes/interfaces inherited from interface edu.stanford.nlp.util.TypesafeMap
TypesafeMap.Key<BASE,VALUE>
 
Field Summary
 
Fields inherited from class edu.stanford.nlp.ling.CoreLabel
genericKeys, genericValues
 
Constructor Summary
CyclicCoreLabel()
          Default constructor, calls super()
CyclicCoreLabel(CoreLabel label)
          Copy constructor from any CoreMap.
CyclicCoreLabel(CoreMap label)
          Copy constructor from any CoreMap.
CyclicCoreLabel(CyclicCoreLabel label)
          Copy constructor from any CoreMap.
CyclicCoreLabel(Label label)
          Copy constructor from any CoreMap.
 
Method Summary
 boolean cyclicEquals(Object obj)
          Equals method that is well defined even if there are cycles in keys/values.
 int cyclicHashCode()
          Hashcode function that works on object address equality.
 String cyclicToString()
          To string method that works regardless of whether cycles exist
 boolean equals(Object obj)
          Two CoreMaps are equal iff all keys and values are equal.
static LabelFactory factory()
          
 int hashCode()
          Returns a composite hashcode over all the keys and values currently stored in the map.
 LabelFactory labelFactory()
          Returns a factory that makes labels of the exact same type as this one.
 String toString()
          Return a String containing the value (and index, if any) of this label.
 String toString(String format)
          Returns a formatted string representing this label.
 
Methods inherited from class edu.stanford.nlp.ling.CoreLabel
after, appendAfter, before, category, current, docID, getString, index, lemma, lemmatize, ner, prependBefore, sentIndex, setAfter, setBefore, setCategory, setCurrent, setDocID, setFromString, setIndex, setLemma, setNER, setSentIndex, setTag, setValue, setWord, tag, value, word
 
Methods inherited from class edu.stanford.nlp.util.ArrayCoreMap
compact, containsKey, get, has, keySet, remove, set, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CyclicCoreLabel

public CyclicCoreLabel()
Default constructor, calls super()


CyclicCoreLabel

public CyclicCoreLabel(Label label)
Copy constructor from any CoreMap.


CyclicCoreLabel

public CyclicCoreLabel(CoreMap label)
Copy constructor from any CoreMap.


CyclicCoreLabel

public CyclicCoreLabel(CoreLabel label)
Copy constructor from any CoreMap.


CyclicCoreLabel

public CyclicCoreLabel(CyclicCoreLabel label)
Copy constructor from any CoreMap.

Method Detail

equals

public boolean equals(Object obj)
Two CoreMaps are equal iff all keys and values are equal.

Overrides:
equals in class ArrayCoreMap

hashCode

public int hashCode()
Returns a composite hashcode over all the keys and values currently stored in the map. Because they may change over time, this class is not appropriate for use as map keys.

Overrides:
hashCode in class ArrayCoreMap

toString

public String toString()
Return a String containing the value (and index, if any) of this label. This is equivalent to toString("value-index").

Specified by:
toString in interface Label
Overrides:
toString in class ArrayCoreMap
Returns:
a text representation of the full label contents

toString

public String toString(String format)
Returns a formatted string representing this label. The desired format is passed in as a String. Currently supported formats include:

Map is printed in alphabetical order of keys.


factory

public static LabelFactory factory()


labelFactory

public LabelFactory labelFactory()
Returns a factory that makes labels of the exact same type as this one. May return null if no appropriate factory is known.

Specified by:
labelFactory in interface Label
Overrides:
labelFactory in class CoreLabel
Returns:
the LabelFactory for this kind of label

cyclicToString

public String cyclicToString()
To string method that works regardless of whether cycles exist

Returns:

cyclicHashCode

public int cyclicHashCode()
Hashcode function that works on object address equality. Compatible with cyclicEquals

Returns:

cyclicEquals

public boolean cyclicEquals(Object obj)
Equals method that is well defined even if there are cycles in keys/values. Checks for object address equality for key-value pairs.

Parameters:
obj -
Returns:


Stanford NLP Group