Пример #1
0
 // Now load the affected lexems. For each lexem, inflection and transform
 // list, generate a new form.
 $lexems = Lexem::loadByCanonicalModel($modelType, $modelNumber);
 $regenForms = array();
 foreach ($lexems as $l) {
     $regenRow = array();
     foreach ($regenTransforms as $inflId => $variants) {
         $regenRow[$inflId] = array();
         foreach ($variants as $transforms) {
             $accentShift = array_pop($transforms);
             if ($accentShift != UNKNOWN_ACCENT_SHIFT && $accentShift != NO_ACCENT_SHIFT) {
                 $accentedVowel = array_pop($transforms);
             } else {
                 $accentedVowel = '';
             }
             $result = FlexStringUtil::applyTransforms($l->form, $transforms, $accentShift, $accentedVowel);
             $regenRow[$inflId][] = $result;
             if (!$result && count($errorMessage) <= 20) {
                 $errorMessage[] = "Nu pot calcula una din formele lexemului " . htmlentities($l->form) . ".";
             }
         }
     }
     $regenForms[] = $regenRow;
 }
 // Now load the affected adjectives if the participle model changed
 if ($participleNumber != $newParticipleNumber) {
     $participleParadigms = array();
     $participles = loadParticiplesForVerbModel($modelNumber, $participleNumber);
     foreach ($participles as $p) {
         $p->modelNumber = $newParticipleNumber;
         $ifs = $p->generateParadigm();
Пример #2
0
 public function generateInflectedFormWithModel($form, $inflId, $modelId)
 {
     if (!ConstraintMap::validInflection($inflId, $this->restriction)) {
         return array();
     }
     $ifs = array();
     $mds = Model::factory('ModelDescription')->where('modelId', $modelId)->where('inflectionId', $inflId)->order_by_asc('variant')->order_by_asc('applOrder')->find_many();
     $start = 0;
     while ($start < count($mds)) {
         // Identify all the md's that differ only by the applOrder
         $end = $start + 1;
         while ($end < count($mds) && $mds[$end]->applOrder != 0) {
             $end++;
         }
         $inflId = $mds[$start]->inflectionId;
         $accentShift = $mds[$start]->accentShift;
         $vowel = $mds[$start]->vowel;
         // Apply all the transforms from $start to $end - 1.
         $variant = $mds[$start]->variant;
         $recommended = $mds[$start]->recommended;
         // Load the transforms
         $transforms = array();
         for ($i = $end - 1; $i >= $start; $i--) {
             $transforms[] = Transform::get_by_id($mds[$i]->transformId);
         }
         $result = FlexStringUtil::applyTransforms($form, $transforms, $accentShift, $vowel);
         if (!$result) {
             throw new Exception();
         }
         $ifs[] = InflectedForm::create($result, $this->id, $inflId, $variant, $recommended);
         $start = $end;
     }
     return $ifs;
 }