One embodiment of the present invention provides a system that identifies a synonym with N-gram agreement for a query phrase. During operation, the system receives a candidate synon