<section class="section" id="declension"> <header>Declension</header> <?php compose ( [ "numeri", "cases", "definiteness", ] ); ?> <p>The following table summarizes the information of this section:</p> <?php $data_common = read_json("source/data/common.json"); $data_declension = read_json("source/data/declension.json"); $data = $data_declension["words"]; { { if (true) { $data = sql_cross($data, $data_common["counts"]); $data = sql_select($data, function ($row) {return ($row["count_id"] == $row["id"]);}); $data = sql_delete($data, ["count_id", "id"]); $data = sql_rename($data, "name", "count_name"); } else { $data = sql_rename($data, "count_id", "count_name"); } } { if (true) { $data = sql_cross($data, $data_common["definitenesses"]); $data = sql_select($data, function ($row) {return ($row["definiteness_id"] == $row["id"]);}); $data = sql_delete($data, ["definiteness_id", "id"]); $data = sql_rename($data, "name", "definiteness_name"); } else { $data = sql_rename($data, "definiteness_id", "definiteness_name"); } } { if (true) { $data = sql_cross($data, $data_common["cases"]); $data = sql_select($data, function ($row) {return ($row["case_id"] == $row["id"]);}); $data = sql_delete($data, ["case_id", "id"]); $data = sql_rename($data, "name", "case_name"); } else { $data = sql_rename($data, "case_id", "case_name"); } } } $table = new class_table ( [ new class_column("Language", "language_id"), new class_column("Count", "count_name"), new class_column("Definiteness", "definiteness_name"), new class_column("Case", "case_name"), new class_column("Words", "words", function ($x) {return json_encode($x);}), ], $data ); $table->snap ( [ "label_vertical" => function ($column) {return "";}, "columns_vertical" => [ $table->columns_get()[1], $table->columns_get()[2], ], "label_horizontal" => function ($column, $value) {return $value;}, "columns_horizontal" => [ $table->columns_get()[3], ], "columns_data" => [ $table->columns_get()[0], $table->columns_get()[4], ], "data_aggregator" => function ($values) { return $values; }, "data_formatter" => function ($value) { switch (1) { case 0: { return format_list("type_word", "fs")($value[0]["words"]); break; } case 1: { global $configuration; $value_ = []; foreach (["fs",$configuration["target"]] as $language_id) { $value_[$language_id] = array_reduce ( array_map ( function ($dataset) {return $dataset["words"];}, array_filter($value, function ($dataset) use (&$language_id) {return ($dataset["language_id"] == $language_id);}) ), function ($x, $y) {return array_merge($x, $y);}, [] ); } return ( format_correlation("type_word") ( [ "fs" => $value_["fs"], $configuration["target"] => $value_[$configuration["target"]], ] ) ); break; } default: { return json_encode($value); break; } } }, ] )->generate(); ?> <p><?php echo(format_correlation("type_sentence")(["fs" => ["Vi kön see de huses vindöger"], "en" => ["We can see the houses windows."]])); ?></p></section>