Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.ling
Class CoreLabel

    java.lang.Object
      edu.stanford.nlp.util.ArrayCoreMap
          edu.stanford.nlp.ling.CoreLabel

All Implemented Interfaces:
  HasCategory, HasContext, HasIndex, HasTag, HasWord, Label, CoreMap, TypesafeMap<CoreMap>, Serializable

Direct Known Subclasses:
  CyclicCoreLabel

    public class CoreLabel

extends ArrayCoreMap
implements Label, HasWord, HasTag, HasCategory, HasContext, HasIndex

A class that bridges the gap between old-style JavaNLP Labels and the new core object infrastructure. Instances of this class can be used (almost) anywhere that the now-defunct FeatureLabel family could be used. This data structure is backed by an `ArrayCoreMap`.

Author:
  dramage, rafferty
See Also:
  Serialized Form

Nested Class Summary
`static interface` | `CoreLabel.GenericAnnotation<T>` Class that all "generic" annotations extend This allows you to read in arbitrary values from a file as features, for example.

Nested classes/interfaces inherited from interface edu.stanford.nlp.util.TypesafeMap
`TypesafeMap.Key<BASE,VALUE>`

Field Summary
`static HashMap<String,Class<? extends CoreLabel.GenericAnnotation>>` | `genericKeys`
`static HashMap<Class<? extends CoreLabel.GenericAnnotation>,String>` | `genericValues`

Constructor Summary
`CoreLabel()` Default constructor, calls super()
`CoreLabel(CoreLabel label)` Returns a new CoreLabel instance based on the contents of the given CoreLabel.
`CoreLabel(CoreMap label)` Returns a new CoreLabel instance based on the contents of the given CoreMap.
`CoreLabel(Label label)` Returns a new CoreLabel instance based on the contents of the given label.
`CoreLabel(String[] keys, String[] values)` This constructor attempts to parse the String keys into Class keys.

Method Summary
`String` | `after()` Return the String after the word.
`void` | `appendAfter(String after)` Append this String to the current after String
`String` | `before()`
`String` | `category()` Return the category value of the label (or null if none).
`String` | `current()` Return the String which is the unmangled word.
`String` | `docID()`
`static LabelFactory` | `factory()` Return a factory for this kind of label
`
`<KEY extends TypesafeMap.Key<CoreMap,String>> String`
` | `getString(Class<KEY> key)` Return a non-null String value for a key.
`int` | `index()`
`LabelFactory` | `labelFactory()` Returns a factory that makes labels of the exact same type as this one.
`String` | `lemma()` Return the lemma of the label (or null if none).
`String` | `ner()` Return the named entity class of the label (or null if none).
`void` | `prependBefore(String before)` Prepend this String to the before String.
`int` | `sentIndex()`
`void` | `setAfter(String after)` Set the String after the word.
`void` | `setBefore(String before)` Set the String before the word.
`void` | `setCategory(String category)` Set the category value for the label (if one is stored).
`void` | `setCurrent(String current)` Set the String which is the unmangled word.
`void` | `setDocID(String docID)`
`void` | `setFromString(String labelStr)` Set the contents of this label to this `String` representing the complete contents of the label.
`void` | `setIndex(int index)`
`void` | `setLemma(String lemma)`
`void` | `setNER(String ner)`
`void` | `setSentIndex(int sentIndex)`
`void` | `setTag(String tag)` Set the tag value for the label (if one is stored).
`void` | `setValue(String value)` Set the value for the label (if one is stored).
`void` | `setWord(String word)` Set the word value for the label (if one is stored).
`String` | `tag()` Return the tag value of the label (or null if none).
`String` | `value()` Return a String representation of just the "main" value of this label.
`String` | `word()` Return the word value of the label (or null if none).

Methods inherited from class edu.stanford.nlp.util.ArrayCoreMap
`compact, containsKey, equals, get, has, hashCode, keySet, remove, set, size, toShorterString, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface edu.stanford.nlp.ling.Label
`toString`

Field Detail

### genericKeys

    public static HashMap<String,Class<? extends CoreLabel.GenericAnnotation>> genericKeys

### genericValues

    public static HashMap<Class<? extends CoreLabel.GenericAnnotation>,String> genericValues

Constructor Detail

### CoreLabel

    public CoreLabel()

  Default constructor, calls super()

### CoreLabel

    public CoreLabel(CoreLabel label)

  Returns a new CoreLabel instance based on the contents of the given CoreLabel. It copies the contents of the other CoreLabel. Implementation note: this is a the same as the constructor that takes a CoreMap, but is needed to ensure unique most specific type inference for selecting a constructor at compile-time.

  Parameters:
    `label` - The CoreLabel to copy

### CoreLabel

    public CoreLabel(CoreMap label)

  Returns a new CoreLabel instance based on the contents of the given CoreMap. It copies the contents of the other CoreMap.

  Parameters:
    `label` - The CoreMap to copy

### CoreLabel

    public CoreLabel(Label label)

  Returns a new CoreLabel instance based on the contents of the given label. Just the value() is copied.

  Parameters:
    `label` - Basis for this label

### CoreLabel

    public CoreLabel(String[] keys,
                     String[] values)

  This constructor attempts to parse the String keys into Class keys. It's mainly useful for reading from a file. A best effort attempt is made to correctly parse the keys according to the String lookup function in `CoreAnnotations`.

  Parameters:
    `keys` - Array of Strings that are class names
    `values` - Array of values (as String)

Method Detail

### factory

    public static LabelFactory factory()

  Return a factory for this kind of label

  Returns:
    The label 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`
  Returns:
    the LabelFactory for this kind of label

