tokenSortRatio function

double tokenSortRatio(
  1. String s1,
  2. String s2, {
  3. double scoreCutoff = 0.0,
})

Calculates token sort ratio using the ratio algorithm

Implementation

double tokenSortRatio(String s1, String s2, {double scoreCutoff = 0.0}) {
  if (scoreCutoff > 100) return 0.0;

  // Handle edge cases according to RapidFuzz implementation
  if (s1.isEmpty || s2.isEmpty) {
    return 0.0;
  }

  var sorted1 = TokenSort._sort(s1);
  var sorted2 = TokenSort._sort(s2);

  return core.ratio(sorted1, sorted2, scoreCutoff: scoreCutoff);
}