lib/natural/stemmers/porter_stemmer_fr.js
function regions(token) {
  var r1, r2, rv, len;
  var i;

  r1 = r2 = rv = len = token.length;

  // R1 is the region after the first non-vowel following a vowel,
  for (var i = 0; i < len - 1 && r1 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r1 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // R2 is the region after the first non-vowel following a vowel in R1
  for (i = r1; i < len - 1 && r2 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r2 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // RV region
  var three = token.slice(0, 3);
  if (isVowel(token[0]) && isVowel(token[1])) {
    rv = 3;
  }
  if (three === 'par' || three == 'col' || three === 'tap')
    rv = 3;
  // the region after the first vowel not at the beginning of the word or null
  else {
    for (i = 1; i < len - 1 && rv == len; i++) {
      if (isVowel(token[i])) {
        rv = i + 1;
      }
    }
  }

  return {
    r1: r1,
    r2: r2,
    rv: rv
  };
}
function regions(token) {
  var r1, r2, rv, len;
  var i;

  r1 = r2 = rv = len = token.length;

  // R1 is the region after the first non-vowel following a vowel,
  for (var i = 0; i < len - 1 && r1 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r1 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // R2 is the region after the first non-vowel following a vowel in R1
  for (i = r1; i < len - 1 && r2 == len; i++) {
    if (isVowel(token[i]) && !isVowel(token[i + 1])) {
      r2 = i + 2;
    }
  }
  // Or is the null region at the end of the word if there is no such non-vowel.

  // RV region
  var three = token.slice(0, 3);
  if (isVowel(token[0]) && isVowel(token[1])) {
    rv = 3;
  }
  if (three === 'par' || three == 'col' || three === 'tap')
    rv = 3;
  // the region after the first vowel not at the beginning of the word or null
  else {
    for (i = 1; i < len - 1 && rv == len; i++) {
      if (isVowel(token[i])) {
        rv = i + 1;
      }
    }
  }

  return {
    r1: r1,
    r2: r2,
    rv: rv
  };
}
function regions ( token ) { var r1 , r2 , rv , len ; var i ; r1 = r2 = rv = len = token . length ; // R1 is the region after the first non-vowel following a vowel, for ( var i = 0 ; i < len - 1 && r1 == len ; i ++ ) { if ( isVowel ( token [ i ] ) && ! isVowel ( token [ i + 1 ] ) ) { r1 = i + 2 ; } } // Or is the null region at the end of the word if there is no such non-vowel. // R2 is the region after the first non-vowel following a vowel in R1 for ( i = r1 ; i < len - 1 && r2 == len ; i ++ ) { if ( isVowel ( token [ i ] ) && ! isVowel ( token [ i + 1 ] ) ) { r2 = i + 2 ; } } // Or is the null region at the end of the word if there is no such non-vowel. // RV region var three = token . slice ( 0 , 3 ) ; if ( isVowel ( token [ 0 ] ) && isVowel ( token [ 1 ] ) ) { rv = 3 ; } if ( three === 'par' || three == 'col' || three === 'tap' ) rv = 3 ; // the region after the first vowel not at the beginning of the word or null else { for ( i = 1 ; i < len - 1 && rv == len ; i ++ ) { if ( isVowel ( token [ i ] ) ) { rv = i + 1 ; } } } return { r1 : r1 , r2 : r2 , rv : rv } ; }
Compute r1, r2, rv regions as required by french porter stemmer algorithm
@param  {String} token Word to compute regions on
@return {Object}       Regions r1, r2, rv as offsets from the begining of the word
Compute r1 r2 rv regions as required by french porter stemmer algorithm