View Source Akin.Tversky (Akin v0.2.0)

Functions to calculate the Tversky index between two strings.

Summary

Functions

Calculates the Tversky index between two strings. Default alpha is 1 and beta is 1. ngram_size is a positive integer greater than 0 used to tokenize the strings

Functions

Link to this function

compare(left, right, opts \\ [])

View Source
@spec compare(
  %Akin.Corpus{
    list: term(),
    original: term(),
    set: term(),
    stems: term(),
    string: term()
  },
  %Akin.Corpus{
    list: term(),
    original: term(),
    set: term(),
    stems: term(),
    string: term()
  },
  Keyword.t()
) :: float()
@spec compare(
  %Akin.Corpus{
    list: term(),
    original: term(),
    set: term(),
    stems: term(),
    string: term()
  },
  %Akin.Corpus{
    list: term(),
    original: term(),
    set: term(),
    stems: term(),
    string: term()
  },
  integer()
) :: float()

Calculates the Tversky index between two strings. Default alpha is 1 and beta is 1. ngram_size is a positive integer greater than 0 used to tokenize the strings

Examples

iex> Akin.Tversky.compare(%Akin.Corpus{string: "contact"}, %Akin.Corpus{string: "context"}, [ngram_size: 4]) 0.14285714285714285 iex> Akin.Tversky.compare(%Akin.Corpus{string: "contact"}, %Akin.Corpus{string: "context"}) 0.3333333333333333 iex> Akin.Tversky.compare(%Akin.Corpus{string: "contact"}, %Akin.Corpus{string: "context"}, [ngram_size: 1]) 0.5555555555555556