Most likely to be awarded

Marcin Ciura mciura@gmail.com
Twitter: @mciura

Judges' comments:

To use:

make

./prog < text

Try:

./prog < Makefile
./prog < hint.text

Selected Judges Remarks:

This text was processed by prog. You may get confused. We’re not really sure: prog.c wasn’t commented. Who has been thoroughly puzzled by prog? Also how obfuscated is prog? Having been written in C, how large of a vocabulary has it?

Author’s comments:

The Program

“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, active constructions were instead recommended by the authors. The development of this program has been driven by this tenet.

Only passive sentences from the standard input are output. The offending part(s) of each sentence will be highlighted. Several kinds of passive constructions are recognized:

Sentences are never broken by periods that follow abbreviations and initials. Both regular and irregular past participles are properly dealt with. Note that some words are red herrings: even though their ending is -ed, they are not past participles.

The Big String

Here is the purpose of every byte inside the c[] string:

The State Machines

I heard you don’t like state machines so I put a state machine in your state machine so you can reject this entry while you reject this entry.

Both types of state machines in the program are Mealy machines: we can think of their transitions as triples (transition_label, next_state, output).

Type A

A state of type A state machine consists of eight transitions whose representations occupy consecutive bytes. The byte c[3 + 8*state + transition_label] contains (unsigned char)(30 + 5*next_state + output).

The transition_label is either one of character classes:

or one of word classes:

The output is either one of:

or one of

Type A state machines run continuously. Their state is kept in k[2] and k[3].

Below are sample steps of scanning a sequence of characters with classes uppercase, lowercase, period, space, and uppercase.

And here are sample steps of scanning tokens with classes to_be, adverb, past_participle.

Type B

Type B state machines are built by a variant of the algorithm described in the paper How to squeeze a lexicon. Their states are represented as interlaced sparse arrays of transitions.

The transition_label is one of:

The output is either one of word classes:

or

The byte c[186 + (state + transition_label)] = (unsigned char)(2 + transition_label + 28 * output).

The byte c[836 + 2*(state + transition_label)] =

The byte c[837 + 2*(state + transition_label)] =

The byte c[2136 + (state + transition_label)] = (unsigned char)(32 + next_state % 94).

A type B state machine starts in a given state with output set to ignore. It scans a word backwards, converting character by character to transition_label. When it meets word_start, it returns, leaving the most recently stored output in v. It also returns when c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output), i.e. when the transition_label in the byte mismatches the transition_label used to compute the index. Otherwise, if the output in this byte differs from ignore, the state machine stores it in v. Regardless of the value of the output, it also assigns next_state to state and proceeds to scan the previous character. The state machine that determines the word class is set up so that it never returns ignore.

Below are sample steps of scanning the word “chiefly”.

And here are sample steps of scanning the string “i.e.”:

Remarks

The judges found a bug in the handling of contractions: prog.orig.c outputs “foo wasn'[t bazzed]”. I fixed the bug in prog.c, making it output “foo [wasn’t bazzed]” instead, and took the liberty to merge 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 on 16-bit and smaller machines without changing the size of array C[] and the expression 9<<20 inside the call to read().

I have tested it on:

For a clean compile under c89 and c90, add -Woverlength-strings to CSILENCE.


Creative Commons License

© Copyright 1984-2018, Leo Broukhis, Simon Cooper, Landon Curt Noll - All rights reserved
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.