source/content/declension.html.php
579dbe00
 <section class="section" id="declension">
dcda8f59
 	<header>Declension</header>
b3c1b9b9
 <?php
 	compose
 	(
 		[
 			"numeri",
 			"cases",
 			"definiteness",
 		]
 	);
  ?>
 <p>The following table summarizes the information of this section:</p>
 <?php
5da1fdb3
 	$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:
 					{
270847a5
 						return format_list("type_word", "flk")($value[0]["words"]);
8794e319
 						break;
5da1fdb3
 					}
 					case 1:
 					{
 						global $configuration;
 						$value_ = [];
270847a5
 						foreach (["flk",$configuration["target"]] as $language_id)
5da1fdb3
 						{
 							$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 (
8794e319
 							format_correlation("type_word")
5da1fdb3
 							(
 								[
270847a5
 									"flk" => $value_["flk"],
8794e319
 									$configuration["target"] => $value_[$configuration["target"]],
5da1fdb3
 								]
 							)
 						);
8794e319
 						break;
5da1fdb3
 					}
 					default:
 					{
 						return json_encode($value);
8794e319
 						break;
5da1fdb3
 					}
 				}
 			},
 		]
 	)->generate();
8794e319
  ?>
dee63d95
 <p><?php echo(format_correlation("type_sentence")(["flk" => ["Vi kan seje de huses vindöger"], "eng" => ["We can see the houses windows."]])); ?></p></section>
a8c049f8