public class View extends Object implements Serializable, IQueryable<Constituent>
The nodes are objects of type Constituent
and the edges are objects of type
Relation
.
This class represents a generic view without any restrictions on the structure of the graph and can be used for general purpose application specific views. However, for most standard annotations can be represented as one of the sub-classes of this class.
Constituent
,
Relation
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected QueryableList<Constituent> |
constituents
The collection of constituents
|
protected int |
endSpan
The token id of the token next to the rightmost token in this view.
|
protected QueryableList<Relation> |
relations
The collection of relations in this view.
|
protected double |
score
The score of this view, which is generated by the system that annotates this view.
|
protected int |
startSpan
The token id of the leftmost token in this view.
|
protected TextAnnotation |
textAnnotation
The TextAnnotation that is annotated by this view.
|
protected ArrayList[] |
tokensToConstituents
A inverted index from token ids to constituents in this view that cover that token.
|
protected String |
viewGenerator
The name of the system that generates this view.
|
protected String |
viewName
The name of this view.
|
Constructor and Description |
---|
View(String viewName,
String viewGenerator,
TextAnnotation text,
double score)
Creates a view for
text called viewName which is created using a view
generator called ViewGenerator and is assigned a score score |
Modifier and Type | Method and Description |
---|---|
void |
addConstituent(Constituent constituent)
Adds a new constituent to this view
|
void |
addRelation(Relation relation)
Adds a new relation to this view.
|
boolean |
containsConstituent(Constituent c)
Checks if this view contains a constituent
|
int |
count()
Get the number of records in this iterator.
|
List<Constituent> |
getConstituents()
Returns the constituents contained in this view.
|
List<Constituent> |
getConstituentsCovering(Constituent c)
Get the constituents which cover the input constituent
c . |
List<Constituent> |
getConstituentsCoveringCharSpan(int charStart,
int charEnd)
Given char-begin-offset and char-end-offset, it returns the constituents covering it.
|
List<Constituent> |
getConstituentsCoveringSpan(int start,
int end) |
List<Constituent> |
getConstituentsCoveringToken(int tokenId) |
List<Constituent> |
getConstituentsCoveringTokens(Collection<Integer> tokenIds) |
List<Constituent> |
getConstituentsOverlappingCharSpan(int charStart,
int charEnd)
Given char-begin-offset and char-end-offset, it returns the constituents with some overlap with the input char offsets.
|
List<Constituent> |
getConstituentsWithSpan(IntPair span) |
int |
getEndSpan() |
protected Set<Constituent> |
getFilteredConstituents(Predicate<Constituent> predicate) |
List<String> |
getLabelsCovering(Constituent c)
Get the labels of the constituents covered by the input constituent
c |
List<String> |
getLabelsCoveringSpan(int start,
int end) |
List<String> |
getLabelsCoveringToken(int tokenId) |
List<String> |
getLabelsCoveringTokens(Collection<Integer> tokenIds) |
int |
getNumberOfConstituents() |
List<Relation> |
getRelations() |
View |
getRestrictedView(Predicate<Constituent> constituentPredicate,
ITransformer<View,Double> scoreTransformer) |
double |
getScore() |
int |
getStartSpan() |
TextAnnotation |
getTextAnnotation() |
View |
getViewCoveringSpan(int start,
int end,
ITransformer<View,Double> scoreTransformer) |
View |
getViewCoveringToken(int token,
ITransformer<View,Double> scoreTransformer) |
View |
getViewCoveringTokens(Collection<Integer> tokens,
ITransformer<View,Double> scoreTransformer) |
String |
getViewGenerator() |
String |
getViewName() |
Iterator<Constituent> |
iterator() |
IQueryable<Constituent> |
orderBy(Comparator<Constituent> comparator)
Returns a queryable iterator, where the elements of this iterator are sorted using the
comparator.
|
void |
removeAllConsituents() |
void |
removeAllRelations() |
void |
removeAttributes()
Removes all the attributes from the constituents of this of this view
|
void |
removeConstituent(Constituent constituent)
Removes a constituent from this view.
|
void |
removeRelation(Relation relation)
removes a relation from this view.
|
<S> IQueryable<S> |
select(ITransformer<Constituent,S> transformer)
Given a transformer that converts objects of type T to those of type S, this function returns
a new queryable iterator, containing objects of type S which are created by applying the
transformer to each element of this iterator.
|
IQueryable<Constituent> |
unique()
Get a queryable iterator containing the unique elements of this iterator.
|
IQueryable<Constituent> |
where(Predicate<Constituent> condition)
Get a queryable iterator that contains the elements of this iterator which satisfy the
condition.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected final String viewName
ViewNames
.protected final double score
protected final TextAnnotation textAnnotation
protected final QueryableList<Constituent> constituents
protected final QueryableList<Relation> relations
protected final String viewGenerator
protected final ArrayList[] tokensToConstituents
The first element corresponds to the token id, the second corresponds to the constituent .
protected int startSpan
protected int endSpan
public View(String viewName, String viewGenerator, TextAnnotation text, double score)
text
called viewName
which is created using a view
generator called ViewGenerator
and is assigned a score score
viewName
- The name of this viewviewGenerator
- The source of this viewtext
- The text annotation that this view annotatesscore
- The score of this viewpublic void addConstituent(Constituent constituent)
constituent
- The new constituent to be added.public void removeConstituent(Constituent constituent)
public void addRelation(Relation relation)
relation
- The relation to be addedpublic void removeRelation(Relation relation)
public void removeAllRelations()
public void removeAllConsituents()
public void removeAttributes()
public boolean containsConstituent(Constituent c)
c
- The constituent, whose containership needs to be checked.true
if this view contains the constituentpublic List<Constituent> getConstituents()
public List<Constituent> getConstituentsCovering(Constituent c)
c
.c
- A constituent, not necessarily of this text annotation.public List<String> getLabelsCovering(Constituent c)
c
c
- A constituent, not necessarily of this text annotation.public List<String> getLabelsCoveringTokens(Collection<Integer> tokenIds)
public List<Constituent> getConstituentsCoveringSpan(int start, int end)
public List<Constituent> getConstituentsCoveringCharSpan(int charStart, int charEnd)
charStart
- the begin char indexcharEnd
- the end char index (one-past-the-end indexing)public List<Constituent> getConstituentsOverlappingCharSpan(int charStart, int charEnd)
charStart
- the begin char indexcharEnd
- the end char index (one-past-the-end indexing)public List<Constituent> getConstituentsWithSpan(IntPair span)
public List<Constituent> getConstituentsCoveringTokens(Collection<Integer> tokenIds)
public List<Constituent> getConstituentsCoveringToken(int tokenId)
public int getEndSpan()
protected Set<Constituent> getFilteredConstituents(Predicate<Constituent> predicate)
public int getNumberOfConstituents()
public View getRestrictedView(Predicate<Constituent> constituentPredicate, ITransformer<View,Double> scoreTransformer)
public double getScore()
public int getStartSpan()
public TextAnnotation getTextAnnotation()
public View getViewCoveringSpan(int start, int end, ITransformer<View,Double> scoreTransformer)
public View getViewCoveringToken(int token, ITransformer<View,Double> scoreTransformer)
public View getViewCoveringTokens(Collection<Integer> tokens, ITransformer<View,Double> scoreTransformer)
public String getViewName()
ViewNames
.public String getViewGenerator()
public IQueryable<Constituent> orderBy(Comparator<Constituent> comparator)
IQueryable
orderBy
in interface IQueryable<Constituent>
comparator
- The comparator for type Tpublic <S> IQueryable<S> select(ITransformer<Constituent,S> transformer)
IQueryable
select
in interface IQueryable<Constituent>
S
- The type of the elements of the returned iteratortransformer
- An ITransformer
that converts objects of type T to those of type Spublic IQueryable<Constituent> unique()
IQueryable
unique
in interface IQueryable<Constituent>
public IQueryable<Constituent> where(Predicate<Constituent> condition)
IQueryable
where
in interface IQueryable<Constituent>
condition
- A Predicate
, which takes
an object of type T and returns true/false.public Iterator<Constituent> iterator()
iterator
in interface Iterable<Constituent>
public int count()
IQueryable
count
in interface IQueryable<Constituent>
Copyright © 2017. All rights reserved.