|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.whatswrong.NLPInstance
public class NLPInstance
An NLPInstance represents a sentence or any other kind of utterance and some of its (NLP) properties. Properties of sentence are its tokens, that have their own properties, and edges between tokens. Such edges can represent syntactic or semantic dependencies, such as SRL predicate-argument relations, as well as annotated spans (such as NP chunks or NER entities).
Nested Class Summary | |
---|---|
static class |
NLPInstance.RenderType
|
Constructor Summary | |
---|---|
NLPInstance()
Creates an empty NLPInstance without edges or tokens. |
|
NLPInstance(java.util.Collection<Token> tokens,
java.util.Collection<Edge> edges,
NLPInstance.RenderType renderType,
java.util.List<java.lang.Integer> splitPoints)
Creates a new NLPInstance with the given tokens and edges. |
Method Summary | |
---|---|
void |
addDependency(int from,
int to,
java.lang.String label,
java.lang.String type)
Creates and adds an edge with rendertype Edge.RenderType.dependency |
void |
addEdge(Edge edge)
Adds an edge. |
void |
addEdge(int from,
int to,
java.lang.String label,
java.lang.String type)
Creates and adds an edge from the token at the given 'from' index to the token at the given 'to' index with the given label and type. |
void |
addEdge(int from,
int to,
java.lang.String label,
java.lang.String type,
Edge.RenderType renderType)
Creates and adds a new edge with the given properties. |
void |
addEdge(Token from,
Token to,
java.lang.String label,
java.lang.String type)
Creates and adds an edge with the given properties. |
void |
addEdge(Token from,
Token to,
java.lang.String label,
java.lang.String type,
Edge.RenderType renderType)
Creates and adds an edge with the given properties. |
void |
addEdges(java.util.Collection<Edge> edges)
Adds the given edges to this instance. |
void |
addSpan(int from,
int to,
java.lang.String label,
java.lang.String type)
Creates and adds an edge with rendertype Edge.RenderType.span |
void |
addSplitPoint(int tokenIndex)
Add a split point token index. |
Token |
addToken()
Adds a new token and returns it. |
Token |
addToken(int index)
Adds a token at a certain index. |
void |
addTokens(java.util.Collection<Token> tokens)
Adds the given collection of tokens to this instance. |
void |
addTokenWithProperties(java.lang.String... properties)
Adds token that has the provided properties with default property names. |
void |
consistify()
If tokesn were added with addToken(int) this method ensures that
all internal representations of the token sequence are consistent. |
java.util.List<Edge> |
getEdges()
Returns all edges of this instance. |
java.util.List<Edge> |
getEdges(Edge.RenderType renderType)
Returns all edges of this instance with the given render type. |
NLPInstance.RenderType |
getRenderType()
Returns the render type that controls which renderer to use. |
java.util.List<java.lang.Integer> |
getSplitPoints()
Returns the list of split points for this instance. |
Token |
getToken(int index)
Returns the token at the given index. |
java.util.List<Token> |
getTokens()
Returns a list of all tokens in this instance. |
void |
merge(NLPInstance nlp)
Merges the given instance with this instance. |
void |
setRenderType(NLPInstance.RenderType renderType)
Sets the render type for this instance. |
java.lang.String |
toString()
Returns a string representation of this instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NLPInstance()
public NLPInstance(java.util.Collection<Token> tokens, java.util.Collection<Edge> edges, NLPInstance.RenderType renderType, java.util.List<java.lang.Integer> splitPoints)
tokens
- the tokens of the sentence.edges
- the edges of the sentence.renderType
- the render type for the instance.splitPoints
- the points at which the instance can be split.Method Detail |
---|
public NLPInstance.RenderType getRenderType()
public void setRenderType(NLPInstance.RenderType renderType)
renderType
- the render type for this instance.public void addEdge(int from, int to, java.lang.String label, java.lang.String type)
from
- index of the token the edge should start at. The token at the given index must already exist in the
sentence.to
- index of the token edge should end at. The token at the given index must already exist in the
sentence.label
- the label of the edge.type
- the type of edge.Edge
public void addEdge(int from, int to, java.lang.String label, java.lang.String type, Edge.RenderType renderType)
from
- index of the token the edge should start at. The token at the given index must already exist in
the sentence.to
- index of the token edge should end at. The token at the given index must already exist in the
sentence.label
- the label of the edge.type
- the type of edge.renderType
- the render type of the edge.Edge
public void addEdge(Edge edge)
edge
- the edge to add.public void addSpan(int from, int to, java.lang.String label, java.lang.String type)
Edge.RenderType.span
from
- index of the token the edge should start at. The token at the given index must already exist in the
sentence.to
- index of the token edge should end at. The token at the given index must already exist in the
sentence.label
- the label of the edge.type
- the type of edge.Edge
public void addDependency(int from, int to, java.lang.String label, java.lang.String type)
Edge.RenderType.dependency
from
- index of the token the edge should start at. The token at the given index must already exist in the
sentence.to
- index of the token edge should end at. The token at the given index must already exist in the
sentence.label
- the label of the edge.type
- the type of edge.Edge
public void addEdge(Token from, Token to, java.lang.String label, java.lang.String type)
from
- The start token. The created edge will start at the token of this sentence with the same index as
the provided token. This means the start token of created edge does not need to be equal to the
provided token -- they just have to have the same index.to
- the end token. The created edge will end at the token of this sentence with the same index as the
provided token. This means that the end token of created edge does not need to be equal to the
provided token -- they just have to have the same index.label
- the label of the edge.type
- the type of edge.Edge
public void addEdge(Token from, Token to, java.lang.String label, java.lang.String type, Edge.RenderType renderType)
from
- The start token. The created edge will start at the token of this sentence with the same index
as the provided token. This means the start token of created edge does not need to be equal to
the provided token -- they just have to have the same index.to
- the end token. The created edge will end at the token of this sentence with the same index as
the provided token. This means that the end token of created edge does not need to be equal to
the provided token -- they just have to have the same index.label
- the label of the edge.type
- the type of edge.renderType
- the render type of the edge.Edge
public void addTokens(java.util.Collection<Token> tokens)
tokens
- the tokens to add.public void addEdges(java.util.Collection<Edge> edges)
edges
- the edges to add.public void merge(NLPInstance nlp)
nlp
. It will also add every edge between i and i in the given instance
nlp
as an edge between the tokens i and j of this instance, using the same type, label and
rendertype as the original edge.
nlp
- the instance to merge into this instance.public void addTokenWithProperties(java.lang.String... properties)
properties
- an vararray of strings.public Token addToken()
public Token addToken(int index)
consistify()
when you are
done.
index
- the index of the token to add.
public void consistify()
addToken(int)
this method ensures that
all internal representations of the token sequence are consistent.
public void addSplitPoint(int tokenIndex)
tokenIndex
- a token index at which the instance should be split.public java.util.List<java.lang.Integer> getSplitPoints()
public java.util.List<Edge> getEdges()
public java.util.List<Edge> getEdges(Edge.RenderType renderType)
renderType
- the render type of the edges to return.
public Token getToken(int index)
index
- the index of the token to return
public java.util.List<Token> getTokens()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |