forked from DistributedProofreaders/ppwb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pptext.php
159 lines (133 loc) · 5.84 KB
/
pptext.php
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
require_once("base.inc");
output_header("pptext", ["techinfo-pptext.php" => "TECH INFO"], get_js());
output_content();
function output_content()
{
// available dictionaries installed on the server
$dictionaries = [
"en" => [
"en" => "English",
"en_US" => "English (US)",
"en_GB" => "English (GB)",
"en_CA" => "English (CA)",
],
"af" => "Afrikaans",
"da" => "Danish",
"nl" => "Dutch",
"eo" => "Esperanto",
"fr" => "French",
"gl" => "Galician",
"de" => [
"de" => "German",
"de-alt" => "Alt. German",
],
"grc" => "Greek",
"it" => "Italian",
"la" => "Latin",
"pt" => "Portuguese",
"ro" => "Romanian",
"es" => "Spanish",
];
// build checkboxes
$dictionary_html = "";
foreach ($dictionaries as $code => $language) {
if (!is_array($language)) {
$language = [$code => $language];
}
$dictionary_html .= "<tr>";
foreach($language as $code => $locale_name) {
$checked = ($code == "en") ? "checked" : "";
$dictionary_html .= "<td align='right' style='padding-left:30px'>$locale_name: <input type='checkbox' name='wlangs[]' value='$code' $checked></td>";
}
$dictionary_html .= "</tr>";
}
echo <<<MENU
<p>This page provides a consolidated pptext program used to check books before
posting them to Project Gutenberg. This program checks a UTF-8 or a Latin-1 text file. A
related program, <a href='pphtml.php'>pphtml</a>, checks the HTML version.
<p>This program is designed to work on an input text file(s) with certain characteristics:</p>
<ol>
<li>for punctuation checks, curly quotes are required</li>
<li>punctuation style is American (double-quotes used for quotations)</li>
<li>if there is a good words text file, it can be any legal filename</li>
<li>for very large files, it is suggested to
"skip edit distance checks" to significantly reduce run time.</li>
<li>by default, all tests are run. You can choose to enable or disable individual tests.
<li>filenames must not contain an apostrophe</li>
</ol>
<p>To use this program, drag and drop a text file onto the top "Browse" button below.
The text file is the book you want to check.
You may also drag and drop a "good words" file onto the second "Browse" button if you choose.
Choose one or more languages and any options you want. Then click "Submit" and wait
about 30 seconds. Even compiled, a tremendous amount of processing has to get done.
Very large text files (roughly 1 meg) could take up to 15 minutes.
When it's
finished you should see a screen announcing "Pptext Results" with a link to the results
of the run. If the Smart Quote Check generated a report, a link to that report will also
be provided on the Results page.
Left click to view or right click the link to download the results.</p>
<form target="_blank" action="pptext-action.php" method="POST" enctype="multipart/form-data">
<table>
<tr>
<td style='text-align:right'><label for='userfile'>User text file </label></td>
<td><input type="file" name="userfile" id="userfile"></td>
</tr>
<tr>
<td style='text-align:right'><label for='goodfile'>Good words file (optional)</label></td>
<td><input type="file" name="goodfile" id="goodfile"></td>
</tr>
</table>
<div>Select wordlist language(s)<br>
<table style='margin-left: 50px;'>
$dictionary_html
</table>
</div>
<br>
<div>Select/unselect Tests<br>
<input type="checkbox" name="rat" value="Yes" id='rat' class="chk_boxes">
<label for="rat">run all tests</label><br>
<hr style='border:none; border-bottom:1px solid silver; width:10%; float:left; margin-left:24px;'><br>
<input type="checkbox" name="rspl" value="Yes" id="rspl" class="chk_boxes1">
<label for="rspl">run spellcheck</label><br>
<input type="checkbox" name="redi" value="Yes" id="redi" class="chk_boxes1">
<label for="redi">run edit distance check</label><br>
<input type="checkbox" name="rtxt" value="Yes" id="rtxt" class="tchk chk_boxes1 chk_t">
<label for="rtxt">run text checks</label><br>
<input type="checkbox" name="rthc" value="Yes" id="rthc" class="tchks chk_boxes1 chk_t1">
<label for="rthc"> run hyphen consistency</label><br>
<input type="checkbox" name="rhsc" value="Yes" id="rhsc" class="tchks chk_boxes1 chk_t1">
<label for="rhsc"> run hyphen-space consistency</label><br>
<input type="checkbox" name="rjee" value="Yes" id="rjee" class="chk_boxes1">
<label for="rjee">run jeebies check</label><br>
<input type="checkbox" name="rsqc" value="Yes" id="rsqc" class="chk_boxes1">
<label for="rsqc">run smart quote check</label><br>
</div>
<br>
<input type="checkbox" name="ver" value="Yes" id="ver">
<label for="ver">verbose operation</label><br>
<div style='margin-top:1em; margin-bottom:0em;'><input type="submit" value="Submit" name="upload"></div>
</form>
MENU;
}
function get_js()
{
return <<<JS
$(document).ready(function() {
$('.chk_boxes').click(function(){
$('.chk_boxes1').prop('checked',this.checked);
});
$('.chk_t').click(function(){
$('.chk_t1').prop('checked',this.checked);
});
$('.chk_boxes1').click(function(){
$('.chk_boxes').prop('checked',false);
});
$('.tchks').click(function(){
$('.tchk').prop('checked',true);
});
$('.chk_boxes1').prop('checked',true);
$('.chk_boxes').prop('checked',true);
});
JS;
}