src/metrics/distance/ratcliff-obershelp.js
function matches(a, b) {
  const stack = [a, b];

  let m = 0;

  while (stack.length) {
    a = stack.pop();
    b = stack.pop();

    if (!a.length || !b.length)
      continue;

    const lcs = (new GeneralizedSuffixArray([a, b]).longestCommonSubsequence()),
          length = lcs.length;

    if (!length)
      continue;

    // Increasing matches
    m += length;

    // Add to the stack
    const aStart = indexOf(a, lcs),
          bStart = indexOf(b, lcs);

    stack.push(a.slice(0, aStart), b.slice(0, bStart));
    stack.push(a.slice(aStart + length), b.slice(bStart + length));
  }

  return m;
}
function matches(a, b) {
  const stack = [a, b];

  let m = 0;

  while (stack.length) {
    a = stack.pop();
    b = stack.pop();

    if (!a.length || !b.length)
      continue;

    const lcs = (new GeneralizedSuffixArray([a, b]).longestCommonSubsequence()),
          length = lcs.length;

    if (!length)
      continue;

    // Increasing matches
    m += length;

    // Add to the stack
    const aStart = indexOf(a, lcs),
          bStart = indexOf(b, lcs);

    stack.push(a.slice(0, aStart), b.slice(0, bStart));
    stack.push(a.slice(aStart + length), b.slice(bStart + length));
  }

  return m;
}
function matches ( a , b ) { const stack = [ a , b ] ; let m = 0 ; while ( stack . length ) { a = stack . pop ( ) ; b = stack . pop ( ) ; if ( ! a . length || ! b . length ) continue ; const lcs = ( new GeneralizedSuffixArray ( [ a , b ] ) . longestCommonSubsequence ( ) ) , length = lcs . length ; if ( ! length ) continue ; // Increasing matches m += length ; // Add to the stack const aStart = indexOf ( a , lcs ) , bStart = indexOf ( b , lcs ) ; stack . push ( a . slice ( 0 , aStart ) , b . slice ( 0 , bStart ) ) ; stack . push ( a . slice ( aStart + length ) , b . slice ( bStart + length ) ) ; } return m ; }
Function returning the number of Ratcliff-Obershelp matches. This works
by finding the LCS of both strings before recursively finding the LCS
of the substrings both before and after the LCS in the initial strings and
so on...

@param  {mixed}  a  - The first sequence to process.
@param  {mixed}  b  - The second sequence to process.
@return {number}    - The number of matches.
Function returning the number of Ratcliff - Obershelp matches . This works by finding the LCS of both strings before recursively finding the LCS of the substrings both before and after the LCS in the initial strings and so on ...