public class WordOccrrenceContextGenerator extends Object implements ContextGenerator
ContextGenerator. Each co-occurring word is
mapped to a unique dimension and feature scores are based on the distance
between the co-occurring word and the focus word in a particular context.| Constructor and Description |
|---|
WordOccrrenceContextGenerator(BasisMapping<String,String> basis,
WeightingFunction weighting,
int windowSize)
Creates a new
WordOccrrenceContextGenerator. |
| 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(Queue<String> prevWords,
Queue<String> nextWords)
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. |
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 WordOccrrenceContextGenerator(BasisMapping<String,String> basis, WeightingFunction weighting, int windowSize)
WordOccrrenceContextGenerator.weighting - The WeightingFunction used to score each word
co-occrrence, based on the distance from the focus wordwindowSize - The size of the sliding symmetric window composing a
contextpublic SparseDoubleVector generateContext(Queue<String> prevWords, Queue<String> nextWords)
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 ContextGeneratorpublic int getVectorLength()
getVectorLength in interface ContextGeneratorpublic void setReadOnly(boolean readOnly)
ContextGenerator. While in read
only mode, only features that previously existed will contribute to
context vectors.setReadOnly in interface ContextGeneratorprotected void addContextTerms(SparseDoubleVector meaning, Queue<String> words, int distance)
Copyright © 2012. All Rights Reserved.