Akin.Ngram (Akin v0.1.6) View Source

Functions to calculate the ngram distance between two given strings based on this paper

Link to this section Summary

Functions

Calculates the ngram similarity between two given strings with a specified ngram size

Link to this section Functions

Link to this function

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

View Source

Specs

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()

Calculates the ngram similarity between two given strings with a specified ngram size

Examples

iex> Akin.Ngram.compare(%Akin.Corpus{string: "night"}, %Akin.Corpus{string: "naght"}, [ngram_size: 3]) 0.3333333333333333 iex> Akin.Ngram.compare(%Akin.Corpus{string: "context"}, %Akin.Corpus{string: "contact"}, [ngram_size: 1]) 0.7142857142857143