A Formal Framework for Coupling Document Spanners with Ontologies