Implemented ngramsForString.