Complete predictNextWord.r Script

Complete predictNextWord.r script (needs comments).