Week 10 - DCG PDF

Title Week 10 - DCG
Course Artificial Intelligence
Institution University of New South Wales
Pages 3
File Size 99.9 KB
File Type PDF
Total Downloads 42
Total Views 120

Summary

COMP3411 tutorial questions...


Description

Resources / Tutorials (/COMP3411/21T1/resources/57728) / Week 10 - Definite Clause Grammars

Week 10 - Definite Clause Grammars Augmented Grammars and Semantics in Natural Language Extend the following grammar to handle simple semantics, i.e. to determine the price of a purchase:

sentence --> noun_phrase, verb_phrase. noun_phrase --> proper_noun. noun_phrase --> pronoun. noun_phrase --> article, noun. verb_phrase --> trans_verb, objective_noun_phrase. article --> [a]. article --> [the]. trans_verb --> [buy]. trans_verb --> [buys]. % will limit ourselves to using these names proper_noun --> [peter]. proper_noun --> [sarah]. proper_noun --> [john]. proper_noun --> [alice]. proper_noun --> [jenny]. proper_noun --> [james]. noun noun noun noun

--> --> --> -->

[buyer]. [buyers]. [customer]. [customers].

objective_noun_phrase --> nums, [of], object. objective_noun_phrase --> nums, object. object object object object object object

--> --> --> --> --> -->

[apple]. [apples]. [peach]. [peaches]. [strawberry]. [strawberries].

nums --> num. nums --> num,doz. nums --> [a],doz. num num num num num num num num num num

--> --> --> --> --> --> --> --> --> -->

[one]. [two]. [three]. [four]. [five]. [six]. [seven] [eight]. [nine]. [ten].

doz doz doz doz

--> --> --> -->

[halfdozen]. [dozen]. [halfdozens]. [dozens].

pronoun pronoun pronoun pronoun

--> --> --> -->

[he]. [we]. [you]. [they].

The Task Make the following modifications: Add parameters to the grammar rules so that singular and plural in nouns as well as the 's' in verbs is treated properly. Make sure that all sentences that are recognised by your modified grammar are grammatically correct, i.e. that 'buys' instead of 'buy' is only used where appropriate etc. Also make sure that 'of' is only used after 'dozens' or 'halfdozens' - not after numbers of dozens. But note, we will not be testing the grammatically correct "john buys dozens of peaches" because the price is indeterminate. Allow for the calculation of total price of purchases that can be described by grammatical sentences. Assume that one peach costs 3 dollars, one apple 2 dollars and one strawberry 1 dollar. The sentence predicate must be called with three arguments. For example: ?- sentence(TotalPrice, [john,buys,three,dozen,peaches], []). TotalPrice = 108

?- sentence(TotalPrice, [john,buy,three,dozens,of,peaches], []). false

?- sentence(TotalPrice, [we,buy,one,dozens,of,strawberry], []). false

?- sentence(TotalPrice, [he,buys,one,dozen,strawberries], []). TotalPrice = 12

?- sentence(TotalPrice, [a,customers,buy,one,dozen,of,strawberries], []). false

Resource created 3 months ago (Saturday 06 February 2021, 09:11:00 PM).

Comments   (/COMP3411/21T1/forums/search?forum_choice=resource/57743)  (/COMP3411/21T1/forums/resource/57743)

 Add a comment

There are no comments yet....


Similar Free PDFs