public class Constituent extends Object implements Serializable, HasAttributes
Relation
s are edges. Each
Constituent corresponds to a set of tokens in a TextAnnotation
.Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
attributes |
protected double |
constituentScore |
protected int |
endCharOffset |
protected List<Relation> |
incomingRelations |
protected int |
label |
protected Map<String,Double> |
labelsToScores |
protected List<Relation> |
outgoingRelations |
protected IntPair |
span |
protected int |
startCharOffset |
protected TextAnnotation |
textAnnotation |
protected String |
viewName
This indicates whether the element
Constituent#constituentTokens is a two element
list consisting of a start and an end tokenId, specifying a span, instead of explicitly
listing the each element. |
Constructor and Description |
---|
Constituent(Map<String,Double> labelsToScores,
String viewName,
TextAnnotation text,
int start,
int end)
instantiate a constituent with a set of labels and corresponding scores: the 'main' label (returned by
#getLabel()) will be the label with the highest score, as decided by
ArgMax . |
Constituent(String label,
double score,
String viewName,
TextAnnotation text,
int start,
int end)
start, end offsets are token indexes, and use one-past-the-end indexing -- so a one-token
constituent right at the beginning of a text has start/end (0,1) offsets are relative to the
entire text span (i.e.
|
Constituent(String label,
String viewName,
TextAnnotation text,
int start,
int end)
start, end offsets are token indexes, and use one-past-the-end indexing -- so a one-token
constituent right at the beginning of a text has start/end (0,1) offsets are relative to the
entire text span (i.e.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String key,
String value) |
Constituent |
cloneForNewView(String newViewName) |
Constituent |
cloneForNewViewWithDestinationLabel(String newViewName,
String Dlabel) |
boolean |
doesConstituentCover(Constituent other) |
boolean |
doesConstituentCover(int tokenId) |
boolean |
doesConstituentCoverAll(Collection<Integer> tokenIds) |
boolean |
equals(Object obj) |
boolean |
equalsWithoutAttributeEqualityCheck(Constituent that)
This function can be used in scenarios where there is a need for Constituent equality, ignoring the values
of the attributes.
|
String |
getAttribute(String key) |
Set<String> |
getAttributeKeys() |
double |
getConstituentScore() |
TreeSet<Integer> |
getConstituentTokens()
Deprecated.
|
int |
getEndCharOffset() |
int |
getEndSpan() |
int |
getInclusiveEndCharOffset() |
int |
getInclusiveStartCharOffset() |
List<Relation> |
getIncomingRelations()
Get a list of relations where the target is this constituent
|
String |
getLabel() |
Map<String,Double> |
getLabelsToScores()
Return map of labels to scores.
|
int |
getNumberOfTokens() |
List<Relation> |
getOutgoingRelations()
Get a list of relations where the source is this constituent.
|
int |
getSentenceId()
Return the identifier of the sentence that contains this constituent.
|
IntPair |
getSpan() |
int |
getStartCharOffset() |
int |
getStartSpan() |
String |
getSurfaceForm()
This method returns the original surface form of the constituent.
|
TextAnnotation |
getTextAnnotation() |
String |
getTokenizedSurfaceForm()
This method returns a tokenized representation of the surface form of the constituent.
|
View |
getView() |
String |
getViewName() |
boolean |
hasAttribute(String key) |
int |
hashCode() |
boolean |
isConsituentInRange(int start,
int end) |
int |
length() |
void |
removeAllAttributes()
Removes all attributes from a Constituent.
|
void |
removeAllIncomingRelatons() |
void |
removeAllOutgoingRelaton() |
void |
removeIncomingRelaton(Relation r) |
void |
removeOutgoingRelation(Relation r) |
int |
size() |
String |
toSExpression()
Convert this constituent into an S-Expression, including relation labels.
|
String |
toSExpression(boolean includeEdgeLabels) |
protected String |
toSExpression(int spaces,
boolean firstChild,
String prefix,
boolean includeEdgeLabels) |
String |
toString() |
protected final double constituentScore
protected final TextAnnotation textAnnotation
protected final IntPair span
protected final int startCharOffset
protected final int endCharOffset
protected final int label
protected final String viewName
Constituent#constituentTokens
is a two element
list consisting of a start and an end tokenId, specifying a span, instead of explicitly
listing the each element. This would use less memory.public Constituent(String label, String viewName, TextAnnotation text, int start, int end)
label
- label of this ConstituentviewName
- name of
View
this
Constituent belongs totext
- TextAnnotation this Constituent belongs tostart
- start token offsetend
- end token offset (one-past-the-end)public Constituent(Map<String,Double> labelsToScores, String viewName, TextAnnotation text, int start, int end)
ArgMax
.
Start, end offsets are token indexes, and use one-past-the-end indexing -- so a one-token
constituent right at the beginning of a text has start/end (0,1) offsets are relative to the
entire text span (i.e. NOT sentence-relative) This constructor assigns default score to
the constituent.labelsToScores
- set of possible labels and corresponding scores.viewName
- name of
View
this
Constituent belongs totext
- TextAnnotation this Constituent belongs tostart
- start token offsetend
- end token offset (one-past-the-end)public Constituent(String label, double score, String viewName, TextAnnotation text, int start, int end)
label
- label of this Constituentscore
- confidence in labelviewName
- name of
View
this
Constituent belongs totext
- TextAnnotation this Constituent belongs tostart
- start token offsetend
- end token offset (one-past-the-end)public Map<String,Double> getLabelsToScores()
public int getStartCharOffset()
public int getEndCharOffset()
public int getInclusiveStartCharOffset()
public int getInclusiveEndCharOffset()
public void addAttribute(String key, String value)
addAttribute
in interface HasAttributes
public boolean doesConstituentCover(int tokenId)
public boolean doesConstituentCover(Constituent other)
public boolean doesConstituentCoverAll(Collection<Integer> tokenIds)
public boolean equalsWithoutAttributeEqualityCheck(Constituent that)
that
- the input constituent you compare withpublic String getAttribute(String key)
getAttribute
in interface HasAttributes
public Set<String> getAttributeKeys()
getAttributeKeys
in interface HasAttributes
public double getConstituentScore()
public int getEndSpan()
public String getLabel()
public int getNumberOfTokens()
public int size()
public int length()
public int getStartSpan()
public IntPair getSpan()
public String getTokenizedSurfaceForm()
getSurfaceForm()
public String getSurfaceForm()
getTokenizedSurfaceForm()
public TextAnnotation getTextAnnotation()
public String getViewName()
public View getView()
public boolean hasAttribute(String key)
hasAttribute
in interface HasAttributes
public boolean isConsituentInRange(int start, int end)
public List<Relation> getOutgoingRelations()
Relation
spublic List<Relation> getIncomingRelations()
Relation
spublic String toSExpression()
public String toSExpression(boolean includeEdgeLabels)
protected String toSExpression(int spaces, boolean firstChild, String prefix, boolean includeEdgeLabels)
public int getSentenceId()
@Deprecated public TreeSet<Integer> getConstituentTokens()
public Constituent cloneForNewView(String newViewName)
public Constituent cloneForNewViewWithDestinationLabel(String newViewName, String Dlabel)
public void removeIncomingRelaton(Relation r)
public void removeAllIncomingRelatons()
public void removeOutgoingRelation(Relation r)
public void removeAllOutgoingRelaton()
public void removeAllAttributes()
removeAllAttributes
in interface HasAttributes
Copyright © 2017. All rights reserved.