Skip to content

Commit 39094db

Browse files
test-cases: add manifest
1 parent b56b79e commit 39094db

File tree

6 files changed

+4793
-2363
lines changed

6 files changed

+4793
-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

+355
Large diffs are not rendered by default.

test-cases/make-metadata.py

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

0 commit comments

Comments
 (0)