This section is only a proposal yet; not part of the draft.
generate();
break;
}
case 1:
{
global $configuration;
$database = read_json("source/data/x.json");
$data = $database["words"];
// $data = sql_cross($database["words"], sql_rename($database["words"]));
$data = sql_select($data, function ($row) {return ($row["language"] == "fs");});
$table = new class_table
(
[
new class_column("Domain (id)", function ($row) {return $row["domain_id"];}),
new class_column("Type (id)", function ($row) {return $row["type_id"];}),
new class_column
(
"Folksprak",
function ($row) {return $row["words"];},
function ($value) {global $configuration; return _baz($value, "word", "fs");}
),
/*
new class_column
(
$configuration["languagemap"][$configuration["target"]],
function ($row) {global $configuration; return $row["words"][$configuration["target"]];},
function ($value) {global $configuration; return _baz($value, "word", $configuration["target"]);}
),
*/
],
$data
);
$table->generate();
break;
}
case 2:
{
global $configuration;
$database = read_json("source/data/x.json");
$data = $database["words"];
$data = (
/*
sql_project
(
*/
sql_select
(
sql_rename
(
sql_cross
(
$data,
$database["domains"]
),
"name",
"domain_name"
),
function ($row) {return ($row["id"] == $row["domain_id"]);}
)/*,
["domain_id", "name", "type_id", "language", "words"]
)
*/
);
$data = (
/*
sql_project
(
*/
sql_select
(
sql_rename
(
sql_cross
(
$data,
$database["types"]
),
"name",
"type_name"
),
function ($row) {return ($row["id"] == $row["type_id"]);}
)/*,
["domain_name", "name", "language", "words"]
)
*/
);
$data = (
sql_select
(
$data,
function ($row) {return ($row["language"] == "fs");}
)
);
$data = (
sql_add
(
$data,
"type_name/words",
function ($row)
{
return ["key" => $row["type_id"], "value" => $row["words"]];
}
)
);
$data = (
sql_project
(
$data,
["domain_name", "type_name/words"]
)
);
$data = (
sql_group
(
$data,
"domain_name",
[
"type_name/words" => function ($args)
{
$output = [];
array_map
(
function ($arg) use (&$output)
{
$output[$arg["key"]] = $arg["value"];
},
$args
);
return $output;
},
]
)
);
$table = new class_table
(
array_merge
(
[
new class_column("Domain", function ($row) {return $row["domain_name"];}),
],
array_map
(
function ($type)
{
return (
new class_column
(
("Type: " . $type["name"]),
function ($row) use (&$type) {return $row["type_name/words"][$type["id"]];},
function ($value) {return _baz($value, "word", "fs");}
)
);
},
$database["types"]
)
),
$data
);
$table->generate();
break;
}
default:
{
break;
}
}
?>
Some of these words are very unlikely to ever get used (e.g. ing slag). Nevertheless they exist and are listed for completeness.