public class IndexedWord extends Object implements AbstractCoreLabel, Comparable<IndexedWord>
CoreLabel that uses its
DocIDAnnotation, SentenceIndexAnnotation, and IndexAnnotation to implement
Comparable/compareTo, hashCode, and equals. This means no other annotations,
including the identity of the word, are taken into account when using these
methods.TypesafeMap.Key<VALUE>| Modifier and Type | Field and Description |
|---|---|
static IndexedWord |
NO_WORD
The identifier that points to no word.
|
| Constructor and Description |
|---|
IndexedWord()
Default constructor; uses
CoreLabel default constructor |
IndexedWord(CoreLabel w)
Construct an IndexedWord from a CoreLabel just as for a CoreMap.
|
IndexedWord(Label w)
Copy Constructor - relies on
CoreLabel copy constructor
It will set the value, and if the word is not set otherwise, set
the word to the value. |
IndexedWord(String docID,
int sentenceIndex,
int index)
Constructor for setting docID, sentenceIndex, and
index without any other annotations.
|
| Modifier and Type | Method and Description |
|---|---|
CoreLabel |
backingLabel()
TODO: would be nice to get rid of this.
|
int |
beginPosition()
Return the beginning character offset of the label (or -1 if none).
|
int |
compareTo(IndexedWord w)
NOTE: This compareTo is based on and made to be compatible with the one
from IndexedFeatureLabel.
|
<VALUE> boolean |
containsKey(Class<? extends TypesafeMap.Key<VALUE>> key)
Returns true if contains the given key.
|
int |
copyCount() |
String |
docID() |
int |
endPosition()
Return the ending character offset of the label (or -1 if none).
|
boolean |
equals(Object o)
This .equals is dependent only on docID, sentenceIndex, and index.
|
static LabelFactory |
factory() |
<VALUE> VALUE |
get(Class<? extends TypesafeMap.Key<VALUE>> key)
Returns the value associated with the given key or null if
none is provided.
|
<KEY extends TypesafeMap.Key<String>> |
getString(Class<KEY> key) |
<VALUE> boolean |
has(Class<? extends TypesafeMap.Key<VALUE>> key)
Returns true if the map contains the given key.
|
int |
hashCode()
This hashCode uses only the docID, sentenceIndex, and index.
|
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()
Return the lemma value of the label (or null if none).
|
String |
ner() |
String |
originalText() |
<VALUE> VALUE |
remove(Class<? extends TypesafeMap.Key<VALUE>> key)
Removes the given key from the map, returning the value removed.
|
int |
sentIndex() |
<VALUE> VALUE |
set(Class<? extends TypesafeMap.Key<VALUE>> key,
VALUE value)
Associates the given value with the given type for future calls
to get.
|
void |
setBeginPosition(int beginPos)
Set the beginning character offset for the label.
|
void |
setCopyCount(int count) |
void |
setDocID(String docID) |
void |
setEndPosition(int endPos)
Set the ending character offset of the label (or -1 if none).
|
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)
Set the lemma value for the label (if one is stored).
|
void |
setNER(String ner) |
void |
setOriginalText(String originalText) |
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()
Returns the value-tag of this label.
|
String |
toString(CoreLabel.OutputFormat format) |
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).
|
public static final IndexedWord NO_WORD
public IndexedWord()
CoreLabel default constructorpublic IndexedWord(Label w)
CoreLabel copy constructor
It will set the value, and if the word is not set otherwise, set
the word to the value.w - A Label to initialize this IndexedWord frompublic IndexedWord(CoreLabel w)
w - A Label to initialize this IndexedWord frompublic IndexedWord(String docID, int sentenceIndex, int index)
docID - The document ID (arbitrary string)sentenceIndex - The sentence number in the document (normally 0-based)index - The index of the word in the sentence (normally 0-based)public CoreLabel backingLabel()
public <VALUE> VALUE get(Class<? extends TypesafeMap.Key<VALUE>> key)
TypesafeMapget in interface TypesafeMappublic <VALUE> boolean has(Class<? extends TypesafeMap.Key<VALUE>> key)
TypesafeMaphas in interface TypesafeMappublic <VALUE> boolean containsKey(Class<? extends TypesafeMap.Key<VALUE>> key)
TypesafeMapcontainsKey in interface TypesafeMappublic <VALUE> VALUE set(Class<? extends TypesafeMap.Key<VALUE>> key, VALUE value)
TypesafeMapset in interface TypesafeMappublic <KEY extends TypesafeMap.Key<String>> String getString(Class<KEY> key)
getString in interface AbstractCoreLabelpublic <VALUE> VALUE remove(Class<? extends TypesafeMap.Key<VALUE>> key)
TypesafeMapremove in interface TypesafeMappublic Set<Class<?>> keySet()
TypesafeMapkeySet in interface TypesafeMappublic int size()
TypesafeMapsize in interface TypesafeMappublic String value()
Labelpublic void setValue(String value)
Labelpublic String tag()
HasTagpublic void setTag(String tag)
HasTagpublic String word()
HasWordpublic void setWord(String word)
HasWordpublic String lemma()
HasLemmapublic void setLemma(String lemma)
HasLemmapublic String ner()
ner in interface AbstractCoreLabelpublic void setNER(String ner)
setNER in interface AbstractCoreLabelpublic void setSentIndex(int sentIndex)
setSentIndex in interface HasIndexpublic String originalText()
originalText in interface AbstractCoreLabelpublic void setOriginalText(String originalText)
setOriginalText in interface AbstractCoreLabelpublic int beginPosition()
HasOffsetbeginPosition in interface HasOffsetpublic int endPosition()
HasOffsetendPosition in interface HasOffsetpublic void setBeginPosition(int beginPos)
HasOffsetsetBeginPosition in interface HasOffsetbeginPos - The beginning positionpublic void setEndPosition(int endPos)
HasOffsetsetEndPosition in interface HasOffsetendPos - The end character offset for the labelpublic int copyCount()
public void setCopyCount(int count)
public boolean equals(Object o)
public int hashCode()
public int compareTo(IndexedWord w)
compareTo in interface Comparable<IndexedWord>w - The IndexedWord to compare withpublic String toString()
public String toString(CoreLabel.OutputFormat format)
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 LabellabelStr - the String that translates into the content of the
labelpublic static LabelFactory factory()
public LabelFactory labelFactory()
null if no appropriate factory is known.labelFactory in interface Label