SlideServe
Menu
Préférences
© SlideServe · v2026

LING 388: Language and Computers

plato-moore avatar
17 diapositives · 371 Views · Oct 31, 2014

LING 388: Language and Computers. Sandiway Fong Lecture 12: 10/5. Today’s Topics. Tasks Practice how to write a FSA in Prolog Dealing with string transitions Homework #4 Due next Thursday Only two questions Derivational morphology and FSA Converting NDFSA to (deterministic) FSA.

LING 388: Language and Computers - slide 1
01 / 17LING 388: Language and Computers
1 / 17

Télécharger la présentation

LING 388: Language and Computers
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. LING 388: Language and Computers Sandiway Fong Lecture 12: 10/5

  2. Today’s Topics • Tasks • Practice how to write a FSA in Prolog • Dealing with string transitions • Homework #4 • Due next Thursday • Only two questions • Derivational morphology and FSA • Converting NDFSA to (deterministic) FSA

  3. Prolog FSA: One predicate per state • from previous lectures • Prolog FSA implementation • regular expression: ba+! • query • ?- s([b,a,a,’!’]). • code • s([b|L]) :- x(L). a s x y b a > • x([a|L]) :- y(L). ! • y([a|L]) :- y(L). • y([‘!’|L]) :- z(L). z • z([]).

  4. Exercise 1 Derivational Morphology • Write a Prolog FSA that accepts all words ending in the verbal suffix -ize • use: • atom_chars(Word,List) • from the previous homework • examples: • formalize • summarize • *formalizes

  5. Given code: ends_ize(Word) :- atom_chars(Word,List), s(List). s = start state Write s/1 such that ?- ends_ize(formalize). Yes ?- ends_ize(summarize). Yes ?- ends_ize(formalizes). No Exercise 1

  6. Step 1: Draw the FSA: Notes: machine is non-deterministic see an i we don’t know if it’s the “i” in rise or formalize we can name the states anything we want here: states are named after the portion of the suffix recognized so far Exercise 1 s i i z a-z iz e ize

  7. Step 1: Draw the FSA: Step 2: Write the Prolog Hint: use the underscore variable to simulate the range a-z s i i z a-z iz e ize Exercise 1

  8. Step 1: Draw the FSA: Step 2: Write the Prolog s([_|L]) :- s(L). s([i|L]) :- i(L). i([z|L]) :- iz(L). i([e|L]) :- ize(L). ize([]). s i i z a-z iz e ize Exercise 1

  9. b a b b abb String Transitions [last lecture] • all machines have had just a single character label on the arc • so if we allow strings to label arcs • do they endow the FSA with any more power? • Answer: No • because we can always convert a machine with string-transitions into one without

  10. s ize ize a-z Exercise 2 • Let’s simplify the FSA for Exercise 1 using string transitions • Give the modified Prolog form s i i z a-z iz e ize

  11. s ize ize a-z Exercise 2 • Give the modified Prolog form s([_|L]) :- s(L). s([i,z,e|L]) :- ize(L). ize([]). s([_|L]) :- s(L). s([i,z,e]). s i i z a-z iz e ize

  12. Homework Question 1 • Part 1: (8pts) • Modify your machine so that it accepts • formalize • modernize • summarize • concretize • sterilize • but rejects • *summaryize • *concreteize • *sterileize • Part 2: (2pts) • explain what rule of English are we trying to encode here?

  13. a b a b a a b b  > x y   b Empty Transitions [last lecture] • how about allowing the empty character? • i.e. go from x to y without seeing a input character • does this endow the FSA with any more power? • Answer: No • because we can always convert a machine with empty transitions into one without

  14. s x a a b y a b b 1 2 3 a NDFSA • Deterministic FSA • deterministic • it’s clear which state we’re always in • deterministic = no choice • NDFSA • ND = non-deterministic • i.e. we could be in more than one state • non-deterministic  choice point • example: • see an “a”, either in state 2 or 3 next > > >

  15. > > > > a a {1} {1} {1} {1} {2,3} {2,3} b {3} a b a b > 1 2 3 2,3 2,3 2 1 3 a b {2,3} {3} a > NDFSA • NDFSA are generally not more powerful than regular (deterministic) FSA • because • we can transform any NDFSA into an equivalent FSA • trick: • (set of states construction) • construct new machine with states = set of possible states of the old machine

  16. Homework Question 2 • (10pts) • Part 1: (8pts) • Transform the NDFSA shown on the right into a deterministic FSA • Give the Prolog implementation of the machine • Part 2: (2pts) • what does this machine do? • i.e. what is the language it accepts? > q4

  17. Summary • Total: 20 pts • Question 1: 10pts • Question 2: 10pts