both techniques, ngram and edge ngram, has been implemeted
little refactoring