17
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

  • View
    221

  • Download
    2

Embed Size (px)

Citation preview

Page 1: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

LING/C SC/PSYC 438/538Computational Linguistics

Sandiway Fong

Lecture 16: 10/23

Page 2: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Midterm

• graded and returned

• +1 scaling applied

– Final will be on material covered after midterm only

– There will be one or two graded homeworks as well to come

Page 3: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Question 6

[Correction to lecture 15 slides] • Give the deterministic FSA corresponding to:

Page 4: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Answer 6

• [Correction to lecture 15 slides] • Deterministic machine

1

5

2a

3c 4

c

a

b b

c

6a

Page 5: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Recap

• Following Chapter 3 of the textbook

Page 6: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 1: Lexical Intermediate Levels

• Figure 3.17 (top half):tape view of input/output pairs

Page 7: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

The Mapping Problem

• Example: (3.11)

• (Context-Sensitive) Spelling Rule: (3.5) e / {x,s,z}^__ s#

rewrites to letter e in left context x^ or s^ or z^ and right context s#

• i.e. insert e after the ^ when you see x^s# or s^s# or z^s#

• in particular, we have x^s# x^es#

Page 8: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 2: Intermediate Surface Levels

• also can be implemented using a FSTimportant!machine is designed to pass input not matching the rule through unmodified (rather than fail)

implements context-sensitive ruleq0 to q2 : left contextq3 to q0 : right context

Page 9: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 2: Intermediate Surface Levels

• Example (3.17)

Page 10: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 2: Intermediate Surface Levels

• Transition table for FST in 3.14

pg.79

Page 11: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 2: Intermediate Surface Levels

• Class Exercise– Let’s build this

FST in Prolog together

– state by state

Page 12: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

Stage 2: Intermediate Surface Levels

• A Note on Prolog– it will be useful to employ the cut

predicate for the implementation of “other”

• ! is known as the “cut” predicate– it affects how Prolog backtracks for

another solution– it means “cut” the backtracking off– Prolog will not try any other possible

matching rule on backtracking

Page 13: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

FST 3.14 in Prolog

• % To run: ?- q0([f,o,x,^,s,#],L). L = [f,o,x,e,s,#]

• % q0• q0([],[]). % final state case• q0([z|L1],[z|L2]) :- !, q1(L1,L2). % q0 - z -> q1• q0([s|L1],[s|L2]) :- !, q1(L1,L2). % q0 - s -> q1• q0([x|L1],[x|L2]) :- !, q1(L1,L2). % q0 - x -> q1• q0([#|L1],[#|L2]) :- !, q0(L1,L2). % q0 - # -> q0• q0([^|L1],L2) :- !, q0(L1,L2). % q0 - ^:ep -> q0• q0([X|L1],[X|L2]) :- q0(L1,L2). % q0 - other -> q0

Page 14: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

FST 3.14 in Prolog

• % q1• q1([],[]). % final state case• q1([z|L1],[z|L2]) :- !, q1(L1,L2). % q1 - z -> q1• q1([s|L1],[s|L2]) :- !, q1(L1,L2). % q1 - s -> q1• q1([x|L1],[x|L2]) :- !, q1(L1,L2). % q1 - x -> q1• q1([^|L1],L2) :- !, q2(L1,L2). % q1 - ^:ep -> q2• q1([#|L1],[#|L2]) :- !, q0(L1,L2). % q1 - # -> q0• q1([X|L1],[X|L2]) :- q0(L1,L2). % q1 - other -> q0

Page 15: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

FST 3.14 in Prolog

• % q2• q2([],[]). % final state case• q2(L1,[e|L2]) :- q3(L1,L2). % q2 - ep:e -> q3• q2([s|L1],[s|L2]) :- !, q5(L1,L2). % q2 - s -> q5• q2([z|L1],[z|L2]) :- !, q1(L1,L2). % q2 - z -> q1• q2([x|L1],[x|L2]) :- !, q1(L1,L2). % q2 - x -> q1• q2([#|L1],[#|L2]) :- !, q0(L1,L2). % q2 - # -> q0• q2([X|L1],[X|L2]) :- \+ X = ^, q0(L1,L2). % q2 - other -

> q0

Page 16: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

FST 3.14 in Prolog

• % q3• q3([s|L1],[s|L2]) :- q4(L1,L2). % q3 - s -> q4

• % q4• q4([#|L1],[#|L2]) :- q0(L1,L2). % q4 - # -> q0

Page 17: LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23

FST 3.14 in Prolog

• % q5• q5([z|L1],[z|L2]) :- !, q1(L1,L2). % q5 - z -> q1• q5([s|L1],[s|L2]) :- !, q1(L1,L2). % q5 - s -> q1• q5([x|L1],[x|L2]) :- !, q1(L1,L2). % q5 - x -> q1• q5([^|L1],L2) :- !, q2(L1,L2). % q5 - ^:e -> q2• q5([X|L1],[X|L2]) :- \+ X = #, q0(L1,L2). % q5 -

other -> q0