Refactored Viterbi algorithm in such way that there is separate interface for encapsulation of logic of calculating transition and emission probabilities, and for calculating probabilities of states - being at the start (end) position of sequence of observed variables