A homonym is a word that has the same pronunciation and spelling as another word, but a different meaning.
A homograph is a word that has the same spelling as another word, but a different meaning.
A homophone is a word that has the same pronunciation as another word, but a different meaning.
These can cause ambiguity in reading text or in hearing speech.
Some sources state that homonym meanings must be unrelated (rather than just different), or that the words must have a different origin. Thus read (present tense) and read (past tense) would not be homonyms, whereas mean (unkind), mean (intend), and mean (average) would be.
Heteronyms (also sometimes called heterophones) are words that are spelled the same but have different pronunciations and meanings (in other words, they are homographs which differ in pronunciation or, technically, homographs which are not homophones). For example, the homographs desert (abandon) and desert (arid region) are heteronyms (pronounced differently), but mean (intend) and mean (average) are not (Ie. they are pronounced the same, or are homonyms).
Capitonyms are words that are spelled the same but have different meanings when capitalised (and may or may not have different pronunciations) – for example, polish (to make shiny) and Polish (from Poland).
In derivation, homonym means "same name", homophone means "same sound", homograph means "same writing", heteronym (somewhat confusingly) means "different name", and heterophone means "different sound".
Significant variant interpretations include:
Homonym has a specialised meaning in scientific nomenclature, see See also below. Homograph is sometimes used in typography as a synonym for homoglyph, and heteronym has a specialised meaning in poetry – see Heteronym (literature).
The first homophones that one learns in English are probably the homophones to, too, and two, but the sentence "Too much to do in two days" would confuse no one. (Note, however, when read with a natural rhythm in many dialects, to has a schwa and is not homophonous with too or two.)
In some accents, various sounds have merged in that they are no longer distinctive, and thus words that differ only by those sounds in an accent that maintains the distinction (a minimal pair) are homophonous in the accent with the merger. Some examples from English are:-
Homophones are sometimes used in message encryption to increase the difficulty in cracking the decryption code. In this case the clear text is altered prior to being encrypted and the decrypting party substitutes the homophones for their true meaning after decrypting the message
Many puns rely on homophones for their humor.
Homograph disambiguation is critically important in speech synthesis, natural language processing and other fields. See also polysemy for a closely related idea.