Exemplo n.º 1
0
    def has(self, stmts, models):

        candidates = set()
        for s in stmts:
            if not candidates:
                candidates = set(matchingstmt(self.conn, s, models))
            else:
                candidates &= set(matchingstmt(self.conn, s, models))

        return len(candidates) > 0
Exemplo n.º 2
0
    def has(self, stmts, models):

        candidates = set()
        for s in stmts:
            if not candidates:
                candidates = set(matchingstmt(self.conn, s, models))
            else:
                candidates &= set(matchingstmt(self.conn, s, models))

        return len(candidates) > 0
Exemplo n.º 3
0
    def typeof(self, concept, models):
        classes = self.classesof(concept, False, models)
        if classes:
            if "owl:ObjectProperty" in classes:
                return "object_property"
            elif "owl:DatatypeProperty" in classes:
                return "datatype_property"
            elif "owl:Class" in classes:
                return "class"
            elif self.is_literal(concept):
                return "literal"
            else:
                return "instance"
        if self.instancesof(concept, False, models) or \
           self.subclassesof(concept, False, models) or \
           self.superclassesof(concept, False, models):
            return "class"

        stmts_if_predicate = matchingstmt(self.conn, ("?s", concept, "?o"),
                                          models)
        if stmts_if_predicate:
            if self.is_literal(stmts_if_predicate[0][3]):
                return "datatype_property"
            else:
                return "object_property"

        logger.warn("Concept <%s> has undefined type." % concept)
        return "undefined"
Exemplo n.º 4
0
    def typeof(self, concept, models):
        classes = self.classesof(concept, False, models)
        if classes:
            if "owl:ObjectProperty" in classes:
                return "object_property"
            elif "owl:DatatypeProperty" in classes:
                return "datatype_property"
            elif "owl:Class" in classes:
                return "class"
            elif self.is_literal(concept):
                return "literal"
            else:
                return "instance"
        if self.instancesof(concept, False, models) or \
           self.subclassesof(concept, False, models) or \
           self.superclassesof(concept, False, models):
               return "class"
        
        stmts_if_predicate = matchingstmt(self.conn, ("?s", concept, "?o"), models)
        if stmts_if_predicate:
            if self.is_literal(stmts_if_predicate[0][3]):
                return "datatype_property"
            else:
                return "object_property"

        logger.warn("Concept <%s> has undecidable type." % concept)
        return "undecided"