Pattern extraction and clustering for high-dimensional discrete data