feature-grammar.txt

Can you come up with a feature grammar that can parse the following good 
sentences, without parsing any bad ones?

Good: 
    She has a dog.
    She has an animal.
    She has some dogs.
    She has some animals.
    She has some milk.

Bad:
    She has an dog.
    She has a animal.
    She has some dog.
    She has a milk.

===================== Grammar ====================

S  -> NP VP
NP -> Pronoun
NP -> Det[x] Noun[y]
VP -> Verb NP

x, y satisfy function f(x) = y.  Function f is defined as:

f(x) = singular countable noun that begins with a consonant sound if x = 'a'
f(x) = singular countable noun that begins with a vowel sound if x = 'an'
f(x) = plural countable noun OR uncountable noun if x = 'some'

============== Parse Good Sentences ==============

Top down parsing "She has a dog."
    S -> NP VP
      -> NP(Pronoun) VP(Verb NP)
      -> NP(Pronoun(She)) VP(Verb(has) NP(Det Noun))
      -> NP(Pronoun(She)) VP(Verb(has) NP(Det(a) Noun(dog)))

    x = 'a', y = 'dog' satisfy the grammar.
    => S -> NP(Pronoun(She)) VP(Verb(has) NP(Det(a) Noun(dog)))

              S
         /        \
        NP        VP
        |       /    \
        |     Vert   NP
        |      |    /  \
        |      |  Det  Noun
        |      |   |     |  
       She    has  a    dog

Bottom up parsing "She has some milk."
    She <- Pronoun
    She <- NP(Pronoun)
    has <- Verb
    some <- Det
    milk <- Noun

    x = 'some', y = 'milk' satisfy the grammar, so continue:
    some milk <- Det Noun
    some milk <- NP(Det Noun)
    has some milk <- Verb NP(Det Noun)
    S -> NP(Pronoun(She)) VP(Verb(has) NP(Det(some) Noun(milk)))

              S
         /        \
        NP        VP
        |       /    \
        |     Vert   NP
        |      |    /  \
        |      |  Det  Noun
        |      |   |     |  
       She    has some milk

============== Parse Bad Sentences ===============

Top down parsing "She has an dog."
    S -> NP VP
      -> NP(Pronoun) VP(Verb NP)
      -> NP(Pronoun(She)) VP(Verb(has) NP(Det Noun))
      -> NP(Pronoun(She)) VP(Verb(has) NP(Det(an) Noun(dog)))

    x = 'an', y = 'dog' fail the grammar.
    => The given grammar failles to parse "She has an dog"

Bottom up parsing "She has a milk."
    She <- Pronoun
    She <- NP(Pronoun)
    has <- Verb
    some <- Det
    milk <- Noun

    x = 'a', y = 'milk' fail the grammar.
    => The given grammar failles to parse "She has a milk"
Valid HTML 4.01 Valid CSS