Akin.SubstringSort (Akin v0.1.7) View Source

Use Chunk Sorting to compare two strings using substrings.

Ratio is based on difference in string length

  • if words are of similar in length according to Akin.Strategy.determine/2
    • ratio is String.jaro_distance
  • if words are of dissimilar in length according to Akin.Strategy.determine/2
    • ratio is Akin.SubstringComparison.similarity/2 @ratio scale (determined by Akin.Strategy)

Link to this section Summary

Functions

This strategy splits the strings on spaces, sorts the list of strings, joins them together again, and then compares them by applying the Jaro-Winkler distance metric.

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

This strategy splits the strings on spaces, sorts the list of strings, joins them together again, and then compares them by applying the Jaro-Winkler distance metric.

Examples

iex> Akin.SubstringSort.compare(Akin.Util.compose("Alice in Wonderland"), Akin.Util.compose("Alice's Adventures in Wonderland")) 0.63

iex> StringCompare.SubstringSort.substring_similarity("Oscar-Claude Monet"}, %Akin.Corpus{string: "Monet, Claude"}, Akin.Util.compose("Alice's Adventures in Wonderland")) 1.0