public abstract class AbstractTextAnnotation extends Object implements Serializable
This class stores the raw text, the tokens and the list of views available for the text and provides methods for adding new views.
TextAnnotation}, {@link Sentence}
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected String |
text
The raw text
|
protected edu.illinois.cs.cogcomp.core.datastructures.IntPair[] |
tokenCharacterOffsets
The character offsets of the tokens.
|
protected String |
tokenizedText
The tokenized text
|
protected String[] |
tokens
The list of tokens in the text.
|
protected Map<String,List<View>> |
views
The list of views
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractTextAnnotation() |
Modifier and Type | Method and Description |
---|---|
void |
addView(String viewName,
List<View> view)
Adds a new view identified by
viewName and sets the top K values
for this view. |
void |
addView(String viewName,
View view)
Adds the top scoring value for the view identified by
viewName . |
Set<String> |
getAvailableViews()
Gets the set of views that are available
|
String |
getDetokenizedText()
Deprecated.
|
String |
getText()
Gets the raw text
|
String |
getToken(int position)
Get the token at position from this text
|
edu.illinois.cs.cogcomp.core.datastructures.IntPair |
getTokenCharacterOffset(int position)
Get the character offset of the token at position in the raw text.
|
String |
getTokenizedText()
Gets the tokenized text.
|
String[] |
getTokens()
Gets the tokens in this text.
|
String[] |
getTokensInSpan(int start,
int end)
Gets the tokens in the span.
|
List<View> |
getTopKViews(String viewName)
Get all the values available for a given view, identified by
viewName |
View |
getView(String viewName)
Gets the highest scoring value for the view identified by
viewName . |
boolean |
hasView(String viewName)
Checks if this text annotation has a view identified by
viewName |
edu.illinois.cs.cogcomp.core.datastructures.IQueryable<Constituent> |
select(String viewName)
Gets a queryable list of all constituents from the view, represented by
viewName . |
int |
size()
Get the number of tokens in this text.
|
protected String text
protected String[] tokens
protected edu.illinois.cs.cogcomp.core.datastructures.IntPair[] tokenCharacterOffsets
protected String tokenizedText
public void addView(String viewName, List<View> view)
viewName
and sets the top K values
for this view.viewName
- The name of the new view to be added.view
- The top K viewspublic void addView(String viewName, View view)
viewName
.viewName
- view
- public Set<String> getAvailableViews()
Set<String>
of views that are available for this text
annotation.public View getView(String viewName)
viewName
.viewName
- public List<View> getTopKViews(String viewName)
viewName
viewName
- public String getText()
public String getTokenizedText()
public String[] getTokens()
public String getToken(int position)
position
- public edu.illinois.cs.cogcomp.core.datastructures.IntPair getTokenCharacterOffset(int position)
position
- IntPair
representing the pair (start, end+1)public String[] getTokensInSpan(int start, int end)
start
- The start of the spanend
- The end of the spanpublic boolean hasView(String viewName)
viewName
viewName
- true
if the text annotation contains a view called
viewName
and false
otherwisepublic int size()
@Deprecated public String getDetokenizedText()
public edu.illinois.cs.cogcomp.core.datastructures.IQueryable<Constituent> select(String viewName)
viewName
. This function can be used for SQL-like queries on the
text.
Examples: In all the examples that follow, we assume that text
is
a variable of type AbstractTextAnnotation
.
srlConstituent
from the SRL_VERB view, find
all constituents in the parse view that cover exactly this constituent.
List<Constituent> parseConstituent = text.select(ViewNames.PARSE).where( Queries.sameSpanAsConstituent(srlConstituent));
viewName
- QueryableList
,
ViewNames
Copyright © 2015. All rights reserved.