source/content/word_functions.html.php
18080c63
 <?php
 	global $configuration;
dcda8f59
 	include_once("source/logic/server/misc.php");
18080c63
 	include_once("source/logic/server/data.php");
 	include_once("source/logic/server/table.php");
  ?>
579dbe00
 <section class="section" id="word_functions">
18080c63
 	<header>Word Functions</header>
000b5f04
 	<?php proposal(); ?>
18080c63
 <?php
 	$table = new class_table
 	(
 		[
 			new class_column
 			(
 				"Affix",
459c0868
 				"affix",
18080c63
 				function ($value)
 				{
8794e319
 					return mark($value, ["type_word", "lang_fs"]);
18080c63
 				}
 			),
 			new class_column
 			(
 				"Type",
459c0868
 				"type_",
18080c63
 				function ($value)
 				{
 					return (
 						implode
 						(
 							" → ",
 							array_map
 							(
 								function ($group)
 								{
 				 					return ("{" . implode(",", $group) . "}");
 								},
 								$value
 							)
 						)
 					);
 				}
 			),
 			new class_column
 			(
 				"Description",
459c0868
 				"description_",
18080c63
 				function ($value)
 				{
 					$output = "";
 					if ($value["name"] != null) $output .= (mark($value["name"], ["grammarterm"]) . ": ");
 					if ($value["description"] != null) $output .= ($value["description"]);
 					return $output;
 				}
 			),
 			/*
 			new class_column
 			(
 				"Cognates",
459c0868
 				"cognates",
18080c63
 				function ($value)
 				{
 					return implode(", ", array_map(function ($entry) {return ($entry["language"] . ": " . mark($entry["affix"], ["word", "lang_" . $entry["language"]]));}, $value));
 				}
 			),
 			 */
 			new class_column
 			(
 				"Example",
459c0868
 				"example_",
dcda8f59
 				_bar("word")
8794e319
 				/*
 				function ($x)
 				{
 					return json_encode($x);
 				}
 				 */
18080c63
 			),
 		],
459c0868
 		sql_condense
 		(
 			read_json("source/data/word_functions.json"),
 			["type_from","type_to","name","description","example"],
 			["type_","description_","example_"],
 			[
 				"type_" => function ($values) {return [$values["type_from"], $values["type_to"]];},
 				"description_" => function ($values) {return ["name" => $values["name"], "description" => $values["description"]];},
 				"example_" => function ($values) {global $configuration; return ["original" => [$values["example"]["word"]], "translated" => $values["example"]["translations"][$configuration["target"]]];},
 			]
 		)
18080c63
 	);
 	$table->generate();
  ?>
 <p>
 	Some complex examples:
 	<ul>
270847a5
 		<li><?php echo(format_correlation("word")(["flk" => ["unmanlikhed"], "eng" => ["inhumanity"]])); ?></li>
 		<li><?php echo(format_correlation("word")(["flk" => ["seberenung"], "eng" => ["visualization"]])); ?></li>
 		<li><?php echo(format_correlation("word")(["flk" => ["kraftigenar"], "eng" => ["fortifier"]])); ?></li>
18080c63
 	</ul>
 </p>
 </section>