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
                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);
            assert(count($pastPerfect) == $personCount);
            saveModel($modelNumber, $infinitive, $longInfinitive, $imperative, $slaveModels, $participle, $gerund, $participleModel, $present, $subjonctive, $imperfect, $perfectSimple, $pastPerfect);
            $state = ST_MODEL_NUMBER;
    }
}
analyzeModelMap($modelMap);
assertEquals(EXPECTED_MODELS, $numModels);
/*************************************************************************/
function parseSlaveModels($str)
{
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);
}