Refactoring e probabilistic grammar creation