A class for finding the
k-nearest neighbors of one or more words. The {@code NearestNeighborFinder} operates by generating a set of
principlevectors that reflect average words in a {@link SemanticSpace} and thenmapping each principle vector to the set of words to which it is closest. Finding the nearest neighbor then entails finding the
k-closest principle vectors and comparing only their words, rather than all the words in the space. This dramatically reduces the search space by partitioning the vectors of the {@code SemanticSpace} into smaller sets, not all of which needto be searched.
The number of principle vectors is typically far less than the total number of vectors in the {@code SemanticSpace}, but should be more than the expected number of neighbors being searched for. This value can be optimized by minimizing the value of {@code c} in the equation {@code c = k * p + (k (|Sspace| / p))}, where {@code p} is the number of principle components,{@code k} is the number of nearest neighbors to be found, and {@code |Sspace|} is the size of the semantic space.
Instances of this class are also serializable. If the backing {@code SemanticSpace} is also serializable, the space will be saved. However, ifthe space is not serializable, its contents will be converted to a static version and saved as a copy.