SlideShare una empresa de Scribd logo
1 de 19
Finite-State Automata
K.A.S.H. Kulathilake
B.Sc.(Sp.Hons.)IT, MCS, Mphil, SEDA(UK)
Introduction
• The regular expression is more than just a
convenient meta-language for text searching.
• Symmetrically, any finite-state automaton can be
described with a regular expression.
• Second, a regular expression is one way of
characterizing a particular kind of formal
language called a regular language.
• Both regular expressions and finite-state
automata can be used to described regular
languages.
Introduction (Cont…)
• we defined the sheep language as any string
from the following (infinite) set:
/baa+!/
Introduction (Cont…)
• We represent the automaton as a directed graph: a finite set of
vertices (also called nodes), together with a set of directed links
between pairs of vertices called arcs.
• We’ll represent vertices with circles and arcs with arrows.
• The automaton has five states, which are represented by nodes in
the graph.
• State 0 is the start state which we represent by the incoming arrow.
• State 4 is the final state or accepting state, which we represent by
the double circle.
• It also has four transitions, which we represent by arcs in the graph.
Introduction (Cont…)
• The FSA can be used for recognizing (we also say accepting) strings
in the following way.
• The machine starts in the start state (q0), and iterates the following
process:
– Check the next letter of the input.
– If it matches the symbol on an arc leaving the current state, then cross
that arc, move to the next state, and also advance one symbol in the
input. I
– If we are in the accepting state (q4) when we run out of input, the
machine has successfully recognized an instance of sheeptalk.
• If the machine never gets to the final state, either because
– it runs out of input, or
– it gets some input that doesn’t match an arc, or
– if it just happens to get stuck in some non-final state, we say the
machine rejects or fails to accept an input.
Introduction (Cont…)
• We can also represent an automaton with a state-
transition table.
• We’ve marked state 4 with a colon to indicate that it’s a
final state (you can have as many final states as you want),
and the /0 indicates an illegal or missing transition.
Introduction (Cont…)
• More formally, a finite automaton is defined by
the following 5 parameters:
– Q: a finite set of N states q0,q1,….,qN
– Σ: a finite input alphabet of symbols
– q0: the start state
– F: the set of final states, F subset of Q
– d(q,i): The transition function or transition matrix
between states.
– Given a state qϵQ and an input symbol iϵΣ, δ(q,i)
returns a new state q’ϵQ.
– δ is thus a relation from Q ×Σ to Q;
Introduction (Cont…)
• E.g.
Q={q0 ,q1, q2, q3, q4 }
Σ = {a, b, !}
F = q4
δ(q,i) is defined by the transition table
Fail State
• The state machine will fail whenever there is no legal
transition for a given combination of state and input.
• The input abc will fail to be recognized since there is no
legal transition out of state q0 on the input a.
• Even if the automaton had allowed an initial a it would
have certainly failed on c, since c isn’t even in the
alphabet!
• We can think of these ‘empty’ elements in the table as
if they all pointed at one ‘empty’ state, which we might
call the fail state or sink state.
Fail State (Cont…)
• In a sense then, we could view any machine with
empty transitions as if we had augmented it with
a fail state, and drawn in all the extra arcs, so we
always had somewhere to go from any state on
any possible input.
• Just for completeness, the following is the
previous FSA with the fail state qF.
Formal Languages
• Let’s say for now that we don’t care how the machine makes this
decision; maybe it flips a coin.
• For now, we don’t care which exact string of above example we
generate, as long as it’s a string captured by the regular expression
for discussed previously.
• A formal language is a set of strings, each string composed of
symbols from a finite symbol-set called an alphabet (the same
alphabet used above for defining an automaton!).
• The alphabet for the above example is the set Σ ={a, b, !}.
• Given a model m (such as a particular FSA), we can use L(m) to
mean “the formal language characterized by m”.
• So the formal language defined by previous automaton m in is the
infinite set: L(m)={baa!, baaa!, baaaa!, baaaaa!, baaaaaa!,…..}
Formal Languages (Cont…)
• The usefulness of an automaton for defining a language is that it
can express an infinite set (such as this one above) in a closed form.
• Formal languages are not the same as natural languages, which are
the kind of languages that real people speak.
• In fact a formal language may bear no resemblance at all to a real
language.
• But we often use a formal language to model part of a natural
language, such as parts of the phonology, morphology, or syntax.
• The term generative grammar is sometimes used in linguistics to
mean a grammar of a formal language; the origin of the term is this
use of an automaton to define a language by generating all possible
strings.
FSA with Word Combination
• Suppose we wanted to build an FSA that modeled the
subpart of English dealing with amounts of money.
• Such a formal language would model the subset of
English consisting of phrases like ten cents, three
dollars, one dollar thirty-five cents and so on.
FSA with Word Combination (Cont…)
• We could now add cents and dollars to our
automaton.
Nondeterministic FSAs
• When we get to state 2, if we see an a we don’t know whether to
remain in state 2 or go on to state 3.
• Automata with decision points like this are called Non-deterministic
FSAs (or NFSAs).
• Recall by contrast that previous example specified a deterministic
automaton, i.e. one whose behavior during recognition is fully
determined by the state it is in and the symbol it is looking at.
• A deterministic automaton can be referred to as a DFSA.
Nondeterministic FSAs (Cont…)
• There is another common type of non-
determinism, which can be caused by arcs that
have no symbols on them (called ε-transitions).
• The automaton ε in following diagram defines the
exact same language as the last one, or our first
one, but it does it with an ε-transition.
Nondeterministic FSAs (Cont…)
• We interpret this new arc as follows:
• If we are in state 3, we are allowed to move to state 2
without looking at the input, or advancing our input
pointer.
• So this introduces another kind of non-determinism –
we might not know whether to follow the ε transition
or the ! arc.
Using an NFSA to Accept Strings
• If we want to know whether a string is an
instance of a particular corpus or not, and if we
use a non-deterministic machine to recognize it,
we might follow the wrong arc and reject it when
we should have accepted it.
• That is, since there is more than one choice at
some point, we might take the wrong choice.
• This problem of choice in non-deterministic
models will come up again and again as we build
computational models, particularly for parsing.
Using an NFSA to Accept Strings
(Cont…)
• There are three standard solutions to this
problem:
– Backup:
• Whenever we come to a choice point, we could put a marker
to mark where we were in the input, and what state the
automaton was in. Then if it turns out that we took the
wrong choice, we could back up and try another path.
– Look-ahead:
• We could look ahead in the input to help us decide which
path to take.
– Parallelism:
• Whenever we come to a choice point, we could look at every
alternative path in parallel.