### getString

    public <KEY extends TypesafeMap.Key<CoreMap,String>> String getString(Class<KEY> key)

  Return a non-null String value for a key. This method is included for backwards compatibility with AbstractMapLabel. It is guaranteed to not return null; if the key is not present or has a null value, it returns the empty string (""). It is only valid to call this method when key is paired with a value of type String.

  Type Parameters:
    `KEY` - A key type with a String value
  Parameters:
    `key` - The key to return the value of.
  Returns:
    "" if the key is not in the map or has the value `null` and the String value of the key otherwise

### setFromString

    public void setFromString(String labelStr)

  Set the contents of this label to this `String` representing the complete contents of the label. A class implementing label may throw an `UnsupportedOperationException` for this method (only). Typically, this method would do some appropriate decoding of the string in a way that sets multiple fields in an inverse of the `toString()` method.

  Specified by:
    `setFromString` in interface `Label`
  Parameters:
    `labelStr` - the String that translates into the content of the label

### setValue

    public final void setValue(String value)

  Set the value for the label (if one is stored).

  Specified by:
    `setValue` in interface `Label`
  Parameters:
    `value` - - the value for the label

### value

    public final String value()

  Return a String representation of just the "main" value of this label.

  Specified by:
    `value` in interface `Label`
  Returns:
    the "value" of the label

### setWord

    public void setWord(String word)

  Set the word value for the label (if one is stored).

  Specified by:
    `setWord` in interface `HasWord`
  Parameters:
    `word` - The word value for the label

### word

    public String word()

  Return the word value of the label (or null if none).

  Specified by:
    `word` in interface `HasWord`
  Returns:
    String the word value for the label

### setTag

    public void setTag(String tag)

  Set the tag value for the label (if one is stored).

  Specified by:
    `setTag` in interface `HasTag`
  Parameters:
    `tag` - The tag value for the label

### tag

    public String tag()

  Return the tag value of the label (or null if none).

  Specified by:
    `tag` in interface `HasTag`
  Returns:
    String the tag value for the label

### setCategory

    public void setCategory(String category)

  Set the category value for the label (if one is stored).

  Specified by:
    `setCategory` in interface `HasCategory`
  Parameters:
    `category` - The category value for the label

### category

    public String category()

  Return the category value of the label (or null if none).

  Specified by:
    `category` in interface `HasCategory`
  Returns:
    String the category value for the label

### setAfter

    public void setAfter(String after)

  Set the String after the word.

  Specified by:
    `setAfter` in interface `HasContext`
  Parameters:
    `after` - The String after the word

### appendAfter

    public void appendAfter(String after)

  Append this String to the current after String

  Specified by:
    `appendAfter` in interface `HasContext`
  Parameters:
    `after` - The String to be prepended

### after

    public String after()

  Return the String after the word.

  Specified by:
    `after` in interface `HasContext`
  Returns:
    the String after the word

### setBefore

    public void setBefore(String before)

  Set the String before the word.

  Specified by:
    `setBefore` in interface `HasContext`
  Parameters:
    `before` - the String before the word

### prependBefore

    public void prependBefore(String before)

  Prepend this String to the before String.

  Specified by:
    `prependBefore` in interface `HasContext`
  Parameters:
    `before` - the String to be prepended

### before

    public String before()

  Specified by:
    `before` in interface `HasContext`
  Returns:
    the String before the word

### setCurrent

    public void setCurrent(String current)

  Set the String which is the unmangled word.

  Specified by:
    `setCurrent` in interface `HasContext`
  Parameters:
    `current` - the unmangled word

### current

    public String current()

  Return the String which is the unmangled word.

  Specified by:
    `current` in interface `HasContext`
  Returns:
    the unmangled word

### docID

    public String docID()

  Specified by:
    `docID` in interface `HasIndex`

### setDocID

    public void setDocID(String docID)

  Specified by:
    `setDocID` in interface `HasIndex`

### ner

    public String ner()

  Return the named entity class of the label (or null if none).

  Returns:
    String the word value for the label

### setNER

    public void setNER(String ner)

### lemma

    public String lemma()

  Return the lemma of the label (or null if none).

  Returns:
    String the word value for the label

### setLemma

    public void setLemma(String lemma)

### index

    public int index()

  Specified by:
    `index` in interface `HasIndex`

### setIndex

    public void setIndex(int index)

  Specified by:
    `setIndex` in interface `HasIndex`

### sentIndex

    public int sentIndex()

  Specified by:
    `sentIndex` in interface `HasIndex`

### setSentIndex

    public void setSentIndex(int sentIndex)

  Specified by:
    `setSentIndex` in interface `HasIndex`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group