|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.io.BaseStorable
de.fu_berlin.ties.classify.Prediction
de.fu_berlin.ties.extract.Extraction
public class Extraction
Extends a Prediction
by also storing the
extracted text and location data.
Instances of this class are not thread-safe.
Field Summary | |
---|---|
static String |
KEY_FIRST_TOKEN_REP
Serialization key for the repetition of the first token. |
static String |
KEY_INDEX
Serialization key for the index. |
static String |
KEY_TEXT
Serialization key for the extracted text. |
Fields inherited from class de.fu_berlin.ties.classify.Prediction |
---|
KEY_PR, KEY_PROB, KEY_SOURCE, KEY_TYPE |
Constructor Summary | |
---|---|
Extraction(FieldMap fieldMap)
Creates a new instance from a field map, fulfilling the Storable contract. |
|
Extraction(String predicted,
String extracted)
Creates a new instance without locating it in a text (using -1 for first token rep + index), setting the probability to -1 ("confirmed") and the evaluation status to EvalStatus.TRUTH . |
|
Extraction(String predicted,
TokenDetails details)
Creates a new instance, setting the probability to -1 ("confirmed") and the evaluation status to EvalStatus.TRUTH . |
|
Extraction(String predicted,
TokenDetails details,
Probability prob)
Creates a new instance, setting the evaluation status to EvalStatus.UNKNOWN . |
|
Extraction(String predicted,
TokenDetails details,
Probability prob,
EvalStatus status)
Creates a new instance. |
Method Summary | |
---|---|
void |
addToken(TokenDetails details,
boolean atEnd)
Adds a token to this extraction, delegating to addToken(TokenDetails, Probability, boolean) with a probability
of -1 ("confirmed"). |
void |
addToken(TokenDetails details,
Probability prob,
boolean atEnd)
Adds a token to this extraction, recalculating the probability by multiplying the prior probability value with the probability of the new text. |
Extraction |
clone()
Creates and returns a deep copy of this object. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract. |
int |
getFirstTokenRep()
Returns the repetition of the first token of the extraction in the original text (counting starts with 0, as the first occurrence is the "0th repetition"), -1 if unknown or if isFirstTokenRepIgnored()
is true . |
int |
getIndex()
Returns the index of the first token in the text (indexing starts with 0); or -1 if unknown/irrelevant. |
int |
getLastIndex()
Returns the index of the last token in the text (indexing starts with 0); or -1 if unknown/irrelevant. |
String |
getText()
Returns the extracted text fragment. |
String |
getVisibleChars()
Returns the visible characters of the text fragment (everything except whitespace and control characters). |
int |
hashCode()
Returns a hash code value for this object, fulfulling the Object.hashCode() contract. |
boolean |
hasProperty(Object prop)
Checks if a specific user-defined property is set for this extraction. |
boolean |
isFirstTokenRepIgnored()
Whether the repetition of the first token should be ignored, comparing only the text but not the position of extractions. |
boolean |
isSealed()
Whether this extraction has been sealed. |
void |
modifyProbability(Probability prob)
Modifies the probability of an extraction. |
void |
setFirstTokenRep(int newFirstTokenRep)
Modifies the repetition of the first token of the extraction in the original text (counting starts with 0, as the first occurrence is the "0th repetition"). |
void |
setFirstTokenRepIgnored(boolean ftRepIgnored)
Specified whether the repetition of the first token should be ignored, comparing only the text but not the position of extractions. |
void |
setIndex(int newIndex)
Overrides the index of the first token in the text (indexing starts with 0). |
void |
setLastIndex(int newLastIndex)
Overrides the index of the last token in the text (indexing starts with 0). |
boolean |
setProperty(Object prop)
Sets a user-defined property for this extraction. |
void |
setSealed(boolean newSealed)
Seals or unseals this extraction. |
FieldMap |
storeFields()
Stores all relevant fields of this object in a field map for serialization. |
int |
tokenCount()
Returns the number of tokens in this extraction. |
boolean |
unsetProperty(Object prop)
Unsets a user-defined property for this extraction. |
Methods inherited from class de.fu_berlin.ties.classify.Prediction |
---|
addProb, getEvalStatus, getProbability, getSource, getType, probCount, removeProb, setEvalStatus, setSource |
Methods inherited from class de.fu_berlin.ties.io.BaseStorable |
---|
toString, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.fu_berlin.ties.context.Recognition |
---|
getType |
Field Detail |
---|
public static final String KEY_TEXT
public static final String KEY_FIRST_TOKEN_REP
public static final String KEY_INDEX
Constructor Detail |
---|
public Extraction(FieldMap fieldMap)
Storable
contract. An extraction created
this way will be immediately sealed
, thus the
extracted text cannot be changed.
fieldMap
- map containing the serialized fieldspublic Extraction(String predicted, String extracted)
EvalStatus.TRUTH
.
predicted
- the predicted classextracted
- the (first part) extracted text fragment; must not be
null
public Extraction(String predicted, TokenDetails details)
EvalStatus.TRUTH
.
Use this constructor to build answer keys.
predicted
- the predicted classdetails
- details about the extracted text fragment or its first
tokenpublic Extraction(String predicted, TokenDetails details, Probability prob)
EvalStatus.UNKNOWN
.
predicted
- the predicted classdetails
- details about the extracted text fragment or its first
tokenprob
- the probability of the predictionpublic Extraction(String predicted, TokenDetails details, Probability prob, EvalStatus status)
predicted
- the predicted classdetails
- details about the extracted text fragment or its first
tokenprob
- the probability of the predictionstatus
- the evaluation status of this
instanceMethod Detail |
---|
public void addToken(TokenDetails details, boolean atEnd) throws IllegalStateException
addToken(TokenDetails, Probability, boolean)
with a probability
of -1 ("confirmed"). Use this method when building answer keys.
details
- details about the new tokenatEnd
- whether to add the new token at the end or at the
start
IllegalStateException
- if this extraction
is sealed
public void addToken(TokenDetails details, Probability prob, boolean atEnd) throws IllegalStateException
details
- details about the new tokenprob
- the probability of the new token; might be null
if the overall probability of the extraction should not be changedatEnd
- whether to add the new token at the end or at the
start
IllegalStateException
- if this extraction
is sealed
; or if new and old probabilities/pRs
cannot be combinedpublic Extraction clone()
properties
, however, are only copied,
not cloned.
clone
in class Object
public boolean equals(Object obj)
Object.equals(java.lang.Object)
contract. The
evaluation status is ignored when
checking equality, thus if all other fields of two extractions are equal,
this method will return true
even if their evaluation states
differ. Only the visible characters
of the
extractions are compared, whitespace and control characters are ignored.
equals
in class Prediction
obj
- the reference object with which to compare
true
iff the specified object is an
Extraction
equal to this instancepublic int getFirstTokenRep()
isFirstTokenRepIgnored()
is true
. This is useful to locate this extraction in the
original text.
public int getIndex()
public int getLastIndex()
public String getText()
getText
in interface Recognition
public String getVisibleChars()
public int hashCode()
Object.hashCode()
contract.
hashCode
in class Prediction
public boolean hasProperty(Object prop)
prop
- the property to check
true
iff the property is setpublic boolean setProperty(Object prop)
prop
- the property to set
true
iff the property had not been set beforepublic boolean unsetProperty(Object prop)
prop
- the property to unset
true
iff the property had been set beforepublic boolean isFirstTokenRepIgnored()
false
.
public boolean isSealed()
isSealed
in interface Recognition
true
iff this extraction is sealedpublic void modifyProbability(Probability prob)
prob
- the new probability, will be combined with the current
token probabilities to calculate the averagepublic void setFirstTokenRep(int newFirstTokenRep)
isFirstTokenRepIgnored()
to
false
(since it wouldn't make much sense to update the
repetition if you want it to be ignored anyway).
newFirstTokenRep
- the new value of the attributepublic void setFirstTokenRepIgnored(boolean ftRepIgnored)
ftRepIgnored
- the new value of the attributepublic void setIndex(int newIndex)
newIndex
- the value of the attribute; if negative, the index of the
first token will be used insteadpublic void setLastIndex(int newLastIndex)
newLastIndex
- the value of the attribute; if negative, the index
of the last token will be used insteadpublic void setSealed(boolean newSealed)
newSealed
- the new value of the attributepublic FieldMap storeFields()
FieldMap.createObject(Class)
on the created
field map.
storeFields
in interface Storable
storeFields
in class Prediction
public int tokenCount()
addToken
are used for each further token. Omitted when serializing
so it cannot be restored.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |