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

Slides:



Advertisements
Similar presentations
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 13: 10/9.
Advertisements

Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
LING 388: Language and Computers Sandiway Fong Lecture 15.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/18.
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
Languages, grammars, and regular expressions
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
1 Foundations of Software Design Lecture 23: Finite Automata and Context-Free Grammars Marti Hearst Fall 2002.
LING 388 Language and Computers Lecture 11 10/7/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
LING 388: Language and Computers Sandiway Fong Lecture 22: 11/10.
LING 388: Language and Computers Sandiway Fong Lecture 7.
CSI 3120, Grammars, page 1 Language description methods Major topics in this part of the course: –Syntax and semantics –Grammars –Axiomatic semantics (next.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
LING 388: Language and Computers Sandiway Fong Lecture 30 12/8.
Some Probability Theory and Computational models A short overview.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
Lecture # 9 Chap 4: Ambiguous Grammar. 2 Chomsky Hierarchy: Language Classification A grammar G is said to be – Regular if it is right linear where each.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/15.
CS 461 – Sept. 19 Last word on finite automata… –Scanning tokens in a compiler –How do we implement a “state” ? Chapter 2 introduces the 2 nd model of.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
Context-free grammars. Roadmap Last time – Regex == DFA – JLex for generating Lexers This time – CFGs, the underlying abstraction for Parsers.
9.7: Chomsky Hierarchy.
Natural Language Processing Lecture 4 : Regular Expressions and Automata.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
CST229 Week 8 Questions or concerns? Hand back Homework #6 & #5 Reading: Chapter 14 Comment about Lab1 Getting started with Lab2 Chapter 14 – Regular Grammar.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
1 Course Overview Why this course “formal languages and automata theory?” What do computers really do? What are the practical benefits/application of formal.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
Lecture 6: Context-Free Languages
Formal grammars A formal grammar is a system for defining the syntax of a language by specifying sequences of symbols or sentences that are considered.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong. Last Time Talked about: – 1. Declarative (logical) reading of grammar rules – 2. Prolog query: s(String,[]).
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Course 2 Introduction to Formal Languages and Automata Theory (part 2)
CSE322 The Chomsky Hierarchy
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong.
Chapter 2 Context-Free Language - 01
The Chomsky Hierarchy Costas Busch - LSU.
Presentation transcript:

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 –use plain text if possible (easier for the grader) Homework #1 –everyone should have gotten

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

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

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 …

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 sbac X:X y:i  :e  :s

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([]). sbac X:X y:i  :e  :s 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([],[]).

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] sbac X:X y:i  :e  :s 1.s([X|L],[X|M]) :- s(L,M). 2.s([y|L],[i|M]) :- a(L,M). 3.a(L,[e|M]) :- b(L,M). 4.b(L,[s|M]) :- c(L,M). 5.c([],[]). redo

Finite State Transducers (FST) sbac X:X y:i  :e  :s In Prolog: (FST simplified) –s([X|L],[X|M]) :- s(L,M). –s([y|L],[i,e,s|M]) :- c(L,M). –c([],[]). sc X:X y:ies 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([],[]).

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 sbac X:X y:i  :e  :s

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 sbac X:X y:i  :e  :s sbac X:X y:i  :e  :s z C:C boy  boies, key  keies say  saies

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 sc X:X y:ies z C:C 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([],[]). consonant(b). consonant(c). consonant(d). consonant(f). … consonant(z).

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 a n b n a --> [a], b. b --> [b]. b --> a, [b].

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].

Context-Free Grammars Where do CFGs fit in? Chomsky Hierarchy: –Type-0 General rewrite rules Type-1 Context-sensitive rules a n b n c n –Type-2 Context-free rules – a n b n Pushdown Automata (PDA) »Type-3 Regular grammar rules » Regular Expressions a + b + » Finite State Automata (FSA)

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

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 …