Skip to content

Commit 7844621

Browse files
authored
Merge pull request #9 from rudof-project/issue-8
Update tutorials to pyrudof new API
2 parents f93a787 + c9c5e8b commit 7844621

13 files changed

Lines changed: 17070 additions & 28494 deletions

‎rudof/compare.ipynb‎

Lines changed: 189 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,194 @@
11
{
2-
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"metadata": {
6-
"id": "sUm7kokski_K"
7-
},
8-
"source": [
9-
"# Using rudof to compare schemas"
10-
]
11-
},
12-
{
13-
"cell_type": "markdown",
14-
"metadata": {
15-
"id": "LMC6kMsUp3de"
16-
},
17-
"source": []
18-
},
19-
{
20-
"cell_type": "markdown",
21-
"metadata": {},
22-
"source": [
23-
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](\n",
24-
"https://colab.research.google.com/github/<yourusername>/<yourrepo>/blob/main/book/notebooks/example.ipynb)"
25-
]
26-
},
27-
{
28-
"cell_type": "code",
29-
"execution_count": null,
30-
"metadata": {},
31-
"outputs": [],
32-
"source": [
33-
"!pip install pyrudof"
34-
]
35-
},
36-
{
37-
"cell_type": "code",
38-
"execution_count": null,
39-
"metadata": {},
40-
"outputs": [],
41-
"source": [
42-
"from pyrudof import Rudof, RudofConfig\n",
43-
"rudof = Rudof(RudofConfig())"
44-
]
45-
},
46-
{
47-
"cell_type": "markdown",
48-
"metadata": {
49-
"id": "QtCQjCyUhkoI"
50-
},
51-
"source": [
52-
"## Comparing Schemas"
53-
]
54-
},
55-
{
56-
"cell_type": "markdown",
57-
"metadata": {
58-
"id": "EtecYMyOhooQ"
59-
},
60-
"source": [
61-
"It is possible to use rudof to compare different schemas. For example:"
62-
]
63-
},
64-
{
65-
"cell_type": "code",
66-
"execution_count": 61,
67-
"metadata": {
68-
"id": "2m7-w7NEhvzo"
69-
},
70-
"outputs": [],
71-
"source": [
72-
"schema1 = \"\"\"\n",
73-
" PREFIX : <http://example.org/>\n",
74-
" PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n",
75-
" :Person {\n",
76-
" :name xsd:string ;\n",
77-
" :age xsd:integer ;\n",
78-
" :weight xsd:float ;\n",
79-
" :worksFor .\n",
80-
" }\n",
81-
"\"\"\";"
82-
]
83-
},
84-
{
85-
"cell_type": "code",
86-
"execution_count": 62,
87-
"metadata": {
88-
"id": "u-DOFji_iIyw"
89-
},
90-
"outputs": [],
91-
"source": [
92-
"schema2 = \"\"\"\n",
93-
" PREFIX ex: <http://example.org/>\n",
94-
" PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n",
95-
" ex:Person {\n",
96-
" ex:name xsd:string ;\n",
97-
" ex:birthDate xsd:date ;\n",
98-
" ex:worksFor .\n",
99-
"}\n",
100-
"\"\"\""
101-
]
102-
},
103-
{
104-
"cell_type": "code",
105-
"execution_count": 63,
106-
"metadata": {
107-
"id": "19TByao3icnw"
108-
},
109-
"outputs": [],
110-
"source": [
111-
"result = rudof.compare_schemas_str(\n",
112-
" schema1, schema2,\n",
113-
" \"shex\", \"shex\",\n",
114-
" \"shexc\", \"shexc\",\n",
115-
" None, None,\n",
116-
" \"http://example.org/Person\", \"http://example.org/Person\"\n",
117-
" )"
118-
]
119-
},
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"id": "sUm7kokski_K"
7+
},
8+
"source": [
9+
"# Using rudof to compare schemas"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](\n",
17+
"https://colab.research.google.com/github/<yourusername>/<yourrepo>/blob/main/book/notebooks/example.ipynb)"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": null,
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"!pip install pyrudof"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 1,
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"from pyrudof import Rudof, RudofConfig, ReaderMode\n",
36+
"rudof = Rudof(RudofConfig())"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {
42+
"id": "QtCQjCyUhkoI"
43+
},
44+
"source": [
45+
"## Comparing Schemas"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"metadata": {
51+
"id": "EtecYMyOhooQ"
52+
},
53+
"source": [
54+
"It is possible to use rudof to compare different schemas. For example:"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": 2,
60+
"metadata": {
61+
"id": "2m7-w7NEhvzo"
62+
},
63+
"outputs": [],
64+
"source": [
65+
"schema1 = \"\"\"\n",
66+
" PREFIX : <http://example.org/>\n",
67+
" PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n",
68+
" :Person {\n",
69+
" :name xsd:string ;\n",
70+
" :age xsd:integer ;\n",
71+
" :weight xsd:float ;\n",
72+
" :worksFor .\n",
73+
" }\n",
74+
"\"\"\";"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 3,
80+
"metadata": {
81+
"id": "u-DOFji_iIyw"
82+
},
83+
"outputs": [],
84+
"source": [
85+
"schema2 = \"\"\"\n",
86+
" PREFIX ex: <http://example.org/>\n",
87+
" PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n",
88+
" ex:Person {\n",
89+
" ex:name xsd:string ;\n",
90+
" ex:birthDate xsd:date ;\n",
91+
" ex:worksFor .\n",
92+
"}\n",
93+
"\"\"\""
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": 4,
99+
"metadata": {
100+
"id": "19TByao3icnw"
101+
},
102+
"outputs": [],
103+
"source": [
104+
"result = rudof.compare_schemas(\n",
105+
" schema1, schema2,\n",
106+
" \"shex\", \"shex\",\n",
107+
" \"shexc\", \"shexc\",\n",
108+
" None, None,\n",
109+
" \"http://example.org/Person\", \"http://example.org/Person\",\n",
110+
" ReaderMode.Lax\n",
111+
" )"
112+
]
113+
},
114+
{
115+
"cell_type": "code",
116+
"execution_count": 5,
117+
"metadata": {
118+
"id": "At6iW8MB0CYo"
119+
},
120+
"outputs": [
120121
{
121-
"cell_type": "code",
122-
"execution_count": null,
123-
"metadata": {
124-
"id": "At6iW8MB0CYo"
125-
},
126-
"outputs": [],
127-
"source": [
128-
"print(f\"Result of comparison:\\n{result.as_json()}\")"
129-
]
130-
}
131-
],
132-
"metadata": {
133-
"colab": {
134-
"provenance": [],
135-
"toc_visible": true
136-
},
137-
"kernelspec": {
138-
"display_name": "Python 3",
139-
"name": "python3"
140-
},
141-
"language_info": {
142-
"name": "python"
122+
"name": "stdout",
123+
"output_type": "stream",
124+
"text": [
125+
"Shapes Comparison:\n",
126+
" Equal properties:\n",
127+
" - http://example.org/worksFor: \n",
128+
" - descr1: - value: http://example.org/worksFor\n",
129+
" - datatype: _\n",
130+
"\n",
131+
" - descr2: - value: http://example.org/worksFor\n",
132+
" - datatype: _\n",
133+
"\n",
134+
"\n",
135+
" - http://example.org/name: \n",
136+
" - descr1: - value: http://example.org/name\n",
137+
" - datatype: http://www.w3.org/2001/XMLSchema#string\n",
138+
"\n",
139+
" - descr2: - value: http://example.org/name\n",
140+
" - datatype: http://www.w3.org/2001/XMLSchema#string\n",
141+
"\n",
142+
"\n",
143+
" Properties in shape 1 that are not in shape 2:\n",
144+
" - http://example.org/age: \n",
145+
" - descr: - value: http://example.org/age\n",
146+
" - datatype: http://www.w3.org/2001/XMLSchema#integer\n",
147+
"\n",
148+
"\n",
149+
" - http://example.org/weight: \n",
150+
" - descr: - value: http://example.org/weight\n",
151+
" - datatype: http://www.w3.org/2001/XMLSchema#float\n",
152+
"\n",
153+
"\n",
154+
" Properties in shape 2 that are not in shape 1:\n",
155+
" - http://example.org/birthDate: \n",
156+
" - descr: - value: http://example.org/birthDate\n",
157+
" - datatype: http://www.w3.org/2001/XMLSchema#date\n",
158+
"\n",
159+
"\n",
160+
"\n",
161+
"\n"
162+
]
143163
}
164+
],
165+
"source": [
166+
"print(result)"
167+
]
168+
}
169+
],
170+
"metadata": {
171+
"colab": {
172+
"provenance": [],
173+
"toc_visible": true
174+
},
175+
"kernelspec": {
176+
"display_name": "Python 3",
177+
"name": "python3"
144178
},
145-
"nbformat": 4,
146-
"nbformat_minor": 0
179+
"language_info": {
180+
"codemirror_mode": {
181+
"name": "ipython",
182+
"version": 3
183+
},
184+
"file_extension": ".py",
185+
"mimetype": "text/x-python",
186+
"name": "python",
187+
"nbconvert_exporter": "python",
188+
"pygments_lexer": "ipython3",
189+
"version": "3.13.7"
190+
}
191+
},
192+
"nbformat": 4,
193+
"nbformat_minor": 0
147194
}

0 commit comments

Comments
 (0)