コード例 #1
0
 public function test_participle()
 {
     $inf = 'éclairer';
     $got_participle = LinguaFRParticiple::participle($inf);
     $expected_participle = 'éclairé';
     $this->assertEquals($expected_participle, $got_participle, "The participle for '{$inf}' is wrong.");
     $inf = 'comprendre';
     $got_participle = LinguaFRParticiple::participle($inf);
     $expected_participle = 'compris';
     $this->assertEquals($expected_participle, $got_participle, "The participle for '{$inf}' is wrong.");
     $inf = 'finir';
     $got_participle = LinguaFRParticiple::participle($inf);
     $expected_participle = 'fini';
     $this->assertEquals($expected_participle, $got_participle, "The participle for '{$inf}' is wrong.");
 }
コード例 #2
0
 public static function makeVerbFormPassive($verbKey, $lang)
 {
     $logger = Logger::getLogger('VerbRoot.makeVerbFormPassive');
     $logger->debug("\$verbKey in '{$lang}' on entry= '{$verbKey}'");
     preg_match_all("/\\/([a-zA-Zàâèéëêïîôùüûç\\-]+)/", $verbKey, $matches);
     $verb_words = $matches[1];
     $logger->debug("\$verb_words= " . print_r($verb_words, 1));
     $passive_verbKey = $verbKey;
     foreach ($verb_words as $a_verb_word) {
         $logger->debug("\$a_verb_word= {$a_verb_word}");
         if ($lang == 'en') {
             $vpass = LinguaENParticiple::participle($a_verb_word);
             $logger->debug("\$vpass= {$vpass}");
         } else {
             // enlever la partie 'préposition' de la clé (ex.:  '-à' dans 'donner-à')
             // (à la fin de la clé)
             $verbKey_without_prep = self::removePrepositionFromEndOfVerbWord($a_verb_word);
             $verbPrep = preg_replace("/{$verbKey_without_prep}/", "", $a_verb_word);
             $verbKey_without_prep = preg_replace('/^(?:se-|s\')/', '', $verbKey_without_prep);
             if ($verbPrep == 'à' || $verbPrep == '-contre' || $verbPrep == '-de' || $verbPrep == '-dans') {
                 $vpass = '******' . $verbKey_without_prep;
             } elseif ($verbPrep == '-sur') {
                 $vpass = '******' . $verbKey_without_prep . ' dessus';
             } else {
                 $vpass = LinguaFRParticiple::participle($verbKey_without_prep);
             }
         }
         $logger->debug("\$passive_verbKey = str_replace('{$a_verb_word}', '{$vpass}', '{$passive_verbKey}')");
         $passive_verbKey = str_replace($a_verb_word, $vpass, $passive_verbKey);
         $logger->debug("\$passive_verbKey= {$passive_verbKey}");
     }
     $passive_verbKey = str_replace('/', '', $passive_verbKey);
     $logger->debug("\$passive_verbKey on exit= '{$passive_verbKey}'");
     return $passive_verbKey;
 }