Contents

neighbors(for:maximumCount:distanceType:)

Retrieves a limited number of strings near a location in the vocabulary space.

Declaration

@nonobjc func neighbors(for vector: [Double], maximumCount maxCount: Int, distanceType: NLDistanceType = .cosine) -> [(String, NLDistance)]

Parameters

  • vector:

    A location in the vocabulary space.

  • maxCount:

    The largest number of neighboring strings that the method can return in an array.

  • distanceType:

    A means of calculating distance that determines which formula the method uses to evaluate a neighbor’s distance from vector.

Return Value

An array of neighboring strings and their distances.

See Also

Finding strings and their distances in an embedding