cky implementation based on Micheal Collins NLP class (coursera)