Esempio n. 1
0
 /**
  * Step 0: Attached pronoun
  *
  * Search for the longest among the following suffixes
  *      me   se   sela   selo   selas   selos   la   le   lo   las   les   los   nos
  *
  * and delete it, if comes after one of
  *      (a) iéndo   ándo   ár   ér   ír
  *      (b) ando   iendo   ar   er   ir
  *      (c) yendo following u
  *
  *  in RV. In the case of (c), yendo must lie in RV, but the preceding u can be outside it.
  *  In the case of (a), deletion is followed by removing the acute accent (for example, haciéndola -> haciendo).
  */
 private function step0()
 {
     if (($position = $this->searchIfInRv(array('selas', 'selos', 'las', 'los', 'les', 'nos', 'selo', 'sela', 'me', 'se', 'la', 'le', 'lo'))) != false) {
         $suffixe = Utf8::substr($this->word, $position);
         // a
         $a = array('iéndo', 'ándo', 'ár', 'ér', 'ír');
         $a = array_map(function ($item) use($suffixe) {
             return $item . $suffixe;
         }, $a);
         if (($position2 = $this->searchIfInRv($a)) !== false) {
             $suffixe2 = Utf8::substr($this->word, $position2);
             $suffixe2 = Utf8::deaccent($suffixe2, -1);
             $this->word = Utf8::substr($this->word, 0, $position2);
             $this->word .= $suffixe2;
             $this->word = Utf8::substr($this->word, 0, $position);
             return true;
         }
         // b
         $b = array('iendo', 'ando', 'ar', 'er', 'ir');
         $b = array_map(function ($item) use($suffixe) {
             return $item . $suffixe;
         }, $b);
         if (($position2 = $this->searchIfInRv($b)) !== false) {
             $this->word = Utf8::substr($this->word, 0, $position);
             return true;
         }
         // c
         if (($position2 = $this->searchIfInRv(array('yendo' . $suffixe))) != false) {
             $before = Utf8::substr($this->word, $position2 - 1, 1);
             if (isset($before) && $before == 'u') {
                 $this->word = Utf8::substr($this->word, 0, $position);
                 return true;
             }
         }
     }
     return false;
 }