Instance Method


Requests an array of neighboring strings and their distances to the given string.


func prediction(from text: String, maxCount: Int = 10, maxDistance: Double = 2.0, distanceType: NLDistanceType = .cosine) throws -> [(text: String, distance: Double)]



A string in the vector space.


The largest number of neighboring strings to return.


The largest distance a string can be from the given string for the method to consider it a neighbor.


The type of distance which determines which formula the method uses to calculate distance.

Return Value

An array of tuples, each of which contain a string and a double.


The method returns distance values calculated with a formula determined by NLDistanceType, such as NLDistanceType.cosine.

See Also

Testing a Word Embedding

func distance(between: String, and: String, distanceType: NLDistanceType) -> Double

Requests the distance between two strings given a distance calculation method.

enum NLDistanceType

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

func contains(String) -> Bool

Queries whether the given string is in the vocabulary.

func vector(for: String) -> [Double]?

Retrieves the vector of the string.