Ejemplo n.º 1
0
 public function test__construct()
 {
     $champs = 'morpheme;type;case;number;perPoss;numbPoss;V-form;V-actions;V-action1;V-action2;t-form;t-actions;t-action1;t-action2;k-form;k-actions;k-action1;k-action2;q-form;q-actions;q-action1;q-action2;condPrec;sources';
     $donnees = 'k;tn;nom;d;;;k;n-n-allV;allV;x;k;i(ii);iallV(i);;k;s-n-allV;sallV;x;k;s-n-allV;sallV;x;;H2';
     $champsValeurs = parseCSV($champs, $donnees);
     $tn = new NounEnding($champsValeurs);
     $this->assertEquals('tn', $tn->type(), "");
     $this->assertEquals('tn-nom-d', $tn->signature(), "");
     $this->assertEquals('k/tn-nom-d', $tn->id(), "");
     $context = 'V';
     $forms = $tn->surfaceForms($context);
     $forms_attendues = array('k');
     $this->assertEquals(count($forms_attendues), count($forms), "");
     $behaviours = $tn->behaviours_for_context($context);
     $nb_expected_behaviours = 1;
     $this->assertTrue($behaviours != null, "Erreur");
     $this->assertEquals($nb_expected_behaviours, count($behaviours), "");
     $behaviour = $behaviours[0];
     $this->assertEquals(Action::NEUTRAL, $behaviour->actionOnStem()->type(), "");
     $this->assertEquals(Action::NEUTRAL, $behaviour->actionVV()->type(), "");
     $this->assertEquals(Action::VOWELLENGTHENING, $behaviour->actionNotVV()->type(), "");
     $context = 't';
     $behaviours = $tn->behaviours_for_context($context);
     $nb_expected_behaviours = 1;
     $this->assertTrue($behaviours != null, "Erreur");
     $this->assertEquals($nb_expected_behaviours, count($behaviours), "");
     $behaviour = $behaviours[0];
     $this->assertEquals(Action::INSERTION, $behaviour->actionOnStem()->type(), "");
     $this->assertEquals(null, $behaviour->actionVV(), "");
     $this->assertEquals(null, $behaviour->actionNotVV(), "");
     $context = 'k';
     $behaviours = $tn->behaviours_for_context($context);
     $nb_expected_behaviours = 1;
     $this->assertTrue($behaviours != null, "Erreur");
     $this->assertEquals($nb_expected_behaviours, count($behaviours), "");
     $behaviour = $behaviours[0];
     $this->assertEquals(Action::DELETION, $behaviour->actionOnStem()->type(), "");
     $this->assertEquals(Action::NEUTRAL, $behaviour->actionVV()->type(), "");
     $this->assertEquals(Action::VOWELLENGTHENING, $behaviour->actionNotVV()->type(), "");
     $context = 'q';
     $behaviours = $tn->behaviours_for_context($context);
     $nb_expected_behaviours = 1;
     $this->assertTrue($behaviours != null, "Erreur");
     $this->assertEquals($nb_expected_behaviours, count($behaviours), "");
     $behaviour = $behaviours[0];
     $this->assertEquals(Action::DELETION, $behaviour->actionOnStem()->type(), "");
     $this->assertEquals(Action::NEUTRAL, $behaviour->actionVV()->type(), "");
     $this->assertEquals(Action::VOWELLENGTHENING, $behaviour->actionNotVV()->type(), "");
     $sources = $tn->sources();
     $this->assertEquals(1, count($sources), "");
     $this->assertEquals('H2', $sources[0], "");
 }
 public function _make_linguistic_object($fieldsAndValues)
 {
     $logger = Logger::getLogger('LinguisticObjects.makeLinguisticObject');
     $logger->debug("\$fieldsAndValues= " . print_r($fieldsAndValues, TRUE));
     $type = $fieldsAndValues['type'];
     $logger->debug("type= {$type}");
     $obj = NULL;
     if ($type == 'n' || $type == 'a' || $type == 'e' || $type == 'c') {
         $obj = new NounRoot($fieldsAndValues);
         array_push(self::$rootIDs, $obj->id());
     } elseif ($type == 'v') {
         $obj = new VerbRoot($fieldsAndValues);
         array_push(self::$rootIDs, $obj->id());
     } elseif ($type == 's') {
         $obj = new Source($fieldsAndValues);
         array_push(self::$sourceIDs, $obj->id());
     } elseif ($type == 'sn' || $type == 'sv' || $type == 'q') {
         $obj = new Suffix($fieldsAndValues);
         array_push(self::$affixIDs, $obj->id());
     } elseif ($type == 'tn') {
         $obj = new NounEnding($fieldsAndValues);
         array_push(self::$affixIDs, $obj->id());
     } elseif ($type == 'tv') {
         $obj = new VerbEnding($fieldsAndValues);
         array_push(self::$affixIDs, $obj->id());
     } elseif ($type == 'vw') {
         $obj = new VerbWord($fieldsAndValues);
         self::$verbWords[$object->getVerb()] = $obj;
     } elseif ($type == 'pr') {
         $obj = new Pronoun($fieldsAndValues);
         array_push(self::$rootIDs, $obj->id());
     } elseif ($type == 'pd' || $type == 'ad') {
         $obj = new Demonstrative($fieldsAndValues);
         array_push(self::$rootIDs, $obj->id());
         $roots = explode(' ', $obj->get_root());
         foreach ($roots as $a_root) {
             $newFieldsAndValues = $fieldsAndValues;
             $newFieldsAndValues['morpheme'] = $a_root;
             $newFieldsAndValues['root'] = $a_root;
             $new_obj = new Demonstrative($newFieldsAndValues);
             array_push(self::$rootIDs, $new_obj->id());
         }
     } else {
         $logger->debug("type '{$type}' not supported yet");
     }
     return $obj;
 }