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, HasOffset, HasTag, HasWord, Label, CoreMap, PrettyLoggable, 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). TODO: However, something now used in various places is that it has a tidy minimal toString output of value-index, which is not preserved in CoreLabel. Maybe it should be but changing that might also break stuff now.

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, TAG_SEPARATOR
 
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 equals(Object obj)
          Two CoreMaps are equal iff all keys and values are equal (really, ==).
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 toPrimes()
           
 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, before, beginPosition, category, docID, endPosition, getString, index, lemma, ner, originalText, sentIndex, setAfter, setBefore, setBeginPosition, setCategory, setDocID, setEndPosition, setFromString, setIndex, setLemma, setNER, setOriginalText, setSentIndex, setTag, setValue, setWord, tag, value, word
 
Methods inherited from class edu.stanford.nlp.util.ArrayCoreMap
compact, containsKey, get, has, keySet, prettyLog, remove, set, setCapacity, size, toShorterString
 
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 (really, ==). This equals method that is well defined even if there are cycles in keys/values. Checks for object address equality for key-value pairs.

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. This hashcode function works on object address equality. Compatible with cyclicEquals.

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.


toPrimes

public String toPrimes()

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


Stanford NLP Group