weighted key selection and synonym replacement