public class BagOfWordsTransform extends DefaultVectorFactoryContainer implements Evaluator<java.lang.Iterable<? extends Termable>,Vector>
Modifier and Type | Field and Description |
---|---|
protected TermIndex |
termIndex
Gets the term index used by the transform.
|
vectorFactory
Constructor and Description |
---|
BagOfWordsTransform()
Creates a new
BagOfWordsTransform . |
BagOfWordsTransform(TermIndex termIndex)
Creates a new
BagOfWordsTransform with the given term index. |
BagOfWordsTransform(TermIndex termIndex,
VectorFactory<? extends Vector> vectorFactory)
Creates a new
BagOfWordsTransform with the given term index. |
Modifier and Type | Method and Description |
---|---|
Vector |
convertToVector(java.lang.Iterable<? extends Termable> terms)
Converts a given list of terms to a vector by counting the occurrence of
each term.
|
static Vector |
convertToVector(java.lang.Iterable<? extends Termable> terms,
TermIndex termIndex,
VectorFactory<?> vectorFactory)
Converts a given list of terms to a vector by counting the occurrence of
each term.
|
Vector |
convertToVector(java.lang.Iterable<? extends Termable> terms,
VectorFactory<?> vectorFactory)
Converts a given list of terms to a vector by counting the occurrence of
each term.
|
Vector |
evaluate(java.lang.Iterable<? extends Termable> terms)
Evaluates the function on the given input and returns the output.
|
TermIndex |
getTermIndex()
Gets the term index that the transform uses to map terms to their vector
indices.
|
void |
setTermIndex(TermIndex termIndex)
Sets the term index that the transform is to use to map terms to their
vector indices.
|
getVectorFactory, setVectorFactory
clone
protected TermIndex termIndex
public BagOfWordsTransform()
BagOfWordsTransform
. Starts with an empty term
index.public BagOfWordsTransform(TermIndex termIndex)
BagOfWordsTransform
with the given term index.termIndex
- The term index to use to map terms to vector indices.public BagOfWordsTransform(TermIndex termIndex, VectorFactory<? extends Vector> vectorFactory)
BagOfWordsTransform
with the given term index.termIndex
- The term index to use to map terms to vector indices.vectorFactory
- The vector factory to use.public Vector evaluate(java.lang.Iterable<? extends Termable> terms)
Evaluator
public Vector convertToVector(java.lang.Iterable<? extends Termable> terms)
terms
- The terms to count.public Vector convertToVector(java.lang.Iterable<? extends Termable> terms, VectorFactory<?> vectorFactory)
terms
- The terms to count.vectorFactory
- The vector factory to use to create the vector.public static Vector convertToVector(java.lang.Iterable<? extends Termable> terms, TermIndex termIndex, VectorFactory<?> vectorFactory)
terms
- The terms to count.termIndex
- The term index to use to map terms to their vector indices.vectorFactory
- The vector factory to use to create the vector.public TermIndex getTermIndex()
public void setTermIndex(TermIndex termIndex)
termIndex
- The term index for the transform to use.