LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/2.

Slides:



Advertisements
Similar presentations
Formal Languages: main findings so far
Advertisements

Formal Languages: main findings so far A problem can be formalised as a formal language A formal language can be defined in various ways, e.g.: the language.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 13: 10/9.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.
Chapter Section Section Summary Set of Strings Finite-State Automata Language Recognition by Finite-State Machines Designing Finite-State.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/19.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/4.
LING 388: Language and Computers Sandiway Fong Lecture 12: 10/5.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 4 9/11/03 Sandiway FONG.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/3.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/23.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.
1 Foundations of Software Design Lecture 23: Finite Automata and Context-Free Grammars Marti Hearst Fall 2002.
LING 388: Language and Computers Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 14: 10/12.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
CPSC 388 – Compiler Design and Construction
CPSC 388 – Compiler Design and Construction Scanners – Finite State Automata.
Chapter 2. Regular Expressions and Automata From: Chapter 2 of An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition,
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 12 10/4 Sandiway Fong.
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
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.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 5 graded.
LING/C SC/PSYC 438/538 Lecture 16 Sandiway Fong. SWI Prolog Grammar rules are translated when the program is loaded into Prolog rules. Solves the mystery.
1.2 Three Basic Concepts Languages start variables Grammars Let us see a grammar for English. Typically, we are told “a sentence can Consist.
using Deterministic Finite Automata & Nondeterministic Finite Automata
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
LECTURE 5 Scanning. SYNTAX ANALYSIS We know from our previous lectures that the process of verifying the syntax of the program is performed in two stages:
Deterministic Finite Automata Nondeterministic Finite Automata.
Introduction to Automata Theory Theory of Computation Lecture 5 Tasneem Ghnaimat.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
Pushdown Automata PDAs
Pushdown Automata PDAs
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
Finite Automata.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Chapter 1 Regular Language
Teori Bahasa dan Automata Lecture 6: Regular Expression
Non Deterministic Automata
Presentation transcript:

LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/2

Last Time FSA –gave a formal definition (Q,s,f,Σ,  ) –background reading Chapter 2: Regular Expressions and Finite State Automata –many practical applications can be encoded and run efficiently on a computer implement regular expressions compress large dictionaries build morphological analyzers (suffixation) –see chapter 3 of textbook speech recognizers –(Hidden) Markov models = FSA + probabilities

FSA: Recap formally –(Q,s,f,Σ,  ) 1.set of states (Q): {s,w,x,y,z} 4 statesmust be a finite set 2.start state (s): s 3.end state(s) (f): z 4.alphabet ( Σ ): {a, b, !} 5.transition function  : signature: character × state → state  (b,s)=w  (a,w)=x  (a,x)=y  (a,y)=y  (!,y)=z sw b x a a > y a z ! xy a λ λ (or ε ) denotes the empty transition

regexps and FSA: recap anything we can encode with a regular expression, we can build a FSA for it basic operators, e.g. –+–+ one or more of the preceding character e.g. a+ backreferences: –by state splitting –e.g. ([aeiou])\1 xy o a e i u yz o a e i u x yuyu o a e i u z yaya yeye yiyi yoyo o a e u xy a a

Today’s Lecture how to implement FSA –in Prolog –two ways: one based directly on the formal definition...

Finite State Automata (FSA) formally –(Q,s,f,Σ,  ) 1.Q: {s,x,y} 2.s: s 3.f: y 4.Σ : {a, b} 5.transition function  : signature: character × state → state  (a,s)=x  (a,x)=x  (b,x)=y  (b,y)=y sx y a a b b >

Finite State Automata (FSA) directly implement the formal definition –define a predicate fsa/2 –takes two arguments –S = a start state –L = string (as a list) we’re interested in testing Prolog code (for any FSA) 1.fsa(S,L) :- L = [C|M], transition(S,C,T), fsa(T,M). 2.fsa(E,[]):- end_state(E). :- to be read as “true if”

Finite State Automata (FSA) Prolog code (for any FSA) –fsa(S,L) :- L = [C|M], transition(S,C,T), fsa(T,M). –fsa(E,[]):- end_state(E). Facts (FSA-particular) –end_state(y). –transition(s,a,x). –transition(x,a,x). –transition(x,b,y). –transition(y,b,y). sx y a a b b transition function  :  (a,s)=x  (a,x)=x  (b,x)=y  (b,y)=y >

Finite State Automata (FSA) –computation tree ?- fsa(s,[a,a,b]). ?- transition(s,a,T). T=x ?- fsa(x,[a,b]). ?- transition(x,a,T’). T’=x ?- fsa(x,[b]). ?- transition(x,b,T”). T”=y ?- fsa(y,[]). ?- end_state(y). Yes fsa(S,L) :- L = [C|M], L = [C|M],transition(S,C,T),fsa(T,M). fsa(y,[]) :-. fsa(y,[]) :- end_state(E).

Finite State Automata (FSA) deterministic FSA (DFSA) –no ambiguity about where to go at any given state non-deterministic FSA (NDFSA) –no restriction on ambiguity (surprisingly, no increase in formal power) textbook –D-RECOGNIZE (FIGURE 2.13) –ND-RECOGNIZE (FIGURE 2.21) fsa(S,L) :- L = [C|M], L = [C|M],transition(S,C,T),fsa(T,M). fsa(y,[]) :-. fsa(y,[]) :- end_state(E).

Finite State Automata (FSA) Prolog Advantages –no change in code for NDFSA –Prolog computation rule takes care of choice point management example –one change –“a” instead of “b” from x to y –non-deterministic –what regular language does this machine accept? sx y a a b a

Finite State Automata (FSA) another possible Prolog encoding strategy –define one predicate for each state taking one argument (the input string) consume input character call next state with remaining input string –query ?- s(L). call start state s

Finite State Automata (FSA) –state s: (start state) s([a|L]) :- x(L). match input string beginning with a and call state x with remainder of input –state x: x([a|L]) :- x(L). x([b|L]) :- y(L). –state y: (end state) y([]). y([b|L]) :- y(L). sx y a a b b

Finite State Automata (FSA) example: 1.?- s([a,a,b]). 2.?- x([a,b]). 3.?- x([b]). 4.?- y([]). Yes s([a|L]) :- x(L). x([a|L]) :- x(L). x([b|L]) :- y(L). y([]). y([b|L]) :- y(L).

Finite State Automata (FSA) Note: –non-deterministic properties of Prolog’s computation rule still applies here

Finite State Automata (FSA) example 1.?- s([a,b,a]). 2.?- x([b,a]). 3.?- y([a]). No s([a|L]) :- x(L). x([a|L]) :- x(L). x([b|L]) :- y(L). y([]). y([b|L]) :- y(L).

Class Project Implement the following FSA in Prolog –using the one predicate per state model sxy a a b λ > make sure your program can generate