Instance Method

neighborsForString:maximumCount:distanceType:

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

Declaration

- (NSArray<NSString *> *)neighborsForString:(NSString *)string maximumCount:(NSUInteger)maxCount distanceType:(NLDistanceType)distanceType;

Parameters

string

A string in the embedding vocabulary.

maxCount

The largest number of neighboring strings to find.

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: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.

- neighborsForVector:maximumCount:maximumDistance:distanceType:

Retrieves the nearest strings to a vector, given a distance, 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.