fix a bug in substitting phrases in rule extraction