Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19.

Similar presentations


Presentation on theme: "LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19."— Presentation transcript:

1 LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19

2 2 Administrivia Homework 3 Review Homework 5: –Two Computer Lab Exercises –due next Thursday

3 3 Homework 3 Review

4 4 Homework Exercise 1 Numbers (3pts) –Question 1 (2pts) Give a single Microsoft Word regular expression for finding occurrences of –$number million where number not is a whole number of millions, e.g. –$25.3 million –$826.7 million –$3.1 million –Question 2 (1pts) How many are there of this kind in the document? Word regular expression: $[0-9]@.[0-9]@ million

5 5 Homework Exercise 2 Words (5pts) –Question 1 (2pts) Give a single Microsoft Word regular expression for finding occurrences of the following terms –spokesman –spokesmen –spokeswoman –spokeswomen –Question 2 (1pt) How many are there in the document? –Question 3 (1pt) What does your expression assume about words in English? –Question 4 (1pt) Why could the answer different from a simple spokes* search? Word regular expression: –Total: 49 spokesman 38 spokesmen 1 spokeswoman 10 spokeswomen 0 spokeswan spokeswoen etc. spokesperson spokespersons

6 6 Homework Exercise 3 Document Structure (8pts) Many articles contains a header line naming its author(s), e.g. @ By Carrie Dolan @ By Ron Winslow and Michael Waldholz @ By Jeffrey H. Birnbaum Note: @ and By are separated by exactly 2 spaces –Question 1 (2pts) Give a Microsoft Word regular expression to find header lines with first authors who use a middle initial –Question 2 (1pt) How many such articles are there in the document? Possible Word regular expressions include: \@ By [A-z]@ [A-Z]. \@ By [A-Z][a-z]@ [A-Z].

7 7 Homework Exercise 3 Document Structure –Question 3 (4pts) Devise multiple regular expressions to find two author header lines @ By Ron Winslow and Michael Waldholz @ By S. Karene Witcher and Jeffrey A. Trachtenberg HINT: –to overcome Microsoft Word’s behavior you will have to break up the search into multiple cases –Question 4 (1pt) How many such header lines are there in the document? –@ By Firstname Lastname and –@ By Firstname MI Lastname and Word regular expressions: \@ By [A-z]@ [A-z]@ and \@ By [A-z]@ [A-Z]. [A-z]@ and

8 8 Homework 5

9 9 DCG from Lecture 15 DCG (including parse tree representation): –s(s(Y,Z)) --> np(Y), vp(Z). –np(np(Y)) --> pronoun(Y). –np(np(det(the),n(ball))) --> [the,ball]. –pronoun(i) --> [i]. –pronoun(we) --> [we]. –vp(vp(Y)) --> unergative(Y). –vp(vp(Y,Z)) --> transitive(Y), np(Z). –unergative(v(ran)) --> [ran]. –transitive(v(hit)) --> [hit]. query –?- s(X,[john,hit,the,ball],[]). Result: parse tree

10 10 DCG from Lecture 15 data –the man/men –a man/*a men grammar (NP section) –np(np(Y)) --> pronoun(Y). –np(np(D,N)) --> det(D,Number), common_noun(N,Number). –det(det(the),_) --> [the]. –det(det(a),sg) --> [a]. –common_noun(n(ball),sg) --> [ball]. –common_noun(n(man),sg) --> [man]. –common_noun(n(men),pl) --> [men]. –pronoun(i) --> [i]. –pronoun(we) --> [we]. idea give determiners a number feature as well and make it agree with the noun rules the can combine with singular or plural nouns a can combine only with singular nouns Implement determiner-Noun Agreement by adding a 2nd argument

11 11 DCG from Lecture 15 We’ll use this grammar as our starting point for Homework 5 s(s(Y,Z)) --> np(Y), vp(Z). np(np(Y)) --> pronoun(Y). np(np(D,N)) --> det(D,Number), common_noun(N,Number). det(det(the),_) --> [the]. det(det(a),sg) --> [a]. common_noun(n(ball),sg) --> [ball]. common_noun(n(man),sg) --> [man]. common_noun(n(men),pl) --> [men]. pronoun(i) --> [i]. pronoun(we) --> [we]. vp(vp(Y)) --> unergative(Y). vp(vp(Y,Z)) --> transitive(Y), np(Z). unergative(v(ran)) --> [ran]. transitive(v(hit)) --> [hit].

12 12 Exercise 1 Let’s add some other determiners/quantifiers (12pts) Modify the grammar given to handle: –every man hit the ball –*every men hit the ball –*most man hit the ball –most men hit the ball –some man hit the ball –some men hit the ball –* (a) few man hit the ball –(a) few men hit the ball –no man hit the ball –no men hit the ball –one man hit the ball –*one men hit the ball –*two man hit the ball –two men hit the ball show your grammar and example runs

13 13 Exercise 1 Modify the grammar given to handle: –every man hit the ball –*every men hit the ball Idea: –every is compatible with singular count nouns –but not with plural count nouns –(also see Exercise 2) –so it’s like the determiner “a”

14 14 Exercise 1 Rule for determiner “a” is: det(det(a),sg) --> [a]. Rule for quantifier “every” can be: det(det(every),sg) --> [every]. Note: –for coding convenience, let’s call them both determiners here –but semantically: every and a are both quantifiers Test: –Every man hit the ball –*Every men hit the ball

15 15 Exercise 1 Alternatively, we could write: it’s up to you (as a grammar writer) whether you want to make a distinction between quantifiers and determiners “a” and “the” in the grammar np(np(Q,N)) --> quantifier(Q,Number), common_noun(N,Number). quantifier(q(every),sg) --> [every]. Output: np(q(every),n(man))

16 16 Exercise 1 Let’s add some other determiners/quantifiers (12pts) Modify the grammar given to handle: –every man hit the ball –*every men hit the ball –*most man hit the ball –most men hit the ball –some man hit the ball –some men hit the ball –* (a) few man hit the ball –(a) few men hit the ball –no man hit the ball –no men hit the ball –one man hit the ball –*one men hit the ball –*two man hit the ball –two men hit the ball show your grammar and example runs

17 17 Exercise 2 Consider the mass term “sand” I hit some sand I hit sand I hit the sand *I hit a sand *I hit one sand *I hit two sands (10pts) Modify your grammar to handle these cases –plus the other quantifiers mentioned in Exercise 1: every, most, (a) few, no show your grammar and example runs

18 18 Exercise 2 To get you started... add the rule: common_noun(n(sand),mass) --> [sand]. to your grammar first. What works with the grammar supplied? I hit the sand

19 19 Exercise 2 To get you started... add the rule: common_noun(n(sand),mass) --> [sand]. to your grammar first. How about? I hit sand *I hit ball cf. I hit the ball Hint: –I need a rule for a bare noun

20 20 Summary Question 1: 12 pts Question 2: 10 pts Total: 22 pts


Download ppt "LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19."

Similar presentations


Ads by Google