Python implementation of trigram Viterbi