Presentation is loading. Please wait.

Presentation is loading. Please wait.

Natural Language Processing Lecture 3—9/3/2013 Jim Martin.

Similar presentations


Presentation on theme: "Natural Language Processing Lecture 3—9/3/2013 Jim Martin."— Presentation transcript:

1 Natural Language Processing Lecture 3—9/3/2013 Jim Martin

2 4/13/2015 Speech and Language Processing - Jurafsky and Martin 2 Today Review/finish up FSA material English morphology Morphological processing and FSAs

3 4/13/2015 Speech and Language Processing - Jurafsky and Martin 3 ND Recognition Two basic approaches (used in all major implementations of regular expressions, see Friedl 2006) 1.Either take a ND machine and convert it to a D machine and then do recognition with that. 2.Or explicitly manage the process of recognition as a state-space search (leaving the machine as is).

4 4/13/2015 Speech and Language Processing - Jurafsky and Martin 4 Non-Deterministic Recognition: Search In a ND FSA there exists at least one path through the machine for any string that is in the language defined by the machine. But not all paths directed through the machine for an accept string necessarily lead to an accept state. No paths through the machine lead to an accept state for a string not in the language.

5 4/13/2015 Speech and Language Processing - Jurafsky and Martin 5 Non-Deterministic Recognition So success in non-deterministic recognition occurs when a path is found through the machine that ends in an accept state. Failure occurs when all of the possible paths for a given string lead to failure.

6 4/13/2015 Speech and Language Processing - Jurafsky and Martin 6 Example ba a a !\ q0q0 q1q1 q2q2 q2q2 q3q3 q4q4

7 4/13/2015 Speech and Language Processing - Jurafsky and Martin 7 Example

8 4/13/2015 Speech and Language Processing - Jurafsky and Martin 8 Example

9 4/13/2015 Speech and Language Processing - Jurafsky and Martin 9 Example

10 4/13/2015 Speech and Language Processing - Jurafsky and Martin 10 Example

11 4/13/2015 Speech and Language Processing - Jurafsky and Martin 11 Example

12 4/13/2015 Speech and Language Processing - Jurafsky and Martin 12 Example

13 4/13/2015 Speech and Language Processing - Jurafsky and Martin 13 Example

14 4/13/2015 Speech and Language Processing - Jurafsky and Martin 14 Example

15 4/13/2015 Speech and Language Processing - Jurafsky and Martin 15 ND-Recognize

16 4/13/2015 Speech and Language Processing - Jurafsky and Martin 16 Example CurrentAgenda {(q0, 1)} (q0,1){} {(q1,2)} (q1,2){} {(q2,3)} (q2,3){} {(q3,4), (q2,4)} (q3,4){(q2,4)} (q2,4){} {(q3,5), (q2,5)} (q3,5){(q2,5)} {(q4,6), (q2,5)} (q4,6)

17 4/13/2015 Speech and Language Processing - Jurafsky and Martin 17 Why Bother with ND? Non-determinism doesn’t get us more formal power and it causes headaches so why bother?  More natural (understandable) solutions  Not always obvious to users whether or not the regex that they’ve produced is non- deterministic or not  Better to not make them worry about it

18 Converting NFAs to DFAs The Subset Construction is the means by which we can convert an NFA to a DFA automatically. The intuition is to think about being in multiple states at the same time. Let’s go back to our earlier example where we’re in state q 2 looking at an “a” 4/13/2015 Speech and Language Processing - Jurafsky and Martin 18

19 Subset Construction So the trick is to simulate going to both q2 and q3 at the same time One way to do this is to imagine a new state of a new machine that represents the state of being in states q2 and q3 at the same time  Let’s call that new state {q2,q3}  That’s just the name of a new state but it helps us remember where it came from  That’s a subset of the original set of states The construction does this for all possible subsets of the original states (the powerset).  And then we fill in the transition table for that set 4/13/2015 Speech and Language Processing - Jurafsky and Martin 19

20 Subset Construction Given an NFA with the usual parts: Q, Σ, transition function δ, start state q 0, and designated accept states We’ll construct a new DFA that accepts the same language where  States of the new machine are the powerset of states Q: call it Q D  Set of all subsets of Q  Start state is {q 0 }  Alphabet is the same: Σ  Accept states are the states in Q D that contain any accept state from Q 4/13/2015 Speech and Language Processing - Jurafsky and Martin 20

