public class SimpleNearestNeighborFinder extends Object implements NearestNeighborFinder
NearestNeighborFinder
implemetnation for finding the k
most-similar words to a provided word in a SemanticSpace
using a
brute-force search. The comparisons required for generating the list maybe
be run in parallel by configuring an instance of this class to use multiple
threads.
All instances of this class are thread-safe.
Constructor and Description |
---|
SimpleNearestNeighborFinder(SemanticSpace sspace)
Creates this
SimpleNearestNeighborFinder with as many threads as
processors, and using the cosine similarity for word comparisons. |
SimpleNearestNeighborFinder(SemanticSpace sspace,
int numThreads)
Creates this
SimpleNearestNeighborFinder with the specified
number of threads, using the cosine similarity for word comparisons. |
SimpleNearestNeighborFinder(SemanticSpace sspace,
SimilarityFunction similarity)
Creates this
SimpleNearestNeighborFinder with as many threads as
processings and using the provided similarity function to compare words. |
SimpleNearestNeighborFinder(SemanticSpace sspace,
SimilarityFunction similarity,
int numThreads)
Creates this
SimpleNearestNeighborFinder with the specified
number of threads and using the provided similarity function to compare
words. |
Modifier and Type | Method and Description |
---|---|
SortedMultiMap<Double,String> |
getMostSimilar(Set<String> terms,
int numberOfSimilarWords)
Finds the k most similar words in the semantic space according to
the cosine similarity, returning a mapping from their similarity to the
word itself.
|
SortedMultiMap<Double,String> |
getMostSimilar(String word,
int numberOfSimilarWords)
Finds the k most similar words in the semantic space according to
the cosine similarity, returning a mapping from their similarity to the
word itself.
|
SortedMultiMap<Double,String> |
getMostSimilar(Vector v,
int numberOfSimilarWords)
Finds the k most similar words in the semantic space according to
the cosine similarity, returning a mapping from their similarity to the
word itself.
|
public SimpleNearestNeighborFinder(SemanticSpace sspace)
SimpleNearestNeighborFinder
with as many threads as
processors, and using the cosine similarity for word comparisons.public SimpleNearestNeighborFinder(SemanticSpace sspace, int numThreads)
SimpleNearestNeighborFinder
with the specified
number of threads, using the cosine similarity for word comparisons.public SimpleNearestNeighborFinder(SemanticSpace sspace, SimilarityFunction similarity)
SimpleNearestNeighborFinder
with as many threads as
processings and using the provided similarity function to compare words.public SimpleNearestNeighborFinder(SemanticSpace sspace, SimilarityFunction similarity, int numThreads)
SimpleNearestNeighborFinder
with the specified
number of threads and using the provided similarity function to compare
words.public SortedMultiMap<Double,String> getMostSimilar(String word, int numberOfSimilarWords)
getMostSimilar
in interface NearestNeighborFinder
null
if the provided word was
not in the semantic space.public SortedMultiMap<Double,String> getMostSimilar(Set<String> terms, int numberOfSimilarWords)
getMostSimilar
in interface NearestNeighborFinder
null
if none of the provided
word were not in the semantic space.public SortedMultiMap<Double,String> getMostSimilar(Vector v, int numberOfSimilarWords)
getMostSimilar
in interface NearestNeighborFinder
Copyright © 2012. All Rights Reserved.