There are two components of NLP, one works for understanding the right meaning/semantic of the text and other helps in generating the text as a response to the user.
a) Natural Language Understanding (NLU)
b) Natural Language Generation (NLG)
1) Natural Language Understanding: It is where the syntax and semantics are learnt by the machine. It is the step where machines understand the actual meaning and context of the sentence. But as the language comes with Ambiguity, so there are few problems mentioned below which occurs while understanding the text:
a) Lexical Ambiguity: When a word has more than one meaning.
Example: I saw Bats (the Mammal Bat or wooden Cricket Bat)
b) Syntactic Ambiguity: Presence of two or more possible meanings within a single sentence.
Example: The chicken is ready to eat. (Chicken dish is now ready for you to eat, Or, chicken himself is ready to eat something)
c) Referential Ambiguity: When it is not clear about the object you are referring to.
Example: John called Jay. Later, He laughed. (Here who is he referring to John or Jay)
There are defined techniques which are used to remove these ambiguities from the text so that the right meaning is understood by the machine.
2) Natural Language Generation: It is where machines generate text from their knowledge base.
Example: Automatic Essay Writing, News Writing etc.
Natural Language Generation works in three phases:
a) Text planning: In this phase, useful content is fetched from the machine's knowledge base.
b) Sentence planning: In this phase, selection of words, forming meaningful phrases and setting tone of the sentence takes place.
c) Text Realization: This is the final phase where execution of a sentence plan is done into the final sentence for delivery.