21 Subset Construction What about the transition function?  For every new state we’ll create a transition on a symbol α from the alphabet to a new state as follows  δ D ({q 1,…,q k }, α) = is the union over all i = 1,…,k of δ N (q i, α) for all αin the alphabet 4/13/2015 Speech and Language Processing - Jurafsky and Martin 21

22 Baaa! How does that work out for our example?  Alphabet is still “a”, “b” and “!”  Start state is {q0}  Rest of the states are: {q1}, {q2},... {q4}, {q1,q2}, {q1,q3}... {q0,q1,q2,q3,q4,q5}  All 2 5 -1 subsets of states in Q What’s the transition table going to look like? 4/13/2015 Speech and Language Processing - Jurafsky and Martin 22

23 Lazy Method 4/13/2015 Speech and Language Processing - Jurafsky and Martin 23 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}

24 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 24 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1}

25 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 25 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1}

26 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 26 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1} {q2}

27 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 27 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1} {q2} {q2,q3}

28 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 28 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1} {q2} {q2,q3}

29 Baaa! 4/13/2015 Speech and Language Processing - Jurafsky and Martin 29 ba! q0q1 q2 q2,q3 q3q4 ba! {q0}{q1} {q2} {q2,q3} {q4}

30 Couple of Notes We didn’t come close to needing 2 Q new states. Most of those were unreachable. So in theory there is the potential for an explosion in the number of states. In practice, it may be more manageable. Draw the new deterministic machine from the table on the previous slide... It should look familiar. 4/13/2015 Speech and Language Processing - Jurafsky and Martin 30

31 4/13/2015 Speech and Language Processing - Jurafsky and Martin 31 Compositional Machines Recall that formal languages are just sets of strings Therefore, we can talk about set operations (intersection, union, concatenation, negation) on languages This turns out to be a very useful  It allows us to decompose problems into smaller problems, solve those problems with specific languages, and then compose those solutions to solve the big problems.

32 Example Create a regex to match all the ways that people write down phone numbers. For just the U.S. that needs to cover  (303) 492-5555  303.492.5555  303-492-5555  1-303-492-5555  (01) 303-492-5555 You could write a big hairy regex to capture all that, or you could write individual regex’s for each type and then OR them together into a new regex/machine. How does that work? 4/13/2015 Speech and Language Processing - Jurafsky and Martin 32

33 4/13/2015 Speech and Language Processing - Jurafsky and Martin 33 Union (Or)

34 4/13/2015 Speech and Language Processing - Jurafsky and Martin 34 Negation Construct a machine M2 to accept all strings not accepted by machine M1 and reject all the strings accepted by M1  Invert all the accept and not accept states in M1 Does that work for non-deterministic machines?

35 4/13/2015 Speech and Language Processing - Jurafsky and Martin 35 Intersection (AND) Accept a string that is in both of two specified languages An indirect construction…  A^B = ~(~A or ~B)

36 Break If you were on the waitlist last week you should be in now. The class is now at the room cap. So if you’re on the waitlist now you’ll have to wait for someone to drop First homework will be posted soon...  Given a newspaper article, segment it into sentences and words (tokens) and tell me how many there are of each.  I will post development examples of the kind of texts I’m talking about 4/13/2015 Speech and Language Processing - Jurafsky and Martin 36

37 Changing Gears We’re switching to talking about why this stuff is relevant to NLP In particular, we’ll be talking about words and morphology 4/13/2015 Speech and Language Processing - Jurafsky and Martin 37

38 4/13/2015 Speech and Language Processing - Jurafsky and Martin 38 Words Finite-state methods are particularly useful in dealing with large lexicons  That is, big bunches of words  Often infinite sized bunches Many devices, some with limited memory resources, need access to large lists of words And they need to perform fairly sophisticated tasks with those lists So we’ll first talk about some facts about words and then come back to computational methods

39 4/13/2015 Speech and Language Processing - Jurafsky and Martin 39 English Morphology Morphology is the study of the ways that words are built up from smaller units called morphemes  The minimal meaning-bearing units in a language We can usefully divide morphemes into two classes  Stems: The core meaning-bearing units  Affixes: Bits and pieces that adhere to stems to change their meanings and grammatical functions

