Instance Method

distance(between:and:distanceType:)

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

Declaration

func distance(between first: String, and second: String, distanceType: NLDistanceType = .cosine) -> Double

Parameters

first

A term in the vector space.

second

Another term in the vector space.

distanceType

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

Return Value

A double.

Discussion

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

See Also

Testing a Word Embedding

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.