Contents

enumerateNeighbors(for:maximumCount:distanceType:using:)

Passes the nearest strings of a string in the vocabulary to a closure.

Declaration

@nonobjc func enumerateNeighbors(for string: String, maximumCount maxCount: Int, distanceType: NLDistanceType = .cosine, using block: (String, NLDistance) -> Bool)

Parameters

  • string:

    A string in the embedding vocabulary.

  • maxCount:

    The largest number of times the method calls block.

  • distanceType:

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

  • block:

    A closure with the following parameters:

    String

    A neighboring string.

    NLDistance

    The distance from string to the neighboring string.

    The closure returns a Boolean that indicates whether to stop enumerating neighbors.

See Also

Finding strings and their distances in an embedding