This is the code written as part of the Kotlin functional programming webinar done on October 22nd 2015.
Please note that this program is NOT COMPLETE. It requires an n-gram list in the form of a tab separated file, with the first column being a frequency and the rest being the words. You can get such files from
but the redistribution requirements mean I cannot bundle them here.