-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_category.php
More file actions
36 lines (32 loc) · 914 Bytes
/
Copy pathshow_category.php
File metadata and controls
36 lines (32 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// parse JSON/mediawiki data for categories/templates.
// Show the resulting PHP data structure, and error/unrecognized messages
require_once("parse_category.inc");
function main($nlines) {
$f = fopen('data/david_category_template_dump.txt', 'r');
$npeople = [];
for ($i=0; $i<$nlines; $i++) {
echo "JSON line $i\n";
$x = fgets($f);
if (!$x) break;
if (!trim($x)) continue;
$y = json_decode($x);
$n = 0;
foreach ($y as $title => $body) {
if (!strstr($title, 'Category:')) continue;
$p = parse_person($title, $body);
if (!$p) continue;
echo "main(): got ".$p->template_name."\n";
//print_r($p);
$n++;
}
$npeople[$i] = $n;
echo "people: $n\n";
}
echo "totals:\n";
print_r($npeople);
}
$verbose = false;
// 480 lines
main(500);
?>