-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
126 lines (89 loc) · 2.79 KB
/
index.php
File metadata and controls
126 lines (89 loc) · 2.79 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
научить # фигачить заголовки не с первого уровня, а с другого
explanation должен быть пустым, если не просили
если дефисов больше трёх подряд, то не нужно их трогать ни один (-------)
в ХТМЛ-коде генерируемых таблиц какие-то мусорные пробелы
*/
//
// вот это неправильно обрабатывается:
// ((https://ilyabirman.ru/meanwhile/all/jerusalem-old-city-street-name-plates/ Иерусалим (старый город)))
// см. test-38.txt
header ('Content-Type: text/html; charset=utf-8');
//error_reporting (E_ALL & ~E_NOTICE);
error_reporting (E_ALL);
//*
ini_set('display_errors', 1);
error_reporting(~0);
define ('USER_FOLDER', '');
//*/
$text = file_get_contents ('tests/test-42.txt');
$res = '';
function stopwatch () {
list ($usec, $sec) = explode (' ', microtime ());
return ((float) $usec + (float) $sec);
}
$stopwatch = stopwatch ();
$inputarray = array (
'config' => 'neasden/config.php',
'text-original' => $text,
'profile-name' => '',
'explain' => true,
);
if (!include 'neasden/neasden.php') die ('neasden init failed');
$Nn = new Neasden;
$Nn->should_explain = true;
$Nn->profile_name = 'kavychki';
$res = $Nn->format ($text);
file_put_contents ('check.json', json_encode ($Nn->ctree, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
// echo '<pre>'.htmlspecialchars($res).'<br>';
echo $res;
// echo sha1($text).'<br>';
// die (sha1($res));
$res = $Nn->explanation;
$stopwatch = stopwatch () - $stopwatch;
?>
<html>
<head>
<!--
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.4/styles/ascetic.min.css">
<script src="http://yandex.st/highlightjs/7.4/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
-->
<link rel="stylesheet" href="style.css" />
<?php
foreach ($Nn->links_required as $link) {
if (substr ($link, -3) == '.js') {
echo '<script src="library/'. $link .'"></script>'. "\n";
}
if (substr ($link, -4) == '.css') {
echo '<link rel="stylesheet" href="library/'. $link .'" />'. "\n";
}
}
?>
</head>
<body>
<?php #= 'Time: '. $stopwatch; ?>
<?php #= neasden_explain ($text); ?>
<?php #= '<pre>'. htmlspecialchars ($res) .'</pre>' ?>
<!--
<table>
<tr valign="top">
<td width="50%"><tt><?= nl2br (htmlspecialchars ($text)) ?></tt></td>
<td></td>
</tr>
</table>
-->
<?= $res ?>
<pre>
Resources:
<?php print_r ($Nn->resources_detected); ?>
Links:
<?php print_r ($Nn->links_required); ?>
Groups:
<?php print_r ($Nn->groups_used); ?>
</pre>
<hr>
<?= $stopwatch ?>
</body>
</html>