public class RandomIndexingContextGenerator extends Object implements ContextGenerator
ContextGenerator
. This generator creates a
context vector by summing the index vectors associated with co-occurring
words. When in normal mode, an index vector is generated for every observed
word. When in read only mode, no new index vector are generated. If a
PermutationFunction
is provided, the index vectors will be permuted
based on the distance between the co-occurring word and the focus word in the
context.RandomIndexing
Constructor and Description |
---|
RandomIndexingContextGenerator(Map<String,TernaryVector> indexMap,
PermutationFunction<TernaryVector> perm,
int indexVectorLength)
Creates a new
RandomIndexingContextGenerator . |
Modifier and Type | Method and Description |
---|---|
protected void |
addContextTerms(SparseDoubleVector meaning,
Queue<String> words,
int distance)
Adds the index vector for each co-occurring word in the context.
|
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 RandomIndexingContextGenerator(Map<String,TernaryVector> indexMap, PermutationFunction<TernaryVector> perm, int indexVectorLength)
RandomIndexingContextGenerator
.indexMap
- The map responsible for mapping co-occurring terms to
their index vectors. This map should generate index vectors for
words that are not currently mapped when in normal mode.perm
- A PermutationFunction
for TernaryVector
s.indexVectorLength
- The number of dimensions in each index vector.public 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 ContextGenerator
public int getVectorLength()
getVectorLength
in interface ContextGenerator
public void setReadOnly(boolean readOnly)
ContextGenerator
. While in read
only mode, only features that previously existed will contribute to
context vectors..setReadOnly
in interface ContextGenerator
protected void addContextTerms(SparseDoubleVector meaning, Queue<String> words, int distance)
permFunc
is not null
. When in read
only mode, only existing index vector are used.Copyright © 2012. All Rights Reserved.