示例#1
0
    def test_ampersand_logical_operator(self):
        # The '&' operator can be used to construct class intersection:

        woman = Class(exNs.Female, graph=self.graph) & Class(exNs.Human, graph=self.graph)
        woman.identifier = exNs.Woman

        assert pformat(woman) == '( ex:Female AND ex:Human )', pformat(woman)
示例#2
0
    def test_ampersand_logical_operator(self):
        # The '&' operator can be used to construct class intersection:

        woman = Class(exNs.Female, graph=self.graph) & Class(exNs.Human,
                                                             graph=self.graph)
        woman.identifier = exNs.Woman

        assert pformat(woman) == '( ex:Female AND ex:Human )', pformat(woman)
示例#3
0
文件: example5.py 项目: RDFLib/FuXi
# of a owl:unionOf the operands:

c = a | b | Class(exNs.Work, graph=g)

assert(pformat(c)) == '( ex:Opera OR ex:CreativeWork OR ex:Work )'

# Boolean class expressions can also be operated as lists (natively in python)

del c[c.index(Class(exNs.Work, graph=g))]

assert pformat(c) == '( ex:Opera OR ex:CreativeWork )'

# The '&' operator can be used to construct class intersection:

woman = Class(exNs.Female, graph=g) & Class(exNs.Human, graph=g)
woman.identifier = exNs.Woman

assert pformat(woman) == '( ex:Female AND ex:Human )'

# Enumerated classes can also be manipulated

contList = [
    Class(exNs.Africa, graph=g),
    Class(exNs.NorthAmerica, graph=g)
]

assert pformat(
    EnumeratedClass(members=contList, graph=g)) == \
    '{ ex:Africa ex:NorthAmerica }'

# owl:Restrictions can also be instanciated:
示例#4
0
# of a owl:unionOf the operands:

c = a | b | Class(exNs.Work, graph=g)

assert (pformat(c)) == '( ex:Opera OR ex:CreativeWork OR ex:Work )'

# Boolean class expressions can also be operated as lists (natively in python)

del c[c.index(Class(exNs.Work, graph=g))]

assert pformat(c) == '( ex:Opera OR ex:CreativeWork )'

# The '&' operator can be used to construct class intersection:

woman = Class(exNs.Female, graph=g) & Class(exNs.Human, graph=g)
woman.identifier = exNs.Woman

assert pformat(woman) == '( ex:Female AND ex:Human )'

# Enumerated classes can also be manipulated

contList = [Class(exNs.Africa, graph=g), Class(exNs.NorthAmerica, graph=g)]

assert pformat(
    EnumeratedClass(members=contList, graph=g)) == \
    '{ ex:Africa ex:NorthAmerica }'

# owl:Restrictions can also be instanciated:

assert pformat(Restriction(
    exNs.hasParent, graph=g, allValuesFrom=exNs.Human)) == \