Community detection, pattern recognition, and hypergraph-based learning: approaches using metric geometry and persistent homology