Add 2018/ciura/try.sh, missing PDF + formatting

The try.sh script does not use less for longer output because for some
reason less options -r/-R do not seem to work with the output (I haven't
looked into it in detail of how it works).

The missing PDF file was a paper I believe by the actual author but was
a dead link. Retrieved from the Internet Wayback Machine.

Format/typo check README.md file.

I believe this completes this entry's review.
This commit is contained in:
Cody Boone Ferguson committed 2023-12-11 09:22:14 -08:00
1 parent 70bb65f47e
commit 1959925eda
4 files changed
+80 -29

No files matched your search

+46 -29
View File
@@ -4,6 +4,10 @@
make make
``` ```
There is an alternate version that lacks a useful bug fix. See [Alternate
code](#alternate-code) and the author's remarks ([remarks section](#remarks))
below for more details.
## To use: ## To use:
@@ -22,31 +26,38 @@ make
## Alternate code: ## Alternate code:
An alternate version of this entry, `prog.alt.c`, is provided. As mentioned in An alternate version of this entry, [prog.alt.c](prog.alt.c), is provided. As
the Author's remarks, the alternate version lacks a useful bug fix. mentioned in the author's [remarks](#remarks), the alternate version lacks a
useful bug fix.
### Alternate build:
To compile this alternate version:
```sh ```sh
make alt make alt
``` ```
### Alternate use:
Use `prog.alt` as you would `prog` above. Use `prog.alt` as you would `prog` above.
## Judges' remarks: ## Judges' remarks:
This text was processed by prog. You may get confused. This text was processed by `prog`. You may get confused. We're not really sure:
We're not really sure: prog.c wasn't commented. [prog.c](prog.c) wasn't commented. Who has been thoroughly puzzled by `prog`?
Who has been thoroughly puzzled by prog? Also how obfuscated is prog? Also how obfuscated is `prog`? Having been written in C, how large of a
Having been written in C, how large of a vocabulary has it? vocabulary has it?
## Author's remarks: ## Author's remarks:
### The Program: ### The Program:
"The Elements of Style" by prof. William Strunk, Jr. and E. B. White "The Elements of Style" by Prof. William Strunk, Jr. and E. B. White
is well known for its dislike of the passive voice. Direct, vigorous, is well known for its dislike of the passive voice. Direct, vigorous,
active constructions were instead recommended by the authors. active constructions were instead recommended by the authors.
The development of this program has been driven by this tenet. The development of this program has been driven by this tenet.
@@ -69,22 +80,24 @@ constructions are recognized:
Sentences are never broken by periods that follow abbreviations and Sentences are never broken by periods that follow abbreviations and
initials. Both regular and irregular past participles are properly initials. Both regular and irregular past participles are properly
dealt with. Note that some words are red herrings: even though their dealt with. Note that some words are red herrings: even though their
ending is -ed, they are not past participles. ending is `-ed`, they are not past participles.
### The Big String: ### The Big String:
Here is the purpose of every byte inside the `c[]` string: Here is the purpose of every byte inside the `c[]` string:
* 0-9: highlighting passive constructions in the output. * `0-9`: highlighting passive constructions in the output.
* 10-50: classifying characters - called by `V(4)`. * `10-50`: classifying characters - called by `V(4)`.
* 52: outputting the newline character. * `52`: outputting the newline character.
* 51-187: tokenizing text and detecting passive constructions - two type A * `51-187`: tokenizing text and detecting passive constructions - two type A
state machines, called by `V(2)` and `V(3)`. state machines, called by `V(2)` and `V(3)`.
* 186-2786: determining word categories (past participles, present simple and * `186-2786`: determining word categories (past participles, present simple and
past simple forms of "to be", other forms of "to be", adverbs, wh-words, and past simple forms of "to be", other forms of "to be", adverbs, wh-words, and
other words) and recognizing abbreviations - two type B state machines, called other words) and recognizing abbreviations - two type B state machines, called
by `V(808)` and `V(205)`. by `V(808)` and `V(205)`.
### The State Machines: ### The State Machines:
I heard you don't like state machines so I put a state machine in your I heard you don't like state machines so I put a state machine in your
@@ -94,6 +107,7 @@ Both types of state machines in the program are Mealy machines: we can
think of their transitions as triples (`transition_label`, think of their transitions as triples (`transition_label`,
`next_state`, `output`). `next_state`, `output`).
### Type A: ### Type A:
A state of type A state machine consists of eight transitions whose A state of type A state machine consists of eight transitions whose
@@ -155,11 +169,12 @@ And here are sample steps of scanning tokens with classes `to_be`,
* `state` = 22, `transition_label` = 0 (`adverb`), `output` = `ignore` * `state` = 22, `transition_label` = 0 (`adverb`), `output` = `ignore`
* `state` = 22, `transition_label` = 3 (`past_participle`), `output` = `passive_construction_end` * `state` = 22, `transition_label` = 3 (`past_participle`), `output` = `passive_construction_end`
### Type B: ### Type B:
Type B state machines are built by a variant of the algorithm described Type B state machines are built by a variant of the algorithm described
in the paper in the paper
[How to squeeze a lexicon](http://sun.aei.polsl.pl/~mciura/publikacje/lexicon.pdf). [How to squeeze a lexicon (PDF)](lexicon.pdf).
Their states are represented as interlaced sparse arrays of transitions. Their states are represented as interlaced sparse arrays of transitions.
The `transition_label` is one of: The `transition_label` is one of:
@@ -203,6 +218,7 @@ A type B state machine starts in a given `state` with `output`
set to `ignore`. It scans a word backwards, converting character by set to `ignore`. It scans a word backwards, converting character by
character to `transition_label`. When it meets `word_start`, it character to `transition_label`. When it meets `word_start`, it
returns, leaving the most recently stored `output` in `v`. returns, leaving the most recently stored `output` in `v`.
It also returns when It also returns when
`c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output)`, `c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output)`,
i.e. when the `transition_label` in the byte mismatches the i.e. when the `transition_label` in the byte mismatches the
@@ -215,33 +231,34 @@ class is set up so that it never returns `ignore`.
Below are sample steps of scanning the word "chiefly". Below are sample steps of scanning the word "chiefly".
* `state` = 623, `transition_label` = 26 ('y'), `output` = `other` * `state` = 623, `transition_label` = 26 (`'y'`), `output` = `other`
* `state` = 602, `transition_label` = 13 ('l'), `output` = `adverb` * `state` = 602, `transition_label` = 13 (`'l'`), `output` = `adverb`
* `state` = 594, `transition_label` = 7 ('f'), `output` = `other` * `state` = 594, `transition_label` = 7 (`'f'`), `output` = `other`
* `state` = 549, `transition_label` = 6 ('e'), `output` = `ignore` * `state` = 549, `transition_label` = 6 (`'e'`), `output` = `ignore`
* `state` = 543, `transition_label` = 10 ('i'), `output` = `adverb` * `state` = 543, `transition_label` = 10 (`'i'`), `output` = `adverb`
* `state` = 0, `transition_label` = 9 ('h') mismatches the value stored * `state` = 0, `transition_label` = 9 (`'h'`) mismatches the value stored
in the byte. Return `adverb`. in the byte. Return `adverb`.
And here are sample steps of scanning the string "i.e.": And here are sample steps of scanning the string "i.e.":
* `state` = 19, `transition_label` = 1 ('.'), `output` = `ignore` * `state` = 19, `transition_label` = 1 (`'.'`), `output` = `ignore`
* `state` = 24, `transition_label` = 6 ('e'), `output` = `ignore` * `state` = 24, `transition_label` = 6 (`'e'`), `output` = `ignore`
* `state` = 3, `transition_label` = 1 ('.'), `output` = `ignore` * `state` = 3, `transition_label` = 1 (`'.'`), `output` = `ignore`
* `state` = 2, `transition_label` = 10 ('i'), `output` = `ignore` * `state` = 2, `transition_label` = 10 (`'i'`), `output` = `ignore`
* `state` = 1, `transition_label` = 0 ('\0'), `output` = `abbreviation`. * `state` = 1, `transition_label` = 0 (`'\0'`), `output` = `abbreviation`.
Return `abbreviation`. Return `abbreviation`.
### Remarks: ### Remarks:
The judges found a bug in the handling of contractions: `prog.alt.c` The judges found a bug in the handling of contractions: [prog.alt.c](prog.alt.c)
outputs "foo wasn'**[t bazzed]**". I fixed the bug in `prog.c`, making outputs "foo wasn'**[t bazzed]**". I fixed the bug in [prog.c](prog.c), making
it output "foo **[wasn't bazzed]**" instead, and took the liberty to merge it output "foo **[wasn't bazzed]**" instead, and took the liberty to merge
one statement into a `for` loop inside its `main()` function. one statement into a `for` loop inside its `main()` function.
The program uses a 9,437,187-byte buffer so it probably will not run The program uses a 9,437,187-byte buffer so it probably will not run
on 16-bit and smaller machines without changing the size of array `C[]` on 16-bit and smaller machines without changing the size of array `C[]`
and the expression `9<<20` inside the call to `read()`. and the expression `9<<20` inside the call to `read(2)`.
I have tested it on: I have tested it on:
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2018/ciura
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
read -r -n 1 -p "Press any key to run: ./prog < Makefile: "
echo 1>&2
./prog < Makefile
echo 1>&2
read -r -n 1 -p "Press any key to run: ./prog < README.md: "
echo 1>&2
./prog < README.md
exit 0
+7
View File
@@ -3949,6 +3949,13 @@ He also added the [try.sh](/2015/yang/try.sh) script.
(Linux doesn't seem to but macOS does). (Linux doesn't seem to but macOS does).
## <a name="2018_ciura"></a>[2018/ciura](/2018/ciura/prog.c) ([README.md](/2018/ciura/README.md))
[Cody](#cody) added the [try.sh](/2018/ciura/try.sh) script and the PDF file,
[lexicon.pdf](/2018/ciura/lexicon.pdf), that was a dead link, restored from the
Internet Wayback Machine.
## <a name="2018_ferguson"></a>[2018/ferguson](/2018/ferguson/prog.c) ([README.md](/2018/ferguson/README.md)) ## <a name="2018_ferguson"></a>[2018/ferguson](/2018/ferguson/prog.c) ([README.md](/2018/ferguson/README.md))
[Cody](#cody), with irony well intended :-), fixed the [test.sh [Cody](#cody), with irony well intended :-), fixed the [test.sh