program Cloze; {A cloze test involves taking a document (or a document sample) of } {about 250 words and deleting every fifth word (these seem to be the } {canonical numbers,) leaving a blank in its place. The reader is then } {asked to fill in the missing words.} {} {In technical writing we use this as a test of readability. The idea is } {that there should be sufficient (local) redundancy in a document to } {allow a reader to score in the 50-60% range. Used in this way it } {measures the writer not the reader.} {} {This program asks the user to specify the deletion interval (in case } {you don't like every fifth word), the name of the text file to be } {clozed, and the name of the file in which the test is to be stored.} {} {The program replaces words with numbered underlined spaces and } {generates an answer key at the end of the document.} const XREPORT = 5; FILL = '____________'; var i, count, answer, report: integer; word_end, end_before: boolean; word, infilename, outfilename: string; answer_list: array[1..300] of string[20]; myin, myout: text; tab, lett, dummy: char; procedure inform; var i: integer; begin for I := 1 to 3 do writeln; writeln('A cloze test involves taking a document (or a document sample) of '); writeln('about 250 words and deleting every fifth word (these seem to be the '); writeln('canonical numbers,) leaving a blank in its place. The reader is then '); writeln('asked to fill in the missing words.'); writeln(''); writeln('In technical writing we use this as a test of readability. The idea is '); writeln('that there should be sufficient (local) redundancy in a document to '); writeln('allow a reader to score in the 50-60% range. Used in this way it '); writeln('measures the writer not the reader.'); writeln(''); writeln('This program asks the user to specify the deletion interval (in case '); writeln('you don''t like every fifth word ) , the name of the text file to be '); writeln('clozed, and the name of the file in which the test is to be stored.'); writeln(''); writeln('The program replaces words with numbered underlined spaces and '); writeln('generates an answer key at the end of the document.'); end; begin SetTextRect(screenBits.bounds); ShowText; count := 0; word_end := true; word := ''; answer := 1; report := Xreport; inform; { for i := 1 to 18 do writeln;} writeln; writeln('Enter the interval at which words should be deleted.'); writeln('The recommended value is 5.'); readln(report); if report < 1 then report := XREPORT; writeln('Please select the input file'); infilename := OldFileName('Open Data File'); writeln('Please name the output file'); outfilename := NewFileName('Name output File', 'Cloze Test'); reset(myin, infilename); rewrite(myout, outfilename); write(myout, ' '); writeln('counting words:'); while ((not eof(myin)) and (answer <= 300)) do begin if eoln(myin) then writeln(myout); read(myin, lett); if lett in ['A'..'Z', 'a'..'z', '''', '-'] then begin word := concat(word, lett); word_end := false; end {in a word} else begin if word_end = false then begin count := count + 1; if count mod REPORT = 0 then begin writeln(count); write(myout, '(', answer : 1, ')', FILL); answer_list[answer] := word; answer := answer + 1; end {cut this one} else begin write(myout, word); end;{don't cut} word_end := true; word := ''; write(myout, lett); end{word_end = false} else write(myout, lett); end;{not in a word} end;{not eof} if answer > 300 then begin writeln(myout, 'WARNING: Maximum input size limit reached - text may be truncated.'); writeln('WARNING: Maximum input size limit reached - text may be truncated.'); end; writeln(myout); writeln(myout, ' ANSWERS'); writeln(myout); for i := 1 to answer - 1 do writeln(myout, i : 3, ' ', answer_list[i]); writeln('Cloze test generated -- Press return to exit this program'); readln(dummy); end.