Exemplo n.º 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);
Exemplo n.º 2
0
function saveModel($modelNumber, $infinitive, $longInfinitive, $imperative, $slaveModels, $participle, $gerund, $participleModel, $present, $subjonctive, $imperfect, $perfectSimple, $pastPerfect)
{
    $forms = array();
    $inflections = array();
    $forms[] = $infinitive;
    $inflections[] = INFL_INFINITIVE;
    $forms[] = $longInfinitive;
    $inflections[] = INFL_LONG_INFINITIVE;
    $forms[] = $imperative;
    $inflections[] = INFL_IMPERATIVE;
    $forms[] = $participle;
    $inflections[] = INFL_PARTICIPLE;
    $forms[] = $gerund;
    $inflections[] = INFL_GERUND;
    addPersonalForms($forms, $inflections, $present, INFL_PRESENT);
    addPersonalForms($forms, $inflections, $subjonctive, INFL_SUBJONCTIVE);
    addPersonalForms($forms, $inflections, $imperfect, INFL_IMPERFECT);
    addPersonalForms($forms, $inflections, $perfectSimple, INFL_PERFECT_SIMPLE);
    addPersonalForms($forms, $inflections, $pastPerfect, INFL_PAST_PERFECT);
    saveCommonModel('V', $modelNumber, $forms, '', $inflections);
    // Add the mapping from this verb model to the corresponding adjective model
    $pm = ParticipleModel::create($modelNumber, $participleModel);
    $pm->save();
    foreach ($slaveModels as $sm) {
        $mm = ModelMapping::create('V', $sm, $modelNumber);
        $mm->save();
    }
}
Exemplo n.º 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);
}