parse self._ontology_file into a graph

def _schema_nodes(self):
        """parse self._ontology_file into a graph"""
        name, ext = os.path.splitext(self._ontology_file)
        if ext in ['.ttl']:
            self._ontology_parser_function = \
                lambda s: rdflib.Graph().parse(s, format='n3')
        else:
            self._ontology_parser_function = \
                lambda s: pyRdfa().graph_from_source(s)
        if not self._ontology_parser_function:
            raise ValueError(
                "No function found to parse ontology. %s" %
                self.errorstring_base)
        if not self._ontology_file:
            raise ValueError(
                "No ontology file specified. %s" % self.errorstring_base)
        if not self.lexicon:
            raise ValueError(
                "No lexicon object assigned. %s" % self.errorstring_base)

        latest_file = self._read_schema()

        try:
            self.graph = self._ontology_parser_function(latest_file)
        except:
            raise IOError("Error parsing ontology at %s" % latest_file)

        for subj, pred, obj in self.graph:
            self.ontology[subj].append((pred, obj))
            yield (subj, pred, obj)