public abstract class AbstractOccurrenceDependencyContextGenerator extends Object implements DependencyContextGenerator
DependencyContextGenerator
that creates a context vector
for a node in an array of DependencyTreeNode
s by using any form of
co-occurrence information in the tree. The windowSize
words prior to
the focus word will be marked as having a negative index with respect to the
focus word and the words after the focus word will be marked with a positive
index. Subclasses need only implement getFeature
.Constructor and Description |
---|
AbstractOccurrenceDependencyContextGenerator(BasisMapping<String,String> basis,
int windowSize)
Constructs a new
AbstractOccurrenceDependencyContextGenerator . |
Modifier and Type | Method and Description |
---|---|
protected void |
addContextTerms(SparseDoubleVector meaning,
Queue<String> words,
int distance)
Adds a feature for each word in the context that has a valid dimension.
|
SparseDoubleVector |
generateContext(DependencyTreeNode[] tree,
int focusIndex)
Returns a
SparseDoubleVector that represents the context composed
of the set of prevWords before the focus word and the set of
nextWords after the focus word. |
protected abstract String |
getFeature(DependencyTreeNode node,
int dist)
Returns a string representing the
DependencyTreeNode which is
dist nodes away from the focus word currently being processed. |
int |
getVectorLength()
Returns the maximum number of dimensions used to represent any given
context.
|
void |
setReadOnly(boolean readOnly)
Sets the read only mode of the
ContextGenerator . |
public AbstractOccurrenceDependencyContextGenerator(BasisMapping<String,String> basis, int windowSize)
AbstractOccurrenceDependencyContextGenerator
.public SparseDoubleVector generateContext(DependencyTreeNode[] tree, int focusIndex)
SparseDoubleVector
that represents the context composed
of the set of prevWords
before the focus word and the set of
nextWords
after the focus word. Since sparse vectors are
returned, if a second order vector is generated, it is recommended that
the vector also be sparsed or have very few dimensions.generateContext
in interface DependencyContextGenerator
protected abstract String getFeature(DependencyTreeNode node, int dist)
DependencyTreeNode
which is
dist
nodes away from the focus word currently being processed.protected void addContextTerms(SparseDoubleVector meaning, Queue<String> words, int distance)
public int getVectorLength()
getVectorLength
in interface DependencyContextGenerator
public void setReadOnly(boolean readOnly)
ContextGenerator
. When set to
read only, it prevents any new features from being generated.setReadOnly
in interface DependencyContextGenerator
Copyright © 2012. All Rights Reserved.