---
title: NLDistance
framework: naturallanguage
role: symbol
role_heading: Type Alias
path: naturallanguage/nldistance
---

# NLDistance

The distance between two strings in a text embedding.

## Declaration

```swift
typealias NLDistance = Double
```

## Discussion

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 neighborsForString:maximumCount:distanceType: method and use NLDistanceType.cosine for the distanceType parameter, the method calculates the cosine distance and returns it as an NLDistance.

## Topics

### Calculating Distance

- [NLDistanceType](naturallanguage/nldistancetype.md)

## See Also

### Finding strings and their distances in an embedding

- [neighbors(for:maximumCount:distanceType:)](naturallanguage/nlembedding/neighbors(for:maximumcount:distancetype:)-8f1jc.md)
- [neighbors(for:maximumCount:distanceType:)](naturallanguage/nlembedding/neighbors(for:maximumcount:distancetype:)-8lp4z.md)
- [enumerateNeighbors(for:maximumCount:distanceType:using:)](naturallanguage/nlembedding/enumerateneighbors(for:maximumcount:distancetype:using:)-72jda.md)
- [enumerateNeighbors(for:maximumCount:distanceType:using:)](naturallanguage/nlembedding/enumerateneighbors(for:maximumcount:distancetype:using:)-6dy4x.md)
- [distance(between:and:distanceType:)](naturallanguage/nlembedding/distance(between:and:distancetype:).md)
