Feature/dynamic programming

Implement dynamic programming phrasing algorithm.