Hello, I have sumbled upon a bug in code generating skos structure dump.
The python script assumes that keys consist of only single characters and therefore removing last character always yields its parent. This works fine most of the time, but several key subtrees contain bracketed text.
for k in obj.get("K", {}).get("S", []):
thek = ""
theuri = nn
for kk in k:
thek = thek + kk
lastk = f"{nn}(+{thek})"
kuri = f"http://iconclass.org/{quote(lastk)}"
nuri = f"http://iconclass.org/{quote(theuri)}"
F.write(
f"<{nuri}> <http://www.w3.org/2004/02/skos/core#narrower> <{kuri}> .\n"
)
F.write(
f"<{kuri}> <http://www.w3.org/2004/02/skos/core#broader> <{nuri}> .\n"
)
theuri = lastk
This results in an incorrect parent structure, for example items
https://iconclass.org/25D3(+2(...)).json
https://iconclass.org/49D352(...)(+52(GYROSCOPE)).json
have nonexistent parents.
A crude but working fix could be something like:
for k in obj.get("K", {}).get("S", []):
thek = ""
theuri = nn
openpar = false
for kk in k:
if not openpar and kk == "(":
openpar = True
continue
if openpar and kk == ")":
openpar = False
if openpar:
continue
thek = thek + kk
lastk = f"{nn}(+{thek})"
kuri = f"http://iconclass.org/{quote(lastk)}"
nuri = f"http://iconclass.org/{quote(theuri)}"
F.write(
f"<{nuri}> <http://www.w3.org/2004/02/skos/core#narrower> <{kuri}> .\n"
)
F.write(
f"<{kuri}> <http://www.w3.org/2004/02/skos/core#broader> <{nuri}> .\n"
)
theuri = lastk
This should work for any bracketed text which doesn't contain parenthesis.
Hello, I have sumbled upon a bug in code generating skos structure dump.
The python script assumes that keys consist of only single characters and therefore removing last character always yields its parent. This works fine most of the time, but several key subtrees contain bracketed text.
This results in an incorrect parent structure, for example items
https://iconclass.org/25D3(+2(...)).json
https://iconclass.org/49D352(...)(+52(GYROSCOPE)).json
have nonexistent parents.
A crude but working fix could be something like:
This should work for any bracketed text which doesn't contain parenthesis.