@style(references STDalphabetic,spacing 1,linewidth 70) @make(article) @device(LASER) @modify(figure,above 2,below 2) @modify(subheading, below 0) @set(page=1) @define(romanize,use enumerate,numbered <(@i)>) @define(alphabetize,use enumerate,numbered <(@a)>) @modify(FootnoteCounter, within page, numbered <@*>, referenced <@*>) @heading(AI1 Prolog Projects - Natural Language Project) @>Helen Pain@* @>@value(Date)@* This project is based on a program that generates sentences from an recursive transition network (RTN). The RTN representation of the grammar consists of a number of states and connecting arcs. The arcs are labelled by other RTN's (non-terminals) or by words (terminals). The RTN may be traversed and a sentence generated in the process of traversal. To run the program three files need to be consulted: @verbatim( '/ai/ai1teach/rtn' '/ai/ai1teach/drinks' '/ai/ai1teach/random') The file '/ai/ai1teach/rtn' contains the sentence generating predicates, generate and traverse. The file '/ai/ai1teach/drinks' contains the grammar itself - it comprises RTN's for sentence, nounphrase, verb, noun, determiner, adjective, proper_noun and stop_mark. The file '/ai/ai1teach/random' contains a number of predicates that are used to select an element from a list, at random. (NOTE: you do not have to worry about how the predicates in this file work - you only need to know that the predicate random_pick(List,El) matches List to a list of any number of elements and that El matches to a random element selected from that list). To generate a sentence, in response to the prompt type @verbatim(?- go.) Try this several times and explore the sentences generated. List the program. Trace the program and step through it. @verbatim(?- debug go.) When you think that you understand how the program works do the following: @begin(enumerate) Write a description of how the program works: a paragraph for each of the procedures in the program, describing what each procedure does, and how it does it. Draw the RTN's that are represented by the 'drinks' grammar. [see your Natural Language lecture notes]. Provide 6 examples of the sentences generated and an example trace of the program for two of these examples. Copy the "drinks" file to your area. Edit it to include the following additional vocabulary: @begin(verbatim) verbs - hates,pours nouns - pint, milk, glass adjectives - clear, fresh, full @end(verbatim) Include a listing of the editted grammar, and sample sentences produced, in your project report. @end(enumerate) In addition to the above, do at least two of the following extensions to the project. For each, include in your project report: @begin(romanize) a description of the extension to the program (including any new RTN's used); a listing of the program to indicate the changes made; a number of examples to illustrate the extension; any relevant discussion of the problem; how you solved it, how else you might have solved it, where it fails and why, etc. @end(romanize) @subheading(Program Extensions) 1. This program does not distinguish between subject and object. It can produce sentences such as: @verbatim( "the tea drinks the vicar") Rewrite the RTN's to prevent this. Rewrite the program (edit the "drinks" file) to include these new rtn's. 2. How could the program be altered to generate the following: @verbatim( fred like a pint of beer. the vicar pours a glass of sherry!) Add to the sentence grammar an RTN for prepositional phrases. Change the program to generate sentences that include these prepositional phrases. Try also adding conjunctions, for example: @verbatim( jane wants a vodka and tonic. the policeman drinks the tea and the beer?) Alter the program to generate these. 3. Copy the 'rtn' file and edit it so that a call of "go" prints a parse tree in the form: @begin(verbatim) sentence nounphrase determiner a noun vicar verb drinks nounphrase determiner the noun tea stop_mark . @end(verbatim) 4. Rewrite the drinks grammar and rtn to produce poems. (They do not have to rhyme!) 5. Rewrite the program so that, instead of generating a sentence, it takes a sentence, for example [the,vicar,loves,tea], and prints a parse of it using the grammar - or fails if it will not parse. [it might produce the same sort of parse tree as that above]. 6. Find out about the Prolog notation for "Definite Clause Grammars". Rewrite the sentence generator using these. Please provide TWO copies of your project report, including all listings and examples. These should be submitted to me, Helen Pain, by Monday ??????? ????(that is, Monday of week 2 of next term).