40 4/13/2015 Speech and Language Processing - Jurafsky and Martin 40 English Morphology We can further divide morphology up into two broad classes  Inflectional  Derivational

41 4/13/2015 Speech and Language Processing - Jurafsky and Martin 41 Word Classes By word class, we have in mind familiar notions like noun and verb  Also referred to as parts of speech and lexical categories We’ll go into the gory details in Chapter 5 Right now we’re concerned with word classes because the way that stems and affixes combine is based to a large degree on the word class of the stem

42 4/13/2015 Speech and Language Processing - Jurafsky and Martin 42 Inflectional Morphology Inflectional morphology concerns the combination of stems and affixes where the resulting word....  Has the same word class as the original  And serves a grammatical/semantic purpose that is  Different from the original  But is nevertheless transparently related to the original “walk” + “s” = “walks”

43 4/13/2015 Speech and Language Processing - Jurafsky and Martin 43 Inflection in English Nouns are simple  Markers for plural and possessive Verbs are only slightly more complex  Markers appropriate to the tense of the verb That’s pretty much it  Other languages can be quite a bit more complex  An implication of this is that hacks (approaches) that work in English will not work for many other languages

44 4/13/2015 Speech and Language Processing - Jurafsky and Martin 44 Regulars and Irregulars Things are complicated by the fact that some words misbehave (refuse to follow the rules)  Mouse/mice, goose/geese, ox/oxen  Go/went, fly/flew, catch/caught The terms regular and irregular are used to refer to words that follow the rules and those that don’t

45 4/13/2015 Speech and Language Processing - Jurafsky and Martin 45 Regular and Irregular Verbs Regulars…  Walk, walks, walking, walked, walked Irregulars  Eat, eats, eating, ate, eaten  Catch, catches, catching, caught, caught  Cut, cuts, cutting, cut, cut

46 4/13/2015 Speech and Language Processing - Jurafsky and Martin 46 Inflectional Morphology So inflectional morphology in English is fairly straightforward But is somewhat complicated by the fact that are irregularities

47 4/13/2015 Speech and Language Processing - Jurafsky and Martin 47 Derivational Morphology Derivational morphology is the messy stuff that no one ever taught you In English it is characterized by  Quasi-systematicity  Irregular meaning change  Changes of word class

48 4/13/2015 Speech and Language Processing - Jurafsky and Martin 48 Derivational Examples Verbs and Adjectives to Nouns -ationcomputerizecomputerization -eeappointappointee -erkillkiller -nessfuzzyfuzziness

49 4/13/2015 Speech and Language Processing - Jurafsky and Martin 49 Derivational Examples Nouns and Verbs to Adjectives -alcomputationcomputational -ableembraceembraceable -lessclueclueless

50 4/13/2015 Speech and Language Processing - Jurafsky and Martin 50 Example: Compute Many paths are possible… Start with compute  Computer -> computerize -> computerization  Computer -> computerize -> computerizable But not all paths/operations are equally good (allowable?)  Clue  Clue  clueless  Clue  ?clueful  Clue  *clueable

51 4/13/2015 Speech and Language Processing - Jurafsky and Martin 51 Morphology and FSAs We would like to use the machinery provided by FSAs to capture these facts about morphology  Accept strings that are in the language  Reject strings that are not  And do so in a way that doesn’t require us to in effect list all the forms of all the words in the language  Even in English this is inefficient  And in other languages it is impossible

52 4/13/2015 Speech and Language Processing - Jurafsky and Martin 52 Start Simple Regular singular nouns are ok as is  They are in the language Regular plural nouns have an -s on the end  So they’re also in the language Irregulars are ok as is

53 4/13/2015 Speech and Language Processing - Jurafsky and Martin 53 Simple Rules

54 4/13/2015 Speech and Language Processing - Jurafsky and Martin 54 Now Plug in the Words Spelled Out Replace the class names like “reg-noun” with FSAs that recognize all the words in that class.


Download ppt "Natural Language Processing Lecture 3—9/3/2013 Jim Martin."

Similar presentations


Ads by Google