... | ... |
@@ -71,7 +71,7 @@ |
71 | 71 |
?> |
72 | 72 |
<div class="note note_information"> |
73 | 73 |
<span class="note_content"> |
74 |
- <p>Some of these words are very unlikely to ever get used (e.g. <?php echo(mark("ni slag", ["type_word", "lang_fs"])); ?>). Nevertheless they exist and are listed for completeness.</p> |
|
74 |
+ <p>Some of these words are very unlikely to ever get used (e.g. <?php echo(mark("ni slag", ["type_word", "lang_flk"])); ?>). Nevertheless they exist and are listed for completeness.</p> |
|
75 | 75 |
</span> |
76 | 76 |
</div> |
77 | 77 |
</section> |
... | ... |
@@ -35,7 +35,7 @@ |
35 | 35 |
], |
36 | 36 |
$data |
37 | 37 |
); |
38 |
- $table = $table->snap |
|
38 |
+ $table_ = $table->snap |
|
39 | 39 |
( |
40 | 40 |
[ |
41 | 41 |
"label_vertical" => function ($column) {return "";}, |
... | ... |
@@ -50,32 +50,28 @@ |
50 | 50 |
], |
51 | 51 |
"columns_data" => |
52 | 52 |
[ |
53 |
+ $table->columns_get()[0], |
|
53 | 54 |
$table->columns_get()[3], |
54 | 55 |
], |
55 | 56 |
"data_aggregator" => function ($values) |
56 | 57 |
{ |
57 | 58 |
return $values; |
58 | 59 |
}, |
59 |
- "data_formatter" => function ($value) |
|
60 |
- { |
|
61 |
- return ( |
|
62 |
- _bar("word") |
|
63 |
- ( |
|
64 |
- [ |
|
65 |
- "original" => $value[0]["words"], |
|
66 |
- "translated" => $value[1]["words"], |
|
67 |
- ] |
|
68 |
- ) |
|
69 |
- ); |
|
70 |
- return json_encode($value); |
|
71 |
- }, |
|
60 |
+ "data_formatter" => function_chain |
|
61 |
+ ( |
|
62 |
+ [ |
|
63 |
+ object_from_array("language_id"), |
|
64 |
+ object_map(object_attribute("words")), |
|
65 |
+ format_correlation("type_word"), |
|
66 |
+ ] |
|
67 |
+ ), |
|
72 | 68 |
] |
73 | 69 |
); |
74 |
- $table->generate(); |
|
70 |
+ $table_->generate(); |
|
75 | 71 |
?> |
76 | 72 |
<div class="note note_information"> |
77 | 73 |
<span class="note_content"> |
78 |
- <p>Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ni slag</span>). Nevertheless they exist and are listed for completeness.</p> |
|
74 |
+ <p>Some of these words are very unlikely to ever get used (e.g. <?php echo(mark("ni slag", ["type_word", "lang_fs"])); ?>). Nevertheless they exist and are listed for completeness.</p> |
|
79 | 75 |
</span> |
80 | 76 |
</div> |
81 | 77 |
</section> |
... | ... |
@@ -73,6 +73,10 @@ |
73 | 73 |
); |
74 | 74 |
$table->generate(); |
75 | 75 |
?> |
76 |
- <div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div> |
|
76 |
+ <div class="note note_information"> |
|
77 |
+ <span class="note_content"> |
|
78 |
+ <p>Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ni slag</span>). Nevertheless they exist and are listed for completeness.</p> |
|
79 |
+ </span> |
|
80 |
+ </div> |
|
77 | 81 |
</section> |
78 | 82 |
|
... | ... |
@@ -73,6 +73,6 @@ |
73 | 73 |
); |
74 | 74 |
$table->generate(); |
75 | 75 |
?> |
76 |
-<div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div> |
|
76 |
+ <div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div> |
|
77 | 77 |
</section> |
78 | 78 |
|
... | ... |
@@ -8,181 +8,70 @@ |
8 | 8 |
<header>Correlatives</header> |
9 | 9 |
<?php proposal(); ?> |
10 | 10 |
<?php |
11 |
- $mode = 0; |
|
12 |
- switch ($mode) |
|
11 |
+ $data_correlatives = read_json("source/data/correlatives.json"); |
|
12 |
+ $data = $data_correlatives["words"]; |
|
13 | 13 |
{ |
14 |
- case 0: |
|
15 | 14 |
{ |
16 |
- $table = new class_table |
|
17 |
- ( |
|
18 |
- [ |
|
19 |
- new class_column |
|
20 |
- ( |
|
21 |
- "Domain", |
|
22 |
- function ($row) {return $row["domain"];} |
|
23 |
- ), |
|
24 |
- new class_column |
|
25 |
- ( |
|
26 |
- "Interrogative / Relative", |
|
27 |
- _foo("interrogative"), |
|
28 |
- _bar("word") |
|
29 |
- ), |
|
30 |
- new class_column |
|
31 |
- ( |
|
32 |
- "Demonstrative far", |
|
33 |
- _foo("demonstrative_far"), |
|
34 |
- _bar("word") |
|
35 |
- ), |
|
36 |
- new class_column |
|
37 |
- ( |
|
38 |
- "Demonstrative near", |
|
39 |
- _foo("demonstrative_near"), |
|
40 |
- _bar("word") |
|
41 |
- ), |
|
42 |
- new class_column |
|
43 |
- ( |
|
44 |
- "Universal", |
|
45 |
- _foo("universal"), |
|
46 |
- _bar("word") |
|
47 |
- ), |
|
48 |
- new class_column |
|
49 |
- ( |
|
50 |
- "Undefined", |
|
51 |
- _foo("undefined"), |
|
52 |
- _bar("word") |
|
53 |
- ), |
|
54 |
- new class_column |
|
55 |
- ( |
|
56 |
- "Negative", |
|
57 |
- _foo("negative"), |
|
58 |
- _bar("word") |
|
59 |
- ), |
|
60 |
- ], |
|
61 |
- read_json("source/data/correlatives.json") |
|
62 |
- ); |
|
63 |
- $table->generate(); |
|
64 |
- break; |
|
15 |
+ $data = sql_cross($data, $data_correlatives["domains"]); |
|
16 |
+ $data = sql_select($data, function ($row) {return ($row["domain_id"] == $row["id"]);}); |
|
17 |
+ $data = sql_delete($data, ["domain_id", "id"]); |
|
18 |
+ $data = sql_rename($data, "name", "domain_name"); |
|
65 | 19 |
} |
66 |
- case 1: |
|
67 | 20 |
{ |
68 |
- global $configuration; |
|
69 |
- $database = read_json("source/data/x.json"); |
|
70 |
- $data = $database["words"]; |
|
71 |
- // $data = sql_cross($database["words"], sql_rename($database["words"])); |
|
72 |
- $data = sql_select($data, function ($row) {return ($row["language"] == "fs");}); |
|
73 |
- $table = new class_table |
|
74 |
- ( |
|
75 |
- [ |
|
76 |
- new class_column("Domain (id)", function ($row) {return $row["domain_id"];}), |
|
77 |
- new class_column("Type (id)", function ($row) {return $row["type_id"];}), |
|
78 |
- new class_column |
|
79 |
- ( |
|
80 |
- "Folksprak", |
|
81 |
- function ($row) {return $row["words"];}, |
|
82 |
- function ($value) {global $configuration; return _baz($value, "word", "fs");} |
|
83 |
- ), |
|
84 |
- /* |
|
85 |
- new class_column |
|
86 |
- ( |
|
87 |
- $configuration["languagemap"][$configuration["target"]], |
|
88 |
- function ($row) {global $configuration; return $row["words"][$configuration["target"]];}, |
|
89 |
- function ($value) {global $configuration; return _baz($value, "word", $configuration["target"]);} |
|
90 |
- ), |
|
91 |
- */ |
|
92 |
- ], |
|
93 |
- $data |
|
94 |
- ); |
|
95 |
- $table->generate(); |
|
96 |
- break; |
|
21 |
+ $data = sql_cross($data, $data_correlatives["types"]); |
|
22 |
+ $data = sql_select($data, function ($row) {return ($row["type_id"] == $row["id"]);}); |
|
23 |
+ $data = sql_delete($data, ["type_id", "id"]); |
|
24 |
+ $data = sql_rename($data, "name", "type_name"); |
|
97 | 25 |
} |
98 |
- case 2: |
|
99 |
- { |
|
100 |
- global $configuration; |
|
101 |
- $database = read_json("source/data/x.json"); |
|
102 |
- $data = $database["words"]; |
|
103 |
- |
|
104 |
- // get domain names |
|
105 |
- { |
|
106 |
- $data = sql_cross($data, $database["domains"]); |
|
107 |
- $data = sql_rename($data, "name", "domain_name"); |
|
108 |
- $data = sql_select($data, function ($row) {return ($row["id"] == $row["domain_id"]);}); |
|
109 |
- $data = sql_delete($data, ["id"]); |
|
110 |
- } |
|
111 |
- |
|
112 |
- // get type names |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ $table = new class_table |
|
29 |
+ ( |
|
30 |
+ [ |
|
31 |
+ new class_column("Language", "language_id"), |
|
32 |
+ new class_column("Domain", "domain_name"), |
|
33 |
+ new class_column("Type", "type_name"), |
|
34 |
+ new class_column("Words", "words", function ($x) {return json_encode($x);}), |
|
35 |
+ ], |
|
36 |
+ $data |
|
37 |
+ ); |
|
38 |
+ $table = $table->snap |
|
39 |
+ ( |
|
40 |
+ [ |
|
41 |
+ "label_vertical" => function ($column) {return "";}, |
|
42 |
+ "columns_vertical" => |
|
43 |
+ [ |
|
44 |
+ $table->columns_get()[1], |
|
45 |
+ ], |
|
46 |
+ "label_horizontal" => function ($column, $value) {return $value;}, |
|
47 |
+ "columns_horizontal" => |
|
48 |
+ [ |
|
49 |
+ $table->columns_get()[2], |
|
50 |
+ ], |
|
51 |
+ "columns_data" => |
|
52 |
+ [ |
|
53 |
+ $table->columns_get()[3], |
|
54 |
+ ], |
|
55 |
+ "data_aggregator" => function ($values) |
|
113 | 56 |
{ |
114 |
- $data = sql_cross($data, $database["types"]); |
|
115 |
- $data = sql_rename($data, "name", "type_name"); |
|
116 |
- $data = sql_select($data, function ($row) {return ($row["id"] == $row["type_id"]);}); |
|
117 |
- $data = sql_delete($data, ["id"]); |
|
118 |
- } |
|
119 |
- |
|
120 |
- // transform |
|
57 |
+ return $values; |
|
58 |
+ }, |
|
59 |
+ "data_formatter" => function ($value) |
|
121 | 60 |
{ |
122 |
- $data = sql_select($data, function ($row) {global $configuration; return (($row["language"] == "fs") or ($row["language"] == $configuration["target"]));}); |
|
123 |
- // $data = sql_group($data, "language"); |
|
124 |
- $data = sql_add($data, ["type_name/words"], ["type_name/words" => function ($row) {return ["key" => $row["type_id"], "value" => [$row["language"] => $row["words"]]];}]); |
|
125 |
- $data = sql_project($data, ["domain_name", "type_name/words"]); |
|
126 |
- $data = sql_group |
|
127 |
- ( |
|
128 |
- $data, |
|
129 |
- "domain_name", |
|
130 |
- [ |
|
131 |
- "type_name/words" => function ($args) |
|
132 |
- { |
|
133 |
- $output = []; |
|
134 |
- foreach ($args as $arg) |
|
135 |
- { |
|
136 |
- if (! array_key_exists($arg["key"], $output)) $output[$arg["key"]] = []; |
|
137 |
- foreach ($arg["value"] as $key => $value) |
|
138 |
- { |
|
139 |
- $output[$arg["key"]][$key] = $value; |
|
140 |
- } |
|
141 |
- } |
|
142 |
- return $output; |
|
143 |
- }, |
|
144 |
- ] |
|
145 |
- ); |
|
146 |
- } |
|
147 |
- |
|
148 |
- $table = new class_table |
|
149 |
- ( |
|
150 |
- array_merge |
|
151 |
- ( |
|
152 |
- [ |
|
153 |
- new class_column("Domain", function ($row) {return $row["domain_name"];}), |
|
154 |
- // new class_column("type_name/words", function ($row) {return $row["type_name/words"];}, function ($value) {print_r($value);}), |
|
155 |
- ], |
|
156 |
- array_map |
|
61 |
+ return ( |
|
62 |
+ _bar("word") |
|
157 | 63 |
( |
158 |
- function ($type) |
|
159 |
- { |
|
160 |
- return ( |
|
161 |
- new class_column |
|
162 |
- ( |
|
163 |
- ("Type: " . $type["name"]), |
|
164 |
- function ($row) use (&$type) |
|
165 |
- { |
|
166 |
- global $configuration; |
|
167 |
- return ["original" => $row["type_name/words"][$type["id"]]["fs"], "translated" => $row["type_name/words"][$type["id"]][$configuration["target"]]]; |
|
168 |
- }, |
|
169 |
- _bar("word") |
|
170 |
- ) |
|
171 |
- ); |
|
172 |
- }, |
|
173 |
- array_filter($database["types"], function ($type) {return ($type["id"] != "relative");}) |
|
64 |
+ [ |
|
65 |
+ "original" => $value[0]["words"], |
|
66 |
+ "translated" => $value[1]["words"], |
|
67 |
+ ] |
|
174 | 68 |
) |
175 |
- ), |
|
176 |
- $data |
|
177 |
- ); |
|
178 |
- $table->generate(); |
|
179 |
- break; |
|
180 |
- } |
|
181 |
- default: |
|
182 |
- { |
|
183 |
- break; |
|
184 |
- } |
|
185 |
- } |
|
69 |
+ ); |
|
70 |
+ return json_encode($value); |
|
71 |
+ }, |
|
72 |
+ ] |
|
73 |
+ ); |
|
74 |
+ $table->generate(); |
|
186 | 75 |
?> |
187 | 76 |
<div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div> |
188 | 77 |
</section> |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,189 @@ |
1 |
+<?php |
|
2 |
+ include_once("source/logic/server/data.php"); |
|
3 |
+ include_once("source/logic/server/table.php"); |
|
4 |
+ include_once("source/logic/server/misc.php"); |
|
5 |
+ include_once("source/logic/server/sql.php"); |
|
6 |
+ ?> |
|
7 |
+<section class="subsection" id="correlatives"> |
|
8 |
+ <header>Correlatives</header> |
|
9 |
+ <div class="note_error">This section is only a proposal yet; not part of the draft.</div> |
|
10 |
+<?php |
|
11 |
+ $mode = 2; |
|
12 |
+ switch ($mode) |
|
13 |
+ { |
|
14 |
+ case 0: |
|
15 |
+ { |
|
16 |
+ $table = new class_table |
|
17 |
+ ( |
|
18 |
+ [ |
|
19 |
+ new class_column |
|
20 |
+ ( |
|
21 |
+ "Domain", |
|
22 |
+ function ($row) {return $row["domain"];} |
|
23 |
+ ), |
|
24 |
+ new class_column |
|
25 |
+ ( |
|
26 |
+ "Interrogative / Relative", |
|
27 |
+ _foo("interrogative"), |
|
28 |
+ _bar("word") |
|
29 |
+ ), |
|
30 |
+ new class_column |
|
31 |
+ ( |
|
32 |
+ "Demonstrative far", |
|
33 |
+ _foo("demonstrative_far"), |
|
34 |
+ _bar("word") |
|
35 |
+ ), |
|
36 |
+ new class_column |
|
37 |
+ ( |
|
38 |
+ "Demonstrative near", |
|
39 |
+ _foo("demonstrative_near"), |
|
40 |
+ _bar("word") |
|
41 |
+ ), |
|
42 |
+ new class_column |
|
43 |
+ ( |
|
44 |
+ "Universal", |
|
45 |
+ _foo("universal"), |
|
46 |
+ _bar("word") |
|
47 |
+ ), |
|
48 |
+ new class_column |
|
49 |
+ ( |
|
50 |
+ "Undefined", |
|
51 |
+ _foo("undefined"), |
|
52 |
+ _bar("word") |
|
53 |
+ ), |
|
54 |
+ new class_column |
|
55 |
+ ( |
|
56 |
+ "Negative", |
|
57 |
+ _foo("negative"), |
|
58 |
+ _bar("word") |
|
59 |
+ ), |
|
60 |
+ ], |
|
61 |
+ read_json("source/data/correlatives.json") |
|
62 |
+ ); |
|
63 |
+ $table->generate(); |
|
64 |
+ break; |
|
65 |
+ } |
|
66 |
+ case 1: |
|
67 |
+ { |
|
68 |
+ global $configuration; |
|
69 |
+ $database = read_json("source/data/x.json"); |
|
70 |
+ $data = $database["words"]; |
|
71 |
+ // $data = sql_cross($database["words"], sql_rename($database["words"])); |
|
72 |
+ $data = sql_select($data, function ($row) {return ($row["language"] == "fs");}); |
|
73 |
+ $table = new class_table |
|
74 |
+ ( |
|
75 |
+ [ |
|
76 |
+ new class_column("Domain (id)", function ($row) {return $row["domain_id"];}), |
|
77 |
+ new class_column("Type (id)", function ($row) {return $row["type_id"];}), |
|
78 |
+ new class_column |
|
79 |
+ ( |
|
80 |
+ "Folksprak", |
|
81 |
+ function ($row) {return $row["words"];}, |
|
82 |
+ function ($value) {global $configuration; return _baz($value, "word", "fs");} |
|
83 |
+ ), |
|
84 |
+ /* |
|
85 |
+ new class_column |
|
86 |
+ ( |
|
87 |
+ $configuration["languagemap"][$configuration["target"]], |
|
88 |
+ function ($row) {global $configuration; return $row["words"][$configuration["target"]];}, |
|
89 |
+ function ($value) {global $configuration; return _baz($value, "word", $configuration["target"]);} |
|
90 |
+ ), |
|
91 |
+ */ |
|
92 |
+ ], |
|
93 |
+ $data |
|
94 |
+ ); |
|
95 |
+ $table->generate(); |
|
96 |
+ break; |
|
97 |
+ } |
|
98 |
+ case 2: |
|
99 |
+ { |
|
100 |
+ global $configuration; |
|
101 |
+ $database = read_json("source/data/x.json"); |
|
102 |
+ $data = $database["words"]; |
|
103 |
+ |
|
104 |
+ // get domain names |
|
105 |
+ { |
|
106 |
+ $data = sql_cross($data, $database["domains"]); |
|
107 |
+ $data = sql_rename($data, "name", "domain_name"); |
|
108 |
+ $data = sql_select($data, function ($row) {return ($row["id"] == $row["domain_id"]);}); |
|
109 |
+ $data = sql_delete($data, ["id"]); |
|
110 |
+ } |
|
111 |
+ |
|
112 |
+ // get type names |
|
113 |
+ { |
|
114 |
+ $data = sql_cross($data, $database["types"]); |
|
115 |
+ $data = sql_rename($data, "name", "type_name"); |
|
116 |
+ $data = sql_select($data, function ($row) {return ($row["id"] == $row["type_id"]);}); |
|
117 |
+ $data = sql_delete($data, ["id"]); |
|
118 |
+ } |
|
119 |
+ |
|
120 |
+ // transform |
|
121 |
+ { |
|
122 |
+ $data = sql_select($data, function ($row) {global $configuration; return (($row["language"] == "fs") or ($row["language"] == $configuration["target"]));}); |
|
123 |
+ // $data = sql_group($data, "language"); |
|
124 |
+ $data = sql_add($data, ["type_name/words"], ["type_name/words" => function ($row) {return ["key" => $row["type_id"], "value" => [$row["language"] => $row["words"]]];}]); |
|
125 |
+ $data = sql_project($data, ["domain_name", "type_name/words"]); |
|
126 |
+ $data = sql_group |
|
127 |
+ ( |
|
128 |
+ $data, |
|
129 |
+ "domain_name", |
|
130 |
+ [ |
|
131 |
+ "type_name/words" => function ($args) |
|
132 |
+ { |
|
133 |
+ $output = []; |
|
134 |
+ foreach ($args as $arg) |
|
135 |
+ { |
|
136 |
+ if (! array_key_exists($arg["key"], $output)) $output[$arg["key"]] = []; |
|
137 |
+ foreach ($arg["value"] as $key => $value) |
|
138 |
+ { |
|
139 |
+ $output[$arg["key"]][$key] = $value; |
|
140 |
+ } |
|
141 |
+ } |
|
142 |
+ return $output; |
|
143 |
+ }, |
|
144 |
+ ] |
|
145 |
+ ); |
|
146 |
+ } |
|
147 |
+ |
|
148 |
+ $table = new class_table |
|
149 |
+ ( |
|
150 |
+ array_merge |
|
151 |
+ ( |
|
152 |
+ [ |
|
153 |
+ new class_column("Domain", function ($row) {return $row["domain_name"];}), |
|
154 |
+ // new class_column("type_name/words", function ($row) {return $row["type_name/words"];}, function ($value) {print_r($value);}), |
|
155 |
+ ], |
|
156 |
+ array_map |
|
157 |
+ ( |
|
158 |
+ function ($type) |
|
159 |
+ { |
|
160 |
+ return ( |
|
161 |
+ new class_column |
|
162 |
+ ( |
|
163 |
+ ("Type: " . $type["name"]), |
|
164 |
+ function ($row) use (&$type) |
|
165 |
+ { |
|
166 |
+ global $configuration; |
|
167 |
+ return ["original" => $row["type_name/words"][$type["id"]]["fs"], "translated" => $row["type_name/words"][$type["id"]][$configuration["target"]]]; |
|
168 |
+ }, |
|
169 |
+ _bar("word") |
|
170 |
+ ) |
|
171 |
+ ); |
|
172 |
+ }, |
|
173 |
+ array_filter($database["types"], function ($type) {return ($type["id"] != "relative");}) |
|
174 |
+ ) |
|
175 |
+ ), |
|
176 |
+ $data |
|
177 |
+ ); |
|
178 |
+ $table->generate(); |
|
179 |
+ break; |
|
180 |
+ } |
|
181 |
+ default: |
|
182 |
+ { |
|
183 |
+ break; |
|
184 |
+ } |
|
185 |
+ } |
|
186 |
+ ?> |
|
187 |
+<div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div> |
|
188 |
+</section> |
|
189 |
+ |