Instance Method

neighborsForVector:maximumCount:maximumDistance:distanceType:

Retrieves the nearest strings to a vector, given a distance, a number of neighbors, and a distance type.

Declaration

- (NSArray<NSString *> *)neighborsForVector:(NSArray<NSNumber *> *)vector maximumCount:(NSUInteger)maxCount maximumDistance:(NLDistance)maxDistance distanceType:(NLDistanceType)distanceType;

Parameters

vector

A location in the vocabulary space.

maxCount

The largest number of neighboring strings to find.

maxDistance

The largest distance a neighbor can be from the given vector.

distanceType

The type of distance, which determines the formula the method uses to calculate distance.

Return Value

An array of terms.

See Also

Finding Strings in an Embedding

NLDistance

The distance between two strings in a text embedding.

- distanceBetweenString:andString:distanceType:

Calculates the distance between two strings.

- neighborsForString:maximumCount:distanceType:

Retrieves the nearest neighbors of a string, given a number of neighbors and a distance type.

- neighborsForString:maximumCount:maximumDistance:distanceType:

Retrieves the nearest neighbors of a string, given a distance, a number of neighbors, and a distance type.

- neighborsForVector:maximumCount:distanceType:

Retrieves the nearest strings to a vector, given a number of neighbors and a distance type.

- enumerateNeighborsForString:maximumCount:distanceType:usingBlock:

Enumerates the nearest neighbors of a string, given a closure, a number of neighbors, and a distance type.

- enumerateNeighborsForString:maximumCount:maximumDistance:distanceType:usingBlock:

Enumerates the nearest neighbors of a string, given a closure, a distance, a number of neighbors, and a distance type.

- enumerateNeighborsForVector:maximumCount:distanceType:usingBlock:

Enumerates the nearest strings of a vector, given a closure, a number of neighbors, and a distance type.

- enumerateNeighborsForVector:maximumCount:maximumDistance:distanceType:usingBlock:

Enumerates the nearest strings of a vector, given a closure, a distance, a number of neighbors, and a distance type.