Más contenido relacionado

La actualidad más candente

Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of LanguageDipankar Boruah
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture NotesFellowBuddy.com
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler designRiazul Islam
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of ComputationAnkur Singh
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lexAnusuya123
 
1.2. introduction to automata theory
1.2. introduction to automata theory1.2. introduction to automata theory
1.2. introduction to automata theorySampath Kumar S
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
NLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelNLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelHemantha Kulathilake
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: ParsingRushdi Shams
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler DesignKuppusamy P
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOCAbhayDhupar
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generatorsanchi29
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 

La actualidad más candente (20)

Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Language models
Language modelsLanguage models
Language models
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
NLP_KASHK:Regular Expressions
NLP_KASHK:Regular Expressions NLP_KASHK:Regular Expressions
NLP_KASHK:Regular Expressions
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of Computation
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lex
 
1.2. introduction to automata theory
1.2. introduction to automata theory1.2. introduction to automata theory
1.2. introduction to automata theory
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
NLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelNLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language Model
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
NLP_KASHK:Text Normalization
NLP_KASHK:Text NormalizationNLP_KASHK:Text Normalization
NLP_KASHK:Text Normalization
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
 

Similar a NLP_KASHK:Finite-State Automata

Natural Language Processing Topics for Engineering students
Natural Language Processing Topics for Engineering studentsNatural Language Processing Topics for Engineering students
Natural Language Processing Topics for Engineering studentsRosnaPHaroon
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computationprasadmvreddy
 
a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...NALESVPMEngg
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingHemantha Kulathilake
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxssuser039bf6
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptxThirumoorthy64
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyserArchana Gopinath
 
MidtermI-review.pptx
MidtermI-review.pptxMidtermI-review.pptx
MidtermI-review.pptxamara jyothi
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languagesSOMNATHMORE2
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languagesSOMNATHMORE2
 
Regular expression automata
Regular expression automataRegular expression automata
Regular expression automata성욱 유
 
Patterns, Automata and Regular Expressions
Patterns, Automata and Regular ExpressionsPatterns, Automata and Regular Expressions
Patterns, Automata and Regular ExpressionsDarío Garigliotti
 
INFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptINFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptLamhotNaibaho3
 
Theory of computing presentation
Theory of computing presentationTheory of computing presentation
Theory of computing presentationMd. Touhidur Rahman
 

Similar a NLP_KASHK:Finite-State Automata (20)

Natural Language Processing Topics for Engineering students
Natural Language Processing Topics for Engineering studentsNatural Language Processing Topics for Engineering students
Natural Language Processing Topics for Engineering students
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...
 
