N-gram implementation in Java for language modelling