First commit.
This commit is contained in:
26
subsites/projects/nalgh/example.php
Executable file
26
subsites/projects/nalgh/example.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
include('nalgh.php');
|
||||
header('content-type: text/plain; charset=utf-8');
|
||||
|
||||
//$txt = 'The paper was nervous. After the day of destiny it had not dared to leave the printer. The printer seemed unhappy with the situation and had subsequently tried to cheer up the piece of paper. But death had taken its toll. The ink was no more.';
|
||||
|
||||
$fn = 'writeclearly-preface';
|
||||
$f = fopen($fn, 'r');
|
||||
$txt = fread($f, filesize($fn));
|
||||
fclose($f);
|
||||
|
||||
$len = strlen($txt);
|
||||
$ntxt = nalgh_compress($txt);
|
||||
$nlen = strlen($ntxt);
|
||||
$dtxt = nalgh_decompress($ntxt);
|
||||
$dlen = strlen($dtxt);
|
||||
|
||||
echo $txt;
|
||||
echo "\nOriginal text: $len\n\n";
|
||||
echo $ntxt;
|
||||
echo "\nCompressed text: $nlen\n\n";
|
||||
echo $dtxt;
|
||||
echo "\nDecompressed text: $dlen\n\n";
|
||||
|
||||
echo 'Compressed takes up '. $nlen / $len * 100 . '% of original.';
|
||||
?>
|
||||
75
subsites/projects/nalgh/nalgh.php
Executable file
75
subsites/projects/nalgh/nalgh.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
//WTFPL 2.0
|
||||
function nalgh_compress($txt) {
|
||||
$len = strlen($txt);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$c[substr($txt, $i, 1)]++;
|
||||
}
|
||||
|
||||
while ($n = current($c)) {
|
||||
$l[sizeof($l)] = array($n, key($c));
|
||||
next($c);
|
||||
}
|
||||
sort($l);
|
||||
$l = array_reverse($l);
|
||||
|
||||
$i = 0;
|
||||
foreach ($l as $t) {
|
||||
$f[$t[1]] = decbin($i);
|
||||
$i++;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$r .= '2' . $f[substr($txt, $i, 1)];
|
||||
}
|
||||
$r = substr($r, 1);
|
||||
$rlen = strlen($r);
|
||||
|
||||
$extra = 5 - ($rlen % 5);
|
||||
$extra == 5 ? $extra = 0 : pass;
|
||||
for ($i = 0; $i < $extra; $i++) {
|
||||
$r .= '2';
|
||||
}
|
||||
$rlen += $extra;
|
||||
|
||||
for ($i = 0; $i < $rlen; $i += 5) {
|
||||
$e .= chr((int)base_convert(substr($r, $i, 5), 3, 10));
|
||||
}
|
||||
|
||||
$ee = chr('' . sizeof($f) - 1 . '');
|
||||
|
||||
reset($f);
|
||||
$ee .= key($f);
|
||||
next($f);
|
||||
while ($fe = current($f)) {
|
||||
$ee .= key($f);
|
||||
next($f);
|
||||
}
|
||||
$e = $ee . $e;
|
||||
return $e;
|
||||
}
|
||||
|
||||
function nalgh_decompress($txt) {
|
||||
$olen = ord(substr($txt, 0, 1)) + 1;
|
||||
for ($i = 0; $i < $olen; $i++) {
|
||||
$s['' . decbin($i) . ''] = substr($txt, $i + 1, 1);
|
||||
}
|
||||
|
||||
$txt = substr($txt, $olen + 1);
|
||||
$len = strlen($txt);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$t = base_convert(ord(substr($txt, $i, 1)), 10, 3);
|
||||
$tlen = 5 - strlen($t);
|
||||
for ($ii = 0; $ii < $tlen; $ii++) {
|
||||
$t = '0' . $t;
|
||||
}
|
||||
$r .= $t;
|
||||
}
|
||||
$p = explode('2', $r);
|
||||
|
||||
foreach ($p as $t) {
|
||||
$e .= $s[$t];
|
||||
}
|
||||
return $e;
|
||||
}
|
||||
?>
|
||||
127
subsites/projects/nalgh/writeclearly-preface
Executable file
127
subsites/projects/nalgh/writeclearly-preface
Executable file
@@ -0,0 +1,127 @@
|
||||
Almost every English boy can be taught to write clearly, so far at
|
||||
least as clearness depends upon the arrangement of words. Force,
|
||||
elegance, and variety of style are more difficult to teach, and far
|
||||
more difficult to learn; but clear writing can be reduced to rules. To
|
||||
teach the art of writing clearly is the main object of these Rules and
|
||||
Exercises.
|
||||
|
||||
Ambiguity may arise, not only from bad arrangement, but also from
|
||||
other causes--from the misuse of single words, and from confused
|
||||
thought. These causes are not removable by definite rules, and
|
||||
therefore, though not neglected, are not prominently considered in
|
||||
this book. My object rather is to point out some few continually
|
||||
recurring causes of ambiguity, and to suggest definite remedies in
|
||||
each case. Speeches in Parliament, newspaper narratives and articles,
|
||||
and, above all, resolutions at public meetings, furnish abundant
|
||||
instances of obscurity arising from the monotonous neglect of some
|
||||
dozen simple rules.
|
||||
|
||||
The art of writing forcibly is, of course, a valuable
|
||||
acquisition--almost as valuable as the art of writing clearly. But
|
||||
forcible expression is not, like clear expression, a mere question of
|
||||
mechanism and of the manipulation of words; it is a much higher power,
|
||||
and implies much more.
|
||||
|
||||
Writing clearly does not imply thinking clearly. A man may think and
|
||||
reason as obscurely as Dogberry himself, but he may (though it is not
|
||||
probable that he will) be able to write clearly for all that. Writing
|
||||
clearly--so far as arrangement of words is concerned--is a mere matter
|
||||
of adverbs, conjunctions, prepositions, and auxiliary verbs, placed
|
||||
and repeated according to definite rules.[1] Even obscure or illogical
|
||||
thought can be clearly expressed; indeed, the transparent medium of
|
||||
clear writing is not least beneficial when it reveals the illogical
|
||||
nature of the meaning beneath it.
|
||||
|
||||
On the other hand, if a man is to write forcibly, he must (to use a
|
||||
well-known illustration) describe Jerusalem as "sown with salt," not
|
||||
as "captured," and the Jews not as being "subdued" but as "almost
|
||||
exterminated" by Titus. But what does this imply? It implies
|
||||
knowledge, and very often a great deal of knowledge, and it implies
|
||||
also a vivid imagination. The writer must have eyes to see the vivid
|
||||
side of everything, as well as words to describe what he sees. Hence
|
||||
forcible writing, and of course tasteful writing also, is far less a
|
||||
matter of rules than is clear writing; and hence, though forcible
|
||||
writing is exemplified in the exercises, clear writing occupies most
|
||||
of the space devoted to the rules.
|
||||
|
||||
Boys who are studying Latin and Greek stand in especial need of help
|
||||
to enable them to write a long English sentence clearly. The periods
|
||||
of Thucydides and Cicero are not easily rendered into our idiom
|
||||
without some knowledge of the links that connect an English sentence.
|
||||
|
||||
There is scarcely any better training, rhetorical as well as logical,
|
||||
than the task of construing Thucydides into genuine English; but the
|
||||
flat, vague, long-winded Greek-English and Latin-English imposture
|
||||
that is often tolerated in our examinations and is allowed to pass
|
||||
current for genuine English, diminishes instead of increasing the
|
||||
power that our pupils should possess over their native language. By
|
||||
getting marks at school and college for construing good Greek and
|
||||
Latin into bad English, our pupils systematically unlearn what they
|
||||
may have been allowed to pick up from Milton and from Shakespeare.
|
||||
|
||||
I must acknowledge very large obligations to Professor Bain's treatise
|
||||
on "English Composition and Rhetoric," and also to his English
|
||||
Grammar. I have not always been able to agree with Professor Bain as
|
||||
to matters of taste; but I find it difficult to express my admiration
|
||||
for the systematic thoroughness and suggestiveness of his book on
|
||||
Composition. In particular, Professor Bain's rule on the use of "that"
|
||||
and "which" (see Rule 8) deserves to be better known.[2] The ambiguity
|
||||
produced by the confusion between these two forms of the Relative is
|
||||
not a mere fiction of pedants; it is practically serious. Take, for
|
||||
instance, the following sentence, which appeared lately in one of our
|
||||
ablest weekly periodicals: "There are a good many Radical members in
|
||||
the House _who_ cannot forgive the Prime Minister for being a
|
||||
Christian." Twenty years hence, who is to say whether the meaning is
|
||||
"_and they_, i.e. _all the Radical_ members in the House," or "there
|
||||
are a good many Radical members of the House _that_ cannot &c."?
|
||||
Professor Bain, apparently admitting no exceptions to his useful rule,
|
||||
amends many sentences in a manner that seems to me intolerably harsh.
|
||||
Therefore, while laying due stress on the utility of the rule, I have
|
||||
endeavoured to point out and explain the exceptions.
|
||||
|
||||
The rules are stated as briefly as possible, and are intended not so
|
||||
much for use by themselves as for reference while the pupil is working
|
||||
at the exercises. Consequently, there is no attempt to prove the rules
|
||||
by accumulations of examples. The few examples that are given, are
|
||||
given not to prove, but to illustrate the rules. The exercises are
|
||||
intended to be written out and revised, as exercises usually are; but
|
||||
they may also be used for _vivâ voce_ instruction. The books being
|
||||
shut, the pupils, with their written exercises before them, may be
|
||||
questioned as to the reasons for the several alterations they have
|
||||
made. Experienced teachers will not require any explanation of the
|
||||
arrangement or rather non-arrangement of the exercises. They have been
|
||||
purposely mixed together unclassified to prevent the pupil from
|
||||
relying upon anything but his own common sense and industry, to show
|
||||
him what is the fault in each case, and how it is to be amended.
|
||||
Besides references to the rules, notes are attached to each sentence,
|
||||
so that the exercises ought not to present any difficulty to a
|
||||
painstaking boy of twelve or thirteen, provided he has first been
|
||||
fairly trained in English grammar.
|
||||
|
||||
The "Continuous Extracts" present rather more difficulty, and are
|
||||
intended for boys somewhat older than those for whom the Exercises are
|
||||
intended. The attempt to modernize, and clarify, so to speak, the
|
||||
style of Burnet, Clarendon, and Bishop Butler,[3] may appear
|
||||
ambitious, and perhaps requires some explanation. My object has, of
|
||||
course, not been to _improve upon_ the style of these authors, but to
|
||||
show how their meaning might be expressed more clearly in modern
|
||||
English. The charm of the style is necessarily lost, but if the loss
|
||||
is recognized both by teacher and pupil, there is nothing, in my
|
||||
opinion, to counterbalance the obvious utility of such exercises.
|
||||
Professor Bain speaks to the same effect:[4] "For an English exercise,
|
||||
the matter should in some way or other be supplied, and the pupil
|
||||
disciplined in giving it expression. I know of no better method than
|
||||
to prescribe passages containing good matter, but in some respects
|
||||
imperfectly worded, to be amended according to the laws and the
|
||||
proprieties of style. Our older writers might be extensively, though
|
||||
not exclusively, drawn upon for this purpose."
|
||||
|
||||
To some of the friends whose help has been already acknowledged in
|
||||
"English Lessons for English People," I am indebted for further help
|
||||
in revising these pages. I desire to express especial obligations to
|
||||
the Rev. J. H. Lupton, late Fellow of St. John's College, Cambridge,
|
||||
and Second Master of St. Paul's School, for copious and valuable
|
||||
suggestions; also to several of my colleagues at the City of London
|
||||
School, among whom I must mention in particular the Rev. A. R. Vardy,
|
||||
Fellow of Trinity College, Cambridge.
|
||||
|
||||
Reference in New Issue
Block a user