Skip to content

Commit 21f2d09

Browse files
test-cases: add manifest
1 parent 61d115b commit 21f2d09

File tree

6 files changed

+4709
-2363
lines changed

6 files changed

+4709
-2363
lines changed

test-cases/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# RML Core test cases
2+
3+
Manifest of test cases can be generated as followed:
4+
5+
1. Add the testcase description in `descriptions.csv` or fetch it from the Google spreadsheet.
6+
2. Execute the `make-metadata.py` script: `python3 make-metadata.py http://w3id.org/rml/core/`
7+
3. Generate the manifest with RMLMapper: `java -jar rmlmapper.jar -m manifest.rml.ttl -o manifest.ttl -s turtle`
8+
9+

test-cases/descriptions.csv

+349
Large diffs are not rendered by default.

test-cases/make-metadata.py

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
import glob
6+
import csv
7+
8+
def get_title_description(testcase: str):
9+
with open ('descriptions.csv') as csvfile:
10+
reader = csv.reader(csvfile)
11+
for row in reader:
12+
if row[0] == testcase:
13+
return row[1], row[2]
14+
15+
def main(spec: str):
16+
with open ('metadata.csv', 'w') as csvfile:
17+
writer = csv.writer(csvfile)
18+
writer.writerow(['ID', 'title', 'description', 'specification',
19+
'mapping', 'input_format1', 'input_format2',
20+
'input_format3', 'output_format1', 'output_format2',
21+
'output_format3', 'input1', 'input2', 'input3',
22+
'output1', 'output2', 'output3', 'error'])
23+
for testcase in glob.glob('RML*'):
24+
title, description = get_title_description(testcase)
25+
title = '"' + title + '"'
26+
description = '"' + description + '"'
27+
error = 'false'
28+
input1 = ''
29+
input2 = ''
30+
input3 = ''
31+
input_format1 = ''
32+
input_format2 = ''
33+
input_format3 = ''
34+
output1 = ''
35+
output2 = ''
36+
output3 = ''
37+
output_format1 = ''
38+
output_format2 = ''
39+
output_format3 = ''
40+
41+
# Input file
42+
if os.path.exists(os.path.join(testcase, 'student.json')):
43+
input1 = 'student.json'
44+
input_format1 = 'application/json'
45+
elif os.path.exists(os.path.join(testcase, 'student_sport.json')):
46+
if testcase == 'RMLTC0009a-JSON' or testcase == 'RMLTC0009b-JSON':
47+
input3 = 'student_sport.json'
48+
input_format3 = 'application/json'
49+
else:
50+
input1 = 'student_sport.json'
51+
input_format1 = 'application/json'
52+
elif os.path.exists(os.path.join(testcase, 'sport.json')):
53+
input2 = 'sport.json'
54+
input_format2 = 'application/json'
55+
elif os.path.exists(os.path.join(testcase, 'ious.json')):
56+
input1 = 'ious.json'
57+
input_format1 = 'application/json'
58+
elif os.path.exists(os.path.join(testcase, 'country_info.json')):
59+
input1 = 'country_info.json'
60+
input_format1 = 'application/json'
61+
elif os.path.exists(os.path.join(testcase, 'persons.json')):
62+
if testcase == 'RMLTC0012b-JSON':
63+
input2 = 'persons.json'
64+
input_format2 = 'application/json'
65+
else:
66+
input1 = 'persons.json'
67+
input_format1 = 'application/json'
68+
elif os.path.exists(os.path.join(testcase, 'country_en.json')):
69+
input1 = 'country_en.json'
70+
input_format1 = 'application/json'
71+
elif os.path.exists(os.path.join(testcase, 'country_es.json')):
72+
input1 = 'country_es.json'
73+
input_format1 = 'application/json'
74+
elif os.path.exists(os.path.join(testcase, 'data.json')):
75+
input1 = 'data.json'
76+
input_format1 = 'application/json'
77+
elif os.path.exists(os.path.join(testcase, 'lives.json')):
78+
input1 = 'lives.json'
79+
input_format1 = 'application/json'
80+
elif os.path.exists(os.path.join(testcase, 'student.xml')):
81+
input1 = 'student.xml'
82+
input_format1 = 'text/xml'
83+
elif os.path.exists(os.path.join(testcase, 'student_sport.xml')):
84+
if testcase == 'RMLTC0009a-XML' or testcase == 'RMLTC0009b-XML':
85+
input3 = 'student_sport.xml'
86+
input_format3 = 'text/xml'
87+
else:
88+
input1 = 'student_sport.xml'
89+
input_format1 = 'text/xml'
90+
elif os.path.exists(os.path.join(testcase, 'sport.xml')):
91+
input2 = 'sport.xml'
92+
input_format2 = 'text/xml'
93+
elif os.path.exists(os.path.join(testcase, 'ious.xml')):
94+
input1 = 'ious.xml'
95+
input_format1 = 'text/xml'
96+
elif os.path.exists(os.path.join(testcase, 'country_info.xml')):
97+
input1 = 'country_info.xml'
98+
input_format1 = 'text/xml'
99+
elif os.path.exists(os.path.join(testcase, 'persons.xml')):
100+
if testcase == 'RMLTC0012b-XML':
101+
input2 = 'persons.xml'
102+
input_format2 = 'text/xml'
103+
else:
104+
input1 = 'persons.xml'
105+
input_format1 = 'text/xml'
106+
elif os.path.exists(os.path.join(testcase, 'country_en.xml')):
107+
input1 = 'country_en.xml'
108+
input_format1 = 'text/xml'
109+
elif os.path.exists(os.path.join(testcase, 'country_es.xml')):
110+
input1 = 'country_es.xml'
111+
input_format1 = 'text/xml'
112+
elif os.path.exists(os.path.join(testcase, 'data.xml')):
113+
input1 = 'data.xml'
114+
input_format1 = 'text/xml'
115+
elif os.path.exists(os.path.join(testcase, 'lives.xml')):
116+
input1 = 'lives.xml'
117+
input_format1 = 'text/xml'
118+
elif os.path.exists(os.path.join(testcase, 'student.csv')):
119+
input1 = 'student.csv'
120+
input_format1 = 'text/csv'
121+
elif os.path.exists(os.path.join(testcase, 'student_sport.csv')):
122+
if testcase == 'RMLTC0009a-CSV' or testcase == 'RMLTC0009b-CSV':
123+
input3 = 'student_sport.csv'
124+
input_format3 = 'text/csv'
125+
else:
126+
input1 = 'student_sport.csv'
127+
input_format1 = 'text/csv'
128+
elif os.path.exists(os.path.join(testcase, 'sport.csv')):
129+
input2 = 'sport.csv'
130+
input_format2 = 'text/csv'
131+
elif os.path.exists(os.path.join(testcase, 'ious.csv')):
132+
input1 = 'ious.csv'
133+
input_format1 = 'text/csv'
134+
elif os.path.exists(os.path.join(testcase, 'country_info.csv')):
135+
input1 = 'country_info.csv'
136+
input_format1 = 'text/csv'
137+
elif os.path.exists(os.path.join(testcase, 'persons.csv')):
138+
if testcase == 'RMLTC0012b-CSV':
139+
input2 = 'persons.csv'
140+
input_format2 = 'text/csv'
141+
else:
142+
input1 = 'persons.csv'
143+
input_format1 = 'text/csv'
144+
elif os.path.exists(os.path.join(testcase, 'country_en.csv')):
145+
input1 = 'country_en.csv'
146+
input_format1 = 'text/csv'
147+
elif os.path.exists(os.path.join(testcase, 'country_es.csv')):
148+
input1 = 'country_es.csv'
149+
input_format1 = 'text/csv'
150+
elif os.path.exists(os.path.join(testcase, 'data.csv')):
151+
input1 = 'data.csv'
152+
input_format1 = 'text/csv'
153+
elif os.path.exists(os.path.join(testcase, 'lives.csv')):
154+
input1 = 'lives.csv'
155+
input_format1 = 'text/csv'
156+
elif os.path.exists(os.path.join(testcase, 'resource.sql')):
157+
input1 = 'resource.sql'
158+
if 'MySQL' in testcase:
159+
input_format1 = 'application/sql+mysql'
160+
elif 'PostgreSQL' in testcase:
161+
input_format1 = 'application/sql+postgresql'
162+
elif 'SQLServer' in testcase:
163+
input_format1 = 'application/sql+sqlserver'
164+
elif 'MariaDB' in testcase:
165+
input_format1 = 'application/sql+mariadb'
166+
elif 'SQLite' in testcase:
167+
input_format1 = 'application/sql+sqlite'
168+
else:
169+
input_format1 = 'application/sql'
170+
elif os.path.exists(os.path.join(testcase, 'resource.ttl')):
171+
input1 = 'resource.ttl'
172+
input_format1 = 'text/turtle'
173+
elif os.path.exists(os.path.join(testcase, 'resource1.ttl')):
174+
input1 = 'resource1.ttl'
175+
input_format1 = 'text/turtle'
176+
elif os.path.exists(os.path.join(testcase, 'resource2.ttl')):
177+
input2 = 'resource2.ttl'
178+
input_format2 = 'text/turtle'
179+
180+
# Mapping file
181+
if os.path.exists(os.path.join(testcase, 'mapping.ttl')):
182+
mapping_file = 'mapping.ttl'
183+
else:
184+
raise ValueError('Mapping file missing!')
185+
186+
# Output files
187+
if os.path.exists(os.path.join(testcase, 'output.nq')):
188+
output1 = 'output.nq'
189+
output_format1 = 'application/n-quads'
190+
else:
191+
error = 'true';
192+
193+
writer.writerow([testcase, title, description, spec, mapping_file,
194+
input_format1, input_format2, input_format3,
195+
output_format1, output_format2, output_format3,
196+
input1, input2, input3, output1, output2,
197+
output3, error])
198+
199+
if __name__ == '__main__':
200+
if len(sys.argv) != 2:
201+
print('Usage: ./make-metadata.py <IRI OF SPEC>')
202+
sys.exit(1)
203+
main(sys.argv[1])

0 commit comments

Comments
 (0)