generating production rule phrases randomly. refactored