Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.

Similar presentations


Presentation on theme: "LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong."— Presentation transcript:

1 LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong

2 Administrivia Reminder – Next Monday, Nirav Merchant from Bio5 will give a guest lecture – a break from the usual JM material – Also next Monday, the corpus reformatting homework is due

3 Today’s Topic Section 2.2 of JM – Finite State Automata

4 Regular Languages Three formalisms – All formally equivalent (no difference in expressive power) – i.e. if you can encode it using a RE, you can do it using a FSA or regular grammar, and so on … Regular Grammars FSA Regular Expressions Regular Languages talk about formal equivalence next time

5 Regular Languages A regular language is the set of strings (including possibly the empty string) (set itself could also be empty) (set can be infinite) generated by a RE/FSA/Regular Grammar

6 Regular Languages Example: – Language: L = { a + b + } “one or more a’s followed by one or more b’s” L is a regular language – described by a regular expression Note: – infinite set of strings belonging to language L » e.g. abbb, aaaab, aabb, *abab, * Notation: – is the empty string (or string with zero length), sometimes ε is used instead – * means string is not in the language

7 Finite State Automata (FSA) L = { a + b + } can be also be generated by the following FSA sx y a a b b >  > Indicates start state  Red circle indicates end (accepting) state  we accept a input string only when we’re in an end state and we’re at the end of the string

8 Finite State Automata (FSA) L = { a + b + } can be also be generated by the following FSA sx y a a b b > There is a natural correspondence between L components of the FSA and L Note : L = {a + b + } L = {aa * bb * }

9 Finite State Automata (FSA) L = { a + b + } can be also be generated by the following FSA sx y a a b b > deterministic FSA (DFSA) no ambiguity about where to go at any given state i.e. for each input symbol in the alphabet at any given state, there is a unique “action” to take non-deterministic FSA (NDFSA) no restriction on ambiguity (surprisingly, no increase in power)

10 Finite State Automata (FSA) more formally – (Q,s,f,Σ,  ) 1.set of states (Q): {s,x,y}must be a finite set 2.start state (s): s 3.end state(s) (f): y 4.alphabet ( Σ ): {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 >

11 Finite State Automata (FSA) In Perl transition function  :  (a,s)=x  (a,x)=x  (b,x)=y  (b,y)=y sx y a a b b We can simulate our 2D transition table using a hash whose elements are themselves hashes %transitiontable = ( s => { a => "x" }, x => { a => "x", b => "y" }, y => { b => "y" } ); Example: print "$transitiontable{s}{a}\n"; > Syntactic sugar %transitiontable = ( "s", { "a", "x", }, "x", { "a", "x", "b", "y" }, "y", { "b", "y" }, ); Syntactic sugar %transitiontable = ( "s", { "a", "x", }, "x", { "a", "x", "b", "y" }, "y", { "b", "y" }, );

12 Finite State Automata (FSA) Given transition table encoded as a hash How to build a decider (Accept/Reject) in Perl? Complications: How about ε-transitions? Multiple end states? Multiple start states? Non-deterministic FSA? Complications: How about ε-transitions? Multiple end states? Multiple start states? Non-deterministic FSA?

13 Finite State Automata (FSA) %transitiontable = ( s => { a => "x" }, x => { a => "x", b => "y" }, y => { b => "y" } ); @input = @ARGV; $state = "s"; foreach $c (@input) { $state = $transitiontable{$state}{$c}; } if ($state eq "y") { print "Accept\n"; } else { print "Reject\n"; } Example runs: perl fsm.prl a b a b Reject perl fsm.prl a a a b b Accept

14 Finite State Automata (FSA)

15 practical applications can be encoded and run efficiently on a computer widely used –encode regular expressions –compress large dictionaries –morphological analyzers Different word forms, e.g. want, wanted, unwanted (suffixation/prefixation) see chapter 3 of textbook speech recognizers Markov models = FSA + probabilities and much more …

16 Finite State Automata (FSA) how: 3 vs. 6 keystrokes michael: 7 vs. 15 keystrokes – T9 text entry (tegic.com) built in to your cellphone predictive text entry for mobile messaging/data entry reduces the number of keystrokes for inputting words on a telephone keypad (8 keys)

17 17 ε-transitions jump from state to another state with the empty character – ε-transition (textbook) or λ-transition – no increase in expressive power examples a ε b > a b b > a ε b > what’s the equivalent without the ε-transition?

18 Non-Deterministic Finite State Automata (NDFSA) non-deterministic FSA (NDFSA) no restriction on ambiguity (surprisingly, no increase in power) Example: sx z a a a b y b b a b >

19 Non-Deterministic Finite State Automata (NDFSA) Strategies for keeping track of multiple states Backtracking (backup) Lookahead Parallelism algorithm gets complicated fast

20 20 NDFSA → (D)FSA [ discussed at the end of section 2.2 in the textbook] construct a new machine – each state of the new machine represents the set of possible states of the original machine when stepping through the input Note: – new machine is equivalent to old one (but has more states) – new machine is deterministic example sx z a a a b y b b a b s{x,y} {z} a a a {y,z} b a {y} b a b b > > [Powerpoint Animation]

21 Ungraded Homework Do not submit, but please do the following exercise to check your understanding of the material – Apply the set-of-states construction technique to the two machines on the ε- transition slide – Check your answer: verify in each case that the machine produced is deterministic and accurately simulates its ε- transition counterpart


Download ppt "LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong."

Similar presentations


Ads by Google