|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ling.CoreLabel
public class CoreLabel
A class that bridges the gap between old-style JavaNLP objects and
the new core object infrastructure. Instances of this class can
be used (almost) anywhere that now-defunct FeatureLabel family could be used.
This data structure is backed by an ArrayCoreMap
.
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
|
protected ArrayCoreMap |
map
The CoreMap backing this label. |
Constructor Summary | |
---|---|
CoreLabel()
Default constructor, calls super() |
|
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). |
|
|
containsKey(Class<KEY> key)
Returns true if contains the given key. |
|
String |
current()
Return the String which is the unmangled word. |
|
String |
docID()
|
|
boolean |
equals(Object other)
|
|
static LabelFactory |
factory()
|
|
static CoreLabel |
fromCoreMap(ArrayCoreMap map)
Wraps the given CoreMap as a CoreLabel. |
|
|
get(Class<KEY> key)
Returns the value associated with the given key or null if none is provided. |
|
|
getString(Class<KEY> key)
This method included for backwards compatibility with AbstractMapLabel. |
|
|
has(Class<KEY> key)
Returns true if the map contains the given key. |
|
int |
hashCode()
|
|
int |
index()
|
|
Set<Class<?>> |
keySet()
Collection of keys currently held in this map. |
|
LabelFactory |
labelFactory()
Returns a factory that makes labels of the exact same type as this one. |
|
String |
lemma()
|
|
String |
ner()
|
|
void |
prependBefore(String before)
Prepend this String to the before String. |
|
|
remove(Class<KEY> key)
Removes the given key from the map, returning the value removed. |
|
int |
sentIndex()
|
|
|
set(Class<KEY> key,
VALUE value)
Associates the given value with the given type for future calls to get. |
|
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). |
|
int |
size()
Returns the number of keys in the map. |
|
String |
tag()
Return the tag value of the label (or null if none). |
|
String |
toString()
Return a String representation of the label. |
|
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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ArrayCoreMap map
public static HashMap<String,Class<? extends CoreLabel.GenericAnnotation>> genericKeys
public static HashMap<Class<? extends CoreLabel.GenericAnnotation>,String> genericValues
Constructor Detail |
---|
public CoreLabel()
public CoreLabel(Label label)
public CoreLabel(String[] keys, String[] values)
CoreAnnotations
.
keys
- values
- Method Detail |
---|
public static CoreLabel fromCoreMap(ArrayCoreMap map)
public static LabelFactory factory()
public LabelFactory labelFactory()
null
if no appropriate factory is known.
labelFactory
in interface Label
public <KEY extends TypesafeMap.Key<CoreMap,String>> String getString(Class<KEY> key)
KEY
- key
-
public int size()
size
in interface TypesafeMap<CoreMap>
public void setFromString(String labelStr)
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.
setFromString
in interface Label
labelStr
- the String that translates into the content of the
labelpublic void setValue(String value)
setValue
in interface Label
value
- - the value for the labelpublic String value()
value
in interface Label
public void setWord(String word)
setWord
in interface HasWord
word
- The word value for the labelpublic String word()
word
in interface HasWord
public void setTag(String tag)
setTag
in interface HasTag
tag
- The tag value for the labelpublic String tag()
tag
in interface HasTag
public void setCategory(String category)
setCategory
in interface HasCategory
category
- The category value for the labelpublic String category()
category
in interface HasCategory
public void setAfter(String after)
setAfter
in interface HasContext
after
- The String after the wordpublic void appendAfter(String after)
appendAfter
in interface HasContext
after
- The String to be prependedpublic String after()
after
in interface HasContext
public void setBefore(String before)
setBefore
in interface HasContext
before
- the String before the wordpublic void prependBefore(String before)
prependBefore
in interface HasContext
before
- the String to be prependedpublic String before()
before
in interface HasContext
public void setCurrent(String current)
setCurrent
in interface HasContext
current
- the unmangled wordpublic String current()
current
in interface HasContext
public String docID()
docID
in interface HasIndex
public void setDocID(String docID)
setDocID
in interface HasIndex
public String ner()
public void setNER(String ner)
public String lemma()
public void setLemma(String lemma)
public int index()
index
in interface HasIndex
public void setIndex(int index)
setIndex
in interface HasIndex
public int sentIndex()
sentIndex
in interface HasIndex
public void setSentIndex(int sentIndex)
setSentIndex
in interface HasIndex
public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE get(Class<KEY> key)
get
in interface TypesafeMap<CoreMap>
public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean has(Class<KEY> key)
has
in interface TypesafeMap<CoreMap>
public Set<Class<?>> keySet()
keySet
in interface TypesafeMap<CoreMap>
public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE remove(Class<KEY> key)
remove
in interface TypesafeMap<CoreMap>
public <VALUEBASE,VALUE extends VALUEBASE,KEY extends TypesafeMap.Key<CoreMap,VALUEBASE>> VALUE set(Class<KEY> key, VALUE value)
set
in interface TypesafeMap<CoreMap>
public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean containsKey(Class<KEY> key)
containsKey
in interface TypesafeMap<CoreMap>
public String toString()
Label
toString()
method
causes a label to spill its guts. It should always return an
empty string rather than null
if there is no value.
toString
in interface Label
toString
in class Object
public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |