1. A method of correcting a misspelled word in input text, the method comprising: detecting, using a computer, a misspelled word in the input text, wherein the detecting comprises comparing each word in the input text to a dictionary database and characterizing a word as misspelled when the word does not match any words in the dictionary database; determining, using the computer, a list of alternative words for the misspelled word including a best alternative word; and ranking, using the computer, the list of alternative words based on a context of the input text, wherein the alternative words yield correct parts of speech sequences according to the context; wherein the ranking comprises: (i) generating a first finite state machine (“FSM”) for the input text, the first FSM having a plurality of arcs which include the alternative words and weights associated therewith, where a weight of each alternative word corresponds to a likelihood that the alternative word, taken out of grammatical context, comprises a correctly-spelled version of the misspelled word; and (ii) applying a second FSM to the first FSM and generating a third FSM, wherein the second FSM encodes a set of grammatically correct sequences of words; determining, using the computer, whether an alternative word is an element of a compound word or lexical phrase; and wherein the ranking step comprises modifying the rank of one or more of the alternative words if the alternative word is an element of a compound word or lexical phrase; and replacing, using the computer, the misspelled word with the best alternative word.