In this situation, neither "the cup" nor "the table" is distinguishing, but "the cup on the table" succeeds in identifying one of the two cups.
the dominant method at the moment is, accordingly, to measure the similarity between generated expressions and those in a suitable corpus of referring expressions.