Presentation is loading. Please wait.

Presentation is loading. Please wait.

Martin KayIntroduction to Prolog1 Problem 1 The following two slides contain part of the definition of a data base of English word forms using the lex/4.

Similar presentations


Presentation on theme: "Martin KayIntroduction to Prolog1 Problem 1 The following two slides contain part of the definition of a data base of English word forms using the lex/4."— Presentation transcript:

1 Martin KayIntroduction to Prolog1 Problem 1 The following two slides contain part of the definition of a data base of English word forms using the lex/4 predicate. With this data base as part of your program, answer questions 1.1 and 1.2.

2 Martin KayIntroduction to Prolog2 lex—1 lex(love, love, n, sing). lex(love, love, v, base). lex(loves, love, v, pres(sg, 3)). lex(loves, love, n, plur). lex(loving, love, v, pres_part). lex(loved, love, v, past). lex(grind, grind, v, base). lex(grinds, grind, v, pres(sg, 3)). lex(grinding, grind, v, pres_part). lex(ground, grind, v, past). lex(ground, ground, n, sing). lex(grounds, ground, n, plur). lex(see, see, v, base). lex(sees, see, v, pres(sg, 3)).

3 Martin KayIntroduction to Prolog3 lex—2 lex(seeing, see, v, pres_part). lex(saw, see, v, past_tense(_, _)). lex(seen, see, v, past_part). lex(hit, hit, v, short). lex(hits, hit, v, pres(sg, 3)). lex(hitting, hit, v, pres_part). lex(sheep, sheep, n, _). lex(X, X, v, base) :- lex(X, X, v, short). lex(X, X, v, past) :- lex(X, X, v, short). lex(X, X, v, inf) :- lex(X, X, v, base). lex(X, X, v, pres(sg, 1)) :- lex(X, X, v, base). lex(X, X, v, pres(sg, 3)) :- lex(X, X, v, base). lex(X, X, v, pres(pl, _)) :- lex(X, X, v, base).

4 Martin KayIntroduction to Prolog4 Question 1.1 Write a predicate ambiguous(X) that is true just in case X is a word that can be both a noun and a verb. It should allow you to do this: | ?- ambiguous(ground). yes | ?- ambiguous(see). no | ?- ambiguous(X). X=love yes | ?-

5 Martin KayIntroduction to Prolog5 Question 1.2 Notice that the verb “see” has a past_tense and a “past_part” form. The other verbs have only a “past” form, because there is no difference between their past- tense and past-participle forms. Write two new clauses which when applied to any verb with a “past” entry in the data base, will enable the past_tense and past_part forms to be found. They should make it possible to do at least this: | ?- lex(loved, love, v, past_tense). yes | ?- lex(loved, love, v, past_part). yes | ?-

6 Martin KayIntroduction to Prolog6 Problem 2 There is a much more efficient way of reversing a list than the one given in class. The trick is to use another predicate, with three arguments, to do the work, so that reverse itself is defined like this: reverse(A, B) :- rev (A, [], B). Write the two-clause definition of rev/3. reverse([], []). reverse([H|T], Rev) :- reverse(T, RT), append(RT, [H], Rev).

7 Martin KayIntroduction to Prolog7 Problem 3 Write a predicate delete(List1, Member, List2). which is true just in case List2 is the result of deleting Member from List1. The predicate should fail if Member is not a member of List1. | ?- delete([a,b,a,c,a,d,a,e], a, X). X = [b,a,c,a,d,a,e] ? ; X = [a,b,c,a,d,a,e] ? ; X = [a,b,a,c,d,a,e] ? ; X = [a,b,a,c,a,d,e] ? ; no | ?-


Download ppt "Martin KayIntroduction to Prolog1 Problem 1 The following two slides contain part of the definition of a data base of English word forms using the lex/4."

Similar presentations


Ads by Google