Finite automata
Finite automataFinite automata
Finite automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
The Theory of Finite Automata.pptx
The Theory of Finite Automata.pptxThe Theory of Finite Automata.pptx
The Theory of Finite Automata.pptx
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
Lexical1
Lexical1Lexical1
Lexical1
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyser
 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
MidtermI-review.pptx
MidtermI-review.pptxMidtermI-review.pptx
MidtermI-review.pptx
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Regular expression automata
Regular expression automataRegular expression automata
Regular expression automata
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Patterns, Automata and Regular Expressions
Patterns, Automata and Regular ExpressionsPatterns, Automata and Regular Expressions
Patterns, Automata and Regular Expressions
 
INFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptINFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.ppt
 
Theory of computing presentation
Theory of computing presentationTheory of computing presentation
Theory of computing presentation
 

Más de Hemantha Kulathilake

NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar Hemantha Kulathilake
 
NLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for EnglishNLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for EnglishHemantha Kulathilake
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation Hemantha Kulathilake
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops Hemantha Kulathilake
 
COM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & BranchingCOM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & BranchingHemantha Kulathilake
 
COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants Hemantha Kulathilake
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types Hemantha Kulathilake
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming Hemantha Kulathilake
 

Más de Hemantha Kulathilake (20)

NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar
 
NLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for EnglishNLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for English
 
NLP_KASHK:POS Tagging
NLP_KASHK:POS TaggingNLP_KASHK:POS Tagging
NLP_KASHK:POS Tagging
 
NLP_KASHK:Markov Models
NLP_KASHK:Markov ModelsNLP_KASHK:Markov Models
NLP_KASHK:Markov Models
 
NLP_KASHK:Smoothing N-gram Models
NLP_KASHK:Smoothing N-gram ModelsNLP_KASHK:Smoothing N-gram Models
NLP_KASHK:Smoothing N-gram Models
 
NLP_KASHK:N-Grams
NLP_KASHK:N-GramsNLP_KASHK:N-Grams
NLP_KASHK:N-Grams
 
NLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit DistanceNLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit Distance
 
NLP_KASHK: Introduction
NLP_KASHK: Introduction NLP_KASHK: Introduction
NLP_KASHK: Introduction
 
COM1407: File Processing
COM1407: File Processing COM1407: File Processing
COM1407: File Processing
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
 
COM1407: Input/ Output Functions
COM1407: Input/ Output FunctionsCOM1407: Input/ Output Functions
COM1407: Input/ Output Functions
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops
 
COM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & BranchingCOM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & Branching
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants COM1407: Type Casting, Command Line Arguments and Defining Constants
COM1407: Type Casting, Command Line Arguments and Defining Constants
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming
 

Último

Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosVictor Morales
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxRomil Mishra
 

Último (20)

Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitos
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
 

