13. A system comprising: one or more computers and one or more storage devices storing instructions that, when executed by the one or more computers, cause the one or more computers to perform operations comprising: selecting a first term and a second term; determining, for each of one or more first co-occurring terms that occur in past search queries that include the first term, a first co-occurrence frequency of the co-occurring term in search queries that include the first term; generating a first vector for the first term using the first co-occurrence frequencies; determining, for each of one or more second co-occurring terms that occur in past search queries that include the first term adjacent to the second term, a second co-occurrence frequency of the co-occurring term in the search queries that include the first term adjacent to the second term; generating a second vector for the second term using the second co-occurrence frequencies; comparing the first vector and the second vector; and computing a score for the second term as a context for a substitution rule based on the first term, wherein the score is based on a comparison between the first vector and the second vector.
14. The system of claim 13 , wherein computing a score for the second term comprises: computing respective changes in co-occurrence frequency between corresponding elements of the first vector and the second vector; generating an order of co-occurring terms according to the corresponding computed changes in co-occurrence frequency; and computing a measure of importance of a top number of co-occurring terms in the order.