1 / 17

LING 388: Language and Computers

LING 388: Language and Computers. Sandiway Fong Lecture 9: 9/22. Administrivia. Reminder LING 388 Homework #2 went out on Monday is due next Monday September 27th (by midnight) need help? submit homework to sandiway@email.arizona.edu use plain text if possible (easier for the grader)

Download Presentation

LING 388: Language and Computers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LING 388: Language and Computers Sandiway Fong Lecture 9: 9/22

  2. Administrivia • Reminder • LING 388 Homework #2 went out on Monday • is due next Monday September 27th (by midnight) • need help? • submit homework to sandiway@email.arizona.edu • use plain text if possible (easier for the grader) • Homework #1 • everyone should have gotten email

  3. Last Time • Exercises on • FSA • Regular Grammars • including fragments of natural language • the man that I saw that you heard that I met …

  4. Today’s Topics • more on natural language cases … • Finite State Transducers (FST) • Context-Free Grammars (CFG)

  5. Finite State Transducers (FST) • a Finite State Transducer (FST) • is just a finite state machine, like FSA, but • is not only an acceptor • can also produce an output sequence as well as accepting input sequences • Application: • We can use FST to map from one word form into another • e.g. a rule of pluralization • technology  technologies • Also easy to implement in Prolog …

  6. s a b c y:i :e :s X:X Finite State Transducers (FST) • Example: (pluralization) • convert word ending in –y to word ending in –ies • technology  technologies, boundary  boundaries • spy  spies, fly  flies, study  studies • *happy  happies, *correctly  correctlies • Notes: • : = separator between input and output characters • is the empty character • variable X can match any character • Machine is non-deterministic

  7. s a b c y:i :e :s X:X Finite State Transducers (FST) • In Prolog: (FSA) • s([X|L]) :- s(L). • s([y|L]) :- a(L). • a(L) :- b(L). • b(L) :- c(L). • c([]). • In Prolog: (FST) • s([X|L],[X|M]) :- s(L,M). • s([y|L],[i|M]) :- a(L,M). • a(L,[e|M]) :- b(L,M). • b(L,[s|M]) :- c(L,M). • c([],[]).

  8. s a b c y:i :e :s X:X Finite State Transducers (FST) • Computation tree • ?- s([s,p,y],O). X=s L=[p,y] O=[X|M] • ?- s([p,y],M). X’=p L’=[y] M=[X’|M’] • ?- s([y],M’). X”=y L”=[] M’=[X”|M”] • ?-s([],M”).No • ?- s([y],M’). L”=[] M’=[i|M”] • ?- a([],M”). L”’=[] M”=[e|M”’] • ?- b([],M”). L””=[] M”’=[s|M””] • ?- c([],M””). Yes M””=[] • Answer • O = [s|[p|[i|[e|[s|[]]]]]] • O = [s,p,i,e,s] • s([X|L],[X|M]) :- s(L,M). • s([y|L],[i|M]) :- a(L,M). • a(L,[e|M]) :- b(L,M). • b(L,[s|M]) :- c(L,M). • c([],[]). redo

  9. s a b c y:i :e :s X:X s c y:ies X:X Finite State Transducers (FST) • In Prolog: (FST) • s([X|L],[X|M]) :- s(L,M). • s([y|L],[i|M]) :- a(L,M). • a(L,[e|M]) :- b(L,M). • b(L,[s|M]) :- c(L,M). • c([],[]). • In Prolog: (FST simplified) • s([X|L],[X|M]) :- s(L,M). • s([y|L],[i,e,s|M]) :- c(L,M). • c([],[]).

  10. s a b c y:i :e :s X:X Finite State Transducers (FST) • Example: (pluralization) • convert word ending in –y to word ending in –ies • technology  technologies, boundary  boundaries • spy  spies, fly  flies, study  studies • *happy  happies, *correctly  correctlies • Counterexamples to the rule: • boy  boies, key  keies • say  saies • Revised Rule: • convert word ending in –y to word ending in –ies in context C__ where C is a consonant

  11. s a b c y:i :e :s s z a b c y:i :e :s C:C X:X X:X Finite State Transducers (FST) • Revised Rule: • convert word ending in –y to word ending in –ies in context C__ where C is a consonant character • boy  boies, key  keies • say  saies

  12. s z c y:ies C:C X:X Finite State Transducers (FST) • Revised Rule: • convert word ending in –y to word ending in –ies in context C__ where C is a consonant character consonant(b). consonant(c). consonant(d). consonant(f). … consonant(z). • In Prolog: (simplified FST) • s([X|L],[X|M]) :- s(L,M). • s([y|L],[i,e,s|M]) :- c(L,M). • c([],[]). • In Prolog: (revised rule, simplified FST) • s([X|L],[X|M]) :- s(L,M). • s([C|L],[C|M]) :- consonant(C), z(L,M). • z([y|L],[i,e,s|M]) :- c(L,M). • c([],[]).

  13. Context-Free Grammars • Regular Grammars • Definite Clause Grammar (DCG) rules that obey special restrictions: • x --> y, [t]. x --> [t]. (left recursive) • x --> [t],y. x --> [t]. (right recursive) • Context-Free Grammars (CFG) • have no restrictions on the number of symbols on the RHS • x --> RHS. • you can mix many terminal and non-terminal symbols as you want • Example of a Context-Free Grammar • non-regular grammar for language anbn • a --> [a], b. • b --> [b]. • b --> a, [b].

  14. Context-Free Grammars • Regular Grammars • Definite Clause Grammar (DCG) rules that obey special restrictions: • x --> y, [t]. x --> [t]. (left recursive) • x --> [t],y. x --> [t]. (right recursive) • Context-Free Grammars (CFG) • have no restrictions on the number of symbols on the RHS • x --> RHS. • you can mix many terminal and non-terminal symbols as you want • Another example of a Context-Free Grammar • Sheeptalk ( baa! baaa! baaaa! …) - is a regular language • s --> [b], [a], a, [‘!’]. • a --> [a]. • a --> a, [a].

  15. Context-Free Grammars • Where do CFGs fit in? • Chomsky Hierarchy: • Type-0 General rewrite rules • Type-1 Context-sensitive rules • anbncn • Type-2 Context-free rules • anbn Pushdown Automata (PDA) • Type-3 Regular grammar rules • Regular Expressionsa+b+ • Finite State Automata (FSA)

  16. FSA Regular Expressions Regular Grammars Context-Free Grammars Type-1 Type-3 Type-2 DCG = Type-0

  17. Context-Free Grammars • In Homework #2, we explored some natural language fragments using regular grammars • the man that I saw (that you heard that I met …) • (object relative clauses) • But regular grammars are quite limited • the man likes dogs • the man that the cat saw likes dogs • ?the man that the cat that the mouse hates saw likes dogs • (center-embedding) • CFGs are not only more powerful but are also more useful for writing natural language grammars • Continued next time …

More Related