Pragmatics is the last stage of analysis, where the meaning is elaborated based on contextual and world knowledge. Contextual knowledge includes knowledge of the previous sentences (spoken or written), general knowledge about the world, and knowledge of the speaker.
One important task at this stage are to work out referents of expressions. For example, in the sentence ``he kicked the brown dog'' the expression ``the brown dog'' refers to a particular brown dog (say, Fido). The pronoun ``he'' refers to the particular guy we are talking about (Fred). A full representation of the meaning of the sentence should mention Fido and Fred.
We can often find this out by looking at the previous sentence, e.g.:
Fred went to the park.
He kicked the brown dog.
We can work out from this that ``he'' refers to Fred. We might also guess that the brown dog is in the park, but to work out that we mean Fido we'd need some extra general or contextual knowledge - that the only brown dog that generally frequents the park is Fido. In general this kind of inference is pretty difficult, though quite alot can be done using simple strategies, like looking at who's mentioned in the previous sentence to work out who ``he'' refers to. Of course, sometimes there may be two people (or two dogs) that the speaker might be referring to, e.g.,
There was a brown dog and a black dog in the park. Fred went to the park with Jim. He kicked the dog.
In cases like this we have referential ambiguity. It is seldom quite as explicit as this, but in general can be a big problem. When the intended referent is unclear a natural language dialogue system may have to initiate a clarification subdialogue, asking for example ``Do you mean the black one or the brown one.''.
Anyway, another thing that is often done at this stage of analysis (pragmatics) is to try and guess at the goals underlying utterances. For example, if someone asks how much something is you generally assume that they have the goal of (probably) buying it. If you can guess at people's goals you can be a bit more helpful in responding to their questions. So, an automatic airline information service, when asked when the next flight to Paris is, shouldn`t just say ``6pm'' if it knows the flight is full. It should guess that the questioner wants to travel on it, check that this is possible, and say ``6pm, but it's full. The next flight with an empty seat is at 8pm.''