NLP_KASHK:Finite-State Automata

  • 2. Introduction • The regular expression is more than just a convenient meta-language for text searching. • Symmetrically, any finite-state automaton can be described with a regular expression. • Second, a regular expression is one way of characterizing a particular kind of formal language called a regular language. • Both regular expressions and finite-state automata can be used to described regular languages.
  • 3. Introduction (Cont…) • we defined the sheep language as any string from the following (infinite) set: /baa+!/
  • 4. Introduction (Cont…) • We represent the automaton as a directed graph: a finite set of vertices (also called nodes), together with a set of directed links between pairs of vertices called arcs. • We’ll represent vertices with circles and arcs with arrows. • The automaton has five states, which are represented by nodes in the graph. • State 0 is the start state which we represent by the incoming arrow. • State 4 is the final state or accepting state, which we represent by the double circle. • It also has four transitions, which we represent by arcs in the graph.
  • 5. Introduction (Cont…) • The FSA can be used for recognizing (we also say accepting) strings in the following way. • The machine starts in the start state (q0), and iterates the following process: – Check the next letter of the input. – If it matches the symbol on an arc leaving the current state, then cross that arc, move to the next state, and also advance one symbol in the input. I – If we are in the accepting state (q4) when we run out of input, the machine has successfully recognized an instance of sheeptalk. • If the machine never gets to the final state, either because – it runs out of input, or – it gets some input that doesn’t match an arc, or – if it just happens to get stuck in some non-final state, we say the machine rejects or fails to accept an input.
  • 6. Introduction (Cont…) • We can also represent an automaton with a state- transition table. • We’ve marked state 4 with a colon to indicate that it’s a final state (you can have as many final states as you want), and the /0 indicates an illegal or missing transition.
  • 7. Introduction (Cont…) • More formally, a finite automaton is defined by the following 5 parameters: – Q: a finite set of N states q0,q1,….,qN – Σ: a finite input alphabet of symbols – q0: the start state – F: the set of final states, F subset of Q – d(q,i): The transition function or transition matrix between states. – Given a state qϵQ and an input symbol iϵΣ, δ(q,i) returns a new state q’ϵQ. – δ is thus a relation from Q ×Σ to Q;
  • 8. Introduction (Cont…) • E.g. Q={q0 ,q1, q2, q3, q4 } Σ = {a, b, !} F = q4 δ(q,i) is defined by the transition table
  • 9. Fail State • The state machine will fail whenever there is no legal transition for a given combination of state and input. • The input abc will fail to be recognized since there is no legal transition out of state q0 on the input a. • Even if the automaton had allowed an initial a it would have certainly failed on c, since c isn’t even in the alphabet! • We can think of these ‘empty’ elements in the table as if they all pointed at one ‘empty’ state, which we might call the fail state or sink state.
  • 10. Fail State (Cont…) • In a sense then, we could view any machine with empty transitions as if we had augmented it with a fail state, and drawn in all the extra arcs, so we always had somewhere to go from any state on any possible input. • Just for completeness, the following is the previous FSA with the fail state qF.
  • 11. Formal Languages • Let’s say for now that we don’t care how the machine makes this decision; maybe it flips a coin. • For now, we don’t care which exact string of above example we generate, as long as it’s a string captured by the regular expression for discussed previously. • A formal language is a set of strings, each string composed of symbols from a finite symbol-set called an alphabet (the same alphabet used above for defining an automaton!). • The alphabet for the above example is the set Σ ={a, b, !}. • Given a model m (such as a particular FSA), we can use L(m) to mean “the formal language characterized by m”. • So the formal language defined by previous automaton m in is the infinite set: L(m)={baa!, baaa!, baaaa!, baaaaa!, baaaaaa!,…..}
  • 12. Formal Languages (Cont…) • The usefulness of an automaton for defining a language is that it can express an infinite set (such as this one above) in a closed form. • Formal languages are not the same as natural languages, which are the kind of languages that real people speak. • In fact a formal language may bear no resemblance at all to a real language. • But we often use a formal language to model part of a natural language, such as parts of the phonology, morphology, or syntax. • The term generative grammar is sometimes used in linguistics to mean a grammar of a formal language; the origin of the term is this use of an automaton to define a language by generating all possible strings.
  • 13. FSA with Word Combination • Suppose we wanted to build an FSA that modeled the subpart of English dealing with amounts of money. • Such a formal language would model the subset of English consisting of phrases like ten cents, three dollars, one dollar thirty-five cents and so on.
  • 14. FSA with Word Combination (Cont…) • We could now add cents and dollars to our automaton.
  • 15. Nondeterministic FSAs • When we get to state 2, if we see an a we don’t know whether to remain in state 2 or go on to state 3. • Automata with decision points like this are called Non-deterministic FSAs (or NFSAs). • Recall by contrast that previous example specified a deterministic automaton, i.e. one whose behavior during recognition is fully determined by the state it is in and the symbol it is looking at. • A deterministic automaton can be referred to as a DFSA.
  • 16. Nondeterministic FSAs (Cont…) • There is another common type of non- determinism, which can be caused by arcs that have no symbols on them (called ε-transitions). • The automaton ε in following diagram defines the exact same language as the last one, or our first one, but it does it with an ε-transition.
  • 17. Nondeterministic FSAs (Cont…) • We interpret this new arc as follows: • If we are in state 3, we are allowed to move to state 2 without looking at the input, or advancing our input pointer. • So this introduces another kind of non-determinism – we might not know whether to follow the ε transition or the ! arc.
  • 18. Using an NFSA to Accept Strings • If we want to know whether a string is an instance of a particular corpus or not, and if we use a non-deterministic machine to recognize it, we might follow the wrong arc and reject it when we should have accepted it. • That is, since there is more than one choice at some point, we might take the wrong choice. • This problem of choice in non-deterministic models will come up again and again as we build computational models, particularly for parsing.
  • 19. Using an NFSA to Accept Strings (Cont…) • There are three standard solutions to this problem: – Backup: • Whenever we come to a choice point, we could put a marker to mark where we were in the input, and what state the automaton was in. Then if it turns out that we took the wrong choice, we could back up and try another path. – Look-ahead: • We could look ahead in the input to help us decide which path to take. – Parallelism: • Whenever we come to a choice point, we could look at every alternative path in parallel.