This functionality is needed both in the query classifier, where it was first created, and in the cache.