Type Alias

# NLDistance

The distance between two strings in a text embedding.

## Discussion

The meaning of an `NLDistance` is directly related to the `NLDistanceType` you use when you call a method that uses it. For example, if you use the `neighbors(for:maximumCount:distanceType:)` method and use `NLDistanceTypeCosine` for the `distanceType` parameter, the method calculates the cosine distance and returns it as an `NLDistance`.

## Topics

### Calculating Distance

`NLDistanceType`

The means of calculating a distance between two locations in a text embedding.

### Finding Strings in an 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.

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