1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
from test.data import TEST_DATA_DIR
import pytest
from rdflib import OWL, RDFS, Graph, Literal, Namespace
from rdflib.extras.infixowl import Class, Individual, manchesterSyntax
EXNS = Namespace("http://example.org/vocab/")
PZNS = Namespace(
"http://www.co-ode.org/ontologies/pizza/2005/10/18/classified/pizza.owl#"
)
@pytest.fixture(scope="function")
def graph():
g = Graph(identifier=EXNS.context0)
g.bind("ex", EXNS)
g.bind("pizza", PZNS)
Individual.factoryGraph = g
yield g
del g
def test_manchester_syntax(graph):
graph.parse(TEST_DATA_DIR / "owl" / "pizza.owl", format="xml")
res = manchesterSyntax(
PZNS.Caprina,
graph,
boolean=False,
transientList=False,
)
assert res == Literal("Caprina", lang="pt")
res = manchesterSyntax(
PZNS.Caprina,
graph,
boolean=False,
transientList=True,
)
assert res == Literal("Caprina", lang="pt")
def test_manchester_syntax_parse_with_transientlist(graph):
graph.parse(TEST_DATA_DIR / "owl" / "pizza.owl", format="xml")
res = manchesterSyntax(
PZNS.Caprina,
graph,
boolean=False,
transientList=False,
)
assert res == Literal("Caprina", lang="pt")
assert (
PZNS.SloppyGiuseppe,
RDFS.label,
Literal("SloppyGiuseppe", lang="pt"),
) in graph
Class(PZNS.Caprina).complementOf = Class(PZNS.SloppyGiuseppe)
res = manchesterSyntax(
PZNS.Caprina,
graph,
boolean=OWL.complementOf,
transientList=True,
)
assert res == "( NOT SloppyGiuseppe )"
|