|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.ArrayCoreMap
edu.stanford.nlp.ling.CoreLabel
public class CoreLabel
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
.
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 java.util.HashMap<java.lang.String,java.lang.Class<? extends CoreLabel.GenericAnnotation>> |
genericKeys
|
static java.util.HashMap<java.lang.Class<? extends CoreLabel.GenericAnnotation>,java.lang.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(java.lang.String[] keys,
java.lang.String[] values)
This constructor attempts to parse the String keys into Class keys. |
Method Summary | ||
---|---|---|
java.lang.String |
after()
Return the String after the word. |
|
void |
appendAfter(java.lang.String after)
Append this String to the current after String |
|
java.lang.String |
before()
|
|
int |
beginPosition()
Return the beginning character offset of the label (or -1 if none). |
|
java.lang.String |
category()
Return the category value of the label (or null if none). |
|
java.lang.String |
current()
Return the String which is the unmangled word. |
|
java.lang.String |
docID()
|
|
int |
endPosition()
Return the ending character offset of the label (or -1 if none). |
|
static LabelFactory |
factory()
Return a factory for this kind of label |
|
|
getString(java.lang.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. |
|
java.lang.String |
lemma()
Return the lemma of the label (or null if none). |
|
java.lang.String |
ner()
Return the named entity class of the label (or null if none). |
|
void |
prependBefore(java.lang.String before)
Prepend this String to the before String. |
|
int |
sentIndex()
|
|
void |
setAfter(java.lang.String after)
Set the String after the word. |
|
void |
setBefore(java.lang.String before)
Set the String before the word. |
|
void |
setBeginPosition(int beginPos)
Set the beginning character offset for the label. |
|
void |
setCategory(java.lang.String category)
Set the category value for the label (if one is stored). |
|
void |
setCurrent(java.lang.String current)
Set the String which is the unmangled word. |
|
void |
setDocID(java.lang.String docID)
|
|
void |
setEndPosition(int endPos)
Set the ending character offset of the label (or -1 if none). |
|
void |
setFromString(java.lang.String labelStr)
Set the contents of this label to this String
representing the
complete contents of the label. |
|
void |
setIndex(int index)
|
|
void |
setLemma(java.lang.String lemma)
|
|
void |
setNER(java.lang.String ner)
|
|
void |
setSentIndex(int sentIndex)
|
|
void |
setTag(java.lang.String tag)
Set the tag value for the label (if one is stored). |
|
void |
setValue(java.lang.String value)
Set the value for the label (if one is stored). |
|
void |
setWord(java.lang.String word)
Set the word value for the label (if one is stored). |
|
java.lang.String |
tag()
Return the tag value of the label (or null if none). |
|
java.lang.String |
value()
Return a String representation of just the "main" value of this label. |
|
java.lang.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, setCapacity, 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 |
---|
public static java.util.HashMap<java.lang.String,java.lang.Class<? extends CoreLabel.GenericAnnotation>> genericKeys
public static java.util.HashMap<java.lang.Class<? extends CoreLabel.GenericAnnotation>,java.lang.String> genericValues
Constructor Detail |
---|
public CoreLabel()
public CoreLabel(CoreLabel label)
label
- The CoreLabel to copypublic CoreLabel(CoreMap label)
label
- The CoreMap to copypublic CoreLabel(Label label)
label
- Basis for this labelpublic CoreLabel(java.lang.String[] keys, java.lang.String[] values)
CoreAnnotations
.
keys
- Array of Strings that are class namesvalues
- Array of values (as String)Method Detail |
---|
public static LabelFactory factory()
public LabelFactory labelFactory()
null
if no appropriate factory is known.
labelFactory
in interface Label
public <KEY extends TypesafeMap.Key<CoreMap,java.lang.String>> java.lang.String getString(java.lang.Class<KEY> key)
KEY
- A key type with a String valuekey
- The key to return the value of.
null
and the String value of the key otherwisepublic void setFromString(java.lang.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 final void setValue(java.lang.String value)
setValue
in interface Label
value
- - the value for the labelpublic final java.lang.String value()
value
in interface Label
public void setWord(java.lang.String word)
setWord
in interface HasWord
word
- The word value for the labelpublic java.lang.String word()
word
in interface HasWord
public void setTag(java.lang.String tag)
setTag
in interface HasTag
tag
- The tag value for the labelpublic java.lang.String tag()
tag
in interface HasTag
public void setCategory(java.lang.String category)
setCategory
in interface HasCategory
category
- The category value for the labelpublic java.lang.String category()
category
in interface HasCategory
public void setAfter(java.lang.String after)
setAfter
in interface HasContext
after
- The String after the wordpublic void appendAfter(java.lang.String after)
appendAfter
in interface HasContext
after
- The String to be prependedpublic java.lang.String after()
after
in interface HasContext
public void setBefore(java.lang.String before)
setBefore
in interface HasContext
before
- the String before the wordpublic void prependBefore(java.lang.String before)
prependBefore
in interface HasContext
before
- the String to be prependedpublic java.lang.String before()
before
in interface HasContext
public void setCurrent(java.lang.String current)
setCurrent
in interface HasContext
current
- the unmangled wordpublic java.lang.String current()
current
in interface HasContext
public java.lang.String docID()
docID
in interface HasIndex
public void setDocID(java.lang.String docID)
setDocID
in interface HasIndex
public java.lang.String ner()
public void setNER(java.lang.String ner)
public java.lang.String lemma()
public void setLemma(java.lang.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 int beginPosition()
HasOffset
beginPosition
in interface HasOffset
public int endPosition()
HasOffset
endPosition
in interface HasOffset
public void setBeginPosition(int beginPos)
HasOffset
setBeginPosition
in interface HasOffset
beginPos
- The beginning positionpublic void setEndPosition(int endPos)
HasOffset
setEndPosition
in interface HasOffset
endPos
- The end character offset for the label
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |