Factoring out word canonicalisation and using it in search API.