12 September 2016

What is NLP?

A Context-Sensitive Parser in Prolog -Based Representation A context-sensitive parser addresses the issues of the previous section in a different manner. Suppose we desire to have proper noun–verb agreement enforced by the grammar rules themselves. In the dictionary entry for each word its singular or plural form can be noted as such. Then in the grammar specifications for nounphrase and verbphrase a further parameter is used to signify the Number of each phrase. This enforces the constraint that a singular noun has to be associated with a singular verb. Similar constraints for article–noun combinations can also be enforced. The technique we are using is constraining sentence components by enforcing variable bindings across the subtrees of the parse of the sentence (note the and links in the parse tree of Figure 8.4). Context sensitivity increases the power of a context-free grammar considerably. These additions are made by directly extending the Prolog code of Section 8.2: utterance(X) :- sentence(X, [ ]). sentence(Start, End) :- nounphrase(Start, Rest, Number), verbphrase(Rest, End, Number). nounphrase([Noun | End], End, Number) :- noun(Noun, Number). nounphrase([Article, Noun | End], End, Number) :- noun(Noun, Number), article(Article, Number). verbphrase([Verb | End], End, Number) :- verb(Verb, Number). verbphrase([Verb | Rest], End, Number) :- verb(Verb, Number), nounphrase(Rest, End, _). article(a, singular). article(these, plural). article(the, singular). article(the, plural). noun(man, singular). noun(men, plural). noun(dog, singular). noun(dogs, plural). verb(likes, singular). verb(like, plural). verb(bites, singular). verb(bite, plural). We next test some sentences. The answer to the second query is no, because the subject (men) and the verb (likes) do not agree in number. ?- utterance([the, men, like, the, dog]). Yes ?- utterance([the, men, likes, the, dog]). no If we enter the following goal, X returns all verb phrases that complete the plural “the men …” with all verb phrases with noun–verb number agreement. The final query returns all sentences with article–noun as well as noun–verb agreement. ?- utterance([the, men X]). ?- utterance(X).