Some years back I saw a grammar based editor at Sony. It allowed you to type a sentence in romaji and it would display a romaji/kanji/kana representation of the sentence at the bottom of the screen. Since it 'understood' the sentence, by the time you got to the end of the sentence, it had a pretty high probability of having it right. You could then tab over to any word and cycle through hiragana, katakana, romaji and the possible kanji equivs. Of course, as you fixed each word, it could be changing all of the unfixed part to match. I'ld hate to think how much code was behind it.