Type Alias

NLDistance

The distance between two strings in a text embedding.

Declaration

typealias NLDistance = Double

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

Topics

Calculating Distance

enum NLDistanceType

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

See Also

Finding Strings in an Embedding

func neighbors(for: String, maximumCount: Int, distanceType: NLDistanceType) -> [(String, NLDistance)]

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

func neighbors(for: [Double], maximumCount: Int, distanceType: NLDistanceType) -> [(String, NLDistance)]

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

func enumerateNeighbors(for: String, maximumCount: Int, distanceType: NLDistanceType, using: (String, NLDistance) -> Bool)

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

func enumerateNeighbors(for: [Double], maximumCount: Int, distanceType: NLDistanceType, using: (String, NLDistance) -> Bool)

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