Example #1
0
$inflections = array(41, 42, 43, 44, 45, 46, 47, 48);
list($verbose, $fileName) = parseArguments();
$data = readAndFormatFile($fileName);
$numModels = 0;
// Skip five header rows
captureTr();
captureTr();
captureTr();
captureTr();
captureTr();
$buf = captureTr();
while (count($buf)) {
    $cells = $buf;
    // We might need to read a second row sometimes. The second row does
    // not contain the model number, so the columns are shifted by 1.
    $buf = captureTr();
    if (count($buf) && !preg_match('/\\d+\\./', $buf[0])) {
        foreach ($buf as $index => $extra) {
            $cells[$index + 1] .= $extra;
        }
        $buf = captureTr();
    }
    assert(preg_match('/\\d+\\./', $cells[0]));
    assert(count($cells) == 9);
    $modelNumber = substr($cells[0], 0, strlen($cells[0]) - 1);
    $forms = array_splice($cells, 1, 8);
    dprintArray($forms, $modelNumber);
    saveCommonModel('P', $modelNumber, $forms, '', $inflections);
    $numModels++;
}
assertEquals(EXPECTED_MODELS, $numModels);
Example #2
0
         $present[$person] = $cells[2];
         assert($cells[3] == 'să');
         $subjonctive[$person] = $cells[4];
         $imperfect[$person] = $cells[5];
         $perfectSimple[$person] = $cells[6];
     }
     assert(count($cells) == 3);
     assert($cells[0] == 'm. m. c. perfect:');
     $cells = array_slice($cells, 1);
     while (count($cells) == 2) {
         foreach ($cells as $cell) {
             assert($cell[1] == '.' && $cell[2] == ' ');
             $person = $cell[0];
             $pastPerfect[$person] = substr($cell, 3);
         }
         $cells = captureTr();
     }
     ksort($pastPerfect);
     $state = ST_FINAL;
     break;
 case ST_FINAL:
     dprintArray($present, 'Present');
     dprintArray($subjonctive, 'Subjonctive');
     dprintArray($imperfect, 'Imperfect');
     dprintArray($perfectSimple, 'Perfect simple');
     dprintArray($pastPerfect, 'Past perfect');
     $personCount = count($present);
     assert($personCount == 2 || $personCount == 6);
     assert(count($subjonctive) == $personCount);
     assert(count($imperfect) == $personCount);
     assert(count($perfectSimple) == $personCount);
Example #3
-1
function parseNounGroup($modelType, $inflections, $expectedModels)
{
    $numModels = 0;
    $buf = captureTr();
    while (count($buf)) {
        $cells = $buf;
        // We might need to read a second row sometimes. The second row does
        // not contain the model number, so the columns are shifted by 1.
        $buf = captureTr();
        if (count($buf) && !preg_match('/\\d+\\./', $buf[0])) {
            assert(count($buf) == 2);
            $cells[1] .= $buf[0];
            $cells[5] .= $buf[1];
            $buf = captureTr();
        }
        assert(preg_match('/\\d+\\./', $cells[0]));
        assert(count($cells) == 9 || count($cells) == 10);
        $descr = count($cells) == 10 ? $cells[9] : '';
        $modelNumber = substr($cells[0], 0, strlen($cells[0]) - 1);
        $forms = array_splice($cells, 1, 8);
        dprintArray($forms, $modelNumber);
        saveCommonModel($modelType, $modelNumber, $forms, $descr, $inflections);
        $numModels++;
    }
    assertEquals($expectedModels, $numModels);
}