program Cloze; {$S+} {$M 32768,0,655360} uses crt, Printer; const XREPORT = 5; FILL = '____________'; var i, count, answer, report,errorcode: 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 TextColor(Yellow); TextBackground(Blue); clrscr; count := 0; word_end := true; word := ''; answer := 1; report := Xreport; inform; 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 enter the name of the input file'); readln(infilename); writeln(' Please name the output file'); readln(outfilename); assign(myin, infilename); assign(myout, outfilename); {$I-} reset(myin); errorCode:=IoResult; {$I+} if errorCode <> 0 then begin Writeln('ERROR ERROR ERROR'); writeln('The program looked for the file: ',infilename,'.'); writeln('But the file was not found.'); end else begin rewrite(myout); 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:10); 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 enter key to exit this program'); readln(dummy); end;{file was found} end.