Example #1
0
function serialize_sentence_part($vector, &$allow_space = NULL)
{
    $r = "";
    if ($allow_space === NULL) {
        $allow_space = FALSE;
    }
    foreach ($vector as $w) {
        if (ISOP($w)) {
            $n = $w;
        } else {
            $n = OP($w);
        }
        if ($n->space_before and $allow_space) {
            $r .= " ";
        }
        $allow_space = !!$n->space_after;
        $r .= $n->text;
    }
    return $r;
}
Example #2
0
    foreach ($sentence as $_ => $__) {
        if (ISOP($__)) {
            continue;
        }
        if ($__["value"] === $value) {
            return $_;
        }
    }
}
$sentences_data = json_decode(file_get_contents("{$dir}/la/sentences.json"), true);
$sentence_data = $sentences_data[array_keys($sentences_data)[0]];
$sentence = $sentence_data["sentence"];
$phrases = $sentence_data["phrases"];
foreach ($sentence as &$word) {
    if (array_key_exists("space_before", $word) and array_key_exists("space_after", $word) and array_key_exists("text", $word)) {
        $word = OP($word["space_before"], $word["text"], $word["space_after"]);
    }
}
$_ = [];
foreach ($phrases as $k => $v) {
    $_[$k - 1] = $v;
}
$phrases_others = [];
$last = [];
foreach (array_reverse($phrases, true) as $_ => $phr) {
    foreach ($phr as $k) {
        $apply =& safe_getr_vector($k, $phrases_others);
        foreach ($phr as $o) {
            $level = $_;
            if (in_array($o, $last)) {
                $level += 1;