Skip to content

Commit 8340453

Browse files
committed
merge inverses in this new world
1 parent 55e36ff commit 8340453

10 files changed

+11159
-5475
lines changed

cromulent/data/crm_vocab.tsv

Lines changed: 33 additions & 33 deletions
Large diffs are not rendered by default.

cromulent/data/linked-art.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,16 +1363,17 @@
13631363
},
13641364
"current_or_former_residence": {
13651365
"@id": "crm:P74_has_current_or_former_residence",
1366-
"@type": "@id"
1366+
"@type": "@id",
1367+
"@container": "@set"
13671368
},
13681369
"current_or_former_residence_of": {
13691370
"@id": "crm:P74i_is_current_or_former_residence_of",
1370-
"@type": "@id"
1371+
"@type": "@id",
1372+
"@container": "@set"
13711373
},
13721374
"possesses": {
13731375
"@id": "crm:P75_possesses",
1374-
"@type": "@id",
1375-
"@container": "@set"
1376+
"@type": "@id"
13761377
},
13771378
"possessed_by": {
13781379
"@id": "crm:P75i_is_possessed_by",
@@ -1499,13 +1500,14 @@
14991500
"@id": "crm:P100_was_death_of",
15001501
"@type": "@id"
15011502
},
1502-
"died_in": {
1503+
"died": {
15031504
"@id": "crm:P100i_died_in",
15041505
"@type": "@id"
15051506
},
1506-
"as_general_use": {
1507+
"general_use": {
15071508
"@id": "crm:P101_had_as_general_use",
1508-
"@type": "@id"
1509+
"@type": "@id",
1510+
"@container": "@set"
15091511
},
15101512
"use_of": {
15111513
"@id": "crm:P101i_was_use_of",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'data/cidoc-extension.json', 'data/crm-profile.json']
1616
},
1717
test_suite="tests",
18-
version = '0.9.13',
18+
version = '0.10.1',
1919
description = 'A library for mapping CIDOC-CRM classes to Python objects',
2020
author = 'Rob Sanderson',
2121
author_email = '[email protected]',

utils/data/cidoc.xml

Lines changed: 5644 additions & 5400 deletions
Large diffs are not rendered by default.

utils/data/linkedart_crm_enhancements.xml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,36 +113,12 @@ Instances of SP6 Declarative Places may be used to approximate instances of E53
113113
</rdf:Property>
114114

115115

116-
<!-- This is truly, truly horrible :( -->
116+
<!-- Proxies are very magical -->
117117

118118
<rdfs:Class rdf:about="http://www.openarchives.org/ore/terms/Proxy">
119119
<rdfs:label xml:lang="en">Proxy</rdfs:label>
120120
<rdfs:comment>Proxy for a resource within the context of an Aggregation.</rdfs:comment>
121-
<rdfs:subClassOf rdf:resource="E36_Visual_Item"/>
122-
<!--
123-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/Payment"/>
124-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/PropertyInterest"/>
125-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/Relationship"/>
126-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/Name"/>
127-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/EndingActivity"/>
128-
<rdfs:subClassOf rdf:resource="https://linked.art/ns/terms/TransformingActivity"/>
129-
<rdfs:subClassOf rdf:resource="E8_Acquisition"/>
130-
<rdfs:subClassOf rdf:resource="E13_Attribute_Assignment"/>
131-
<rdfs:subClassOf rdf:resource="E65_Creation"/>
132-
<rdfs:subClassOf rdf:resource="E66_Formation"/>
133-
<rdfs:subClassOf rdf:resource="E74_Group"/>
134-
<rdfs:subClassOf rdf:resource="E42_Identifier"/>
135-
<rdfs:subClassOf rdf:resource="E56_Language"/>
136-
<rdfs:subClassOf rdf:resource="E22_Man-Made_Object"/>
137-
<rdfs:subClassOf rdf:resource="E57_Material"/>
138-
<rdfs:subClassOf rdf:resource="E97_Monetary_Amount"/>
139-
<rdfs:subClassOf rdf:resource="E21_Person"/>
140-
<rdfs:subClassOf rdf:resource="E53_Place"/>
141-
<rdfs:subClassOf rdf:resource="E12_Production"/>
142-
<rdfs:subClassOf rdf:resource="E10_Transfer_of_Custody"/>
143-
<rdfs:subClassOf rdf:resource="http://www.openarchives.org/ore/terms/Aggregation"/>
144-
-->
145-
121+
<rdfs:subClassOf rdf:resource="E71_Man-Made_Thing"/>
146122
</rdfs:Class>
147123

148124
<rdf:Property rdf:about="http://www.openarchives.org/ore/terms/proxyIn">
@@ -159,6 +135,9 @@ Instances of SP6 Declarative Places may be used to approximate instances of E53
159135
<rdfs:range rdf:resource="E1_CRM_Entity"/>
160136
</rdf:Property>
161137

138+
139+
140+
162141
<!-- Similarity of resources -->
163142
<!-- E1: owl:sameAs, skos:exactMatch, skos:closeMatch, dct:relation -->
164143

utils/old/cidoc.xml

Lines changed: 5416 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

utils/old/merge_inverses.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from lxml import etree
2+
import codecs
3+
4+
NS = {'rdf':"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
5+
'xsd':"http://www.w3.org/2001/XMLSchema#",
6+
'rdfs':"http://www.w3.org/2000/01/rdf-schema#",
7+
'dcterms':"http://purl.org/dc/terms/",
8+
'owl':"http://www.w3.org/2002/07/owl#",
9+
'crm':"http://www.cidoc-crm.org/cidoc-crm/",
10+
'xml': "http://www.w3.org/XML/1998/namespace"
11+
}
12+
13+
fh = file('data/inverses.xml')
14+
data = fh.read()
15+
fh.close()
16+
dom = etree.XML(data)
17+
18+
inverses = {}
19+
props = dom.xpath("//rdf:Property",namespaces=NS)
20+
for p in props:
21+
name = p.xpath('@rdf:about', namespaces=NS)[0]
22+
try:
23+
inv = p.xpath('./owl:inverseOf/@rdf:resource', namespaces=NS)[0]
24+
inverses[name] = inv
25+
except:
26+
pass
27+
28+
fh = file('data/cidoc.xml')
29+
data = fh.read()
30+
fh.close()
31+
dom = etree.XML(data)
32+
33+
# Now insert them into the right blocks
34+
35+
for (n,i) in inverses.items():
36+
try:
37+
elem = dom.xpath('//rdf:Property[@rdf:about="%s"]' % n, namespaces=NS)[0]
38+
if not elem.xpath('./owl:inverseOf', namespaces=NS):
39+
inv = etree.SubElement(elem, "{http://www.w3.org/2002/07/owl#}inverseOf")
40+
inv.set("{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource", i)
41+
inv.tail = "\n"
42+
except:
43+
print "Could not find property %s" % n
44+
45+
46+
# And rewrite the file
47+
48+
fh = file('data/cidoc_inversed.xml', 'w')
49+
fh.write(etree.tostring(dom, pretty_print=True))
50+
fh.close()

utils/process_ontologies.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@
4444
fh.close()
4545
profile_flags = json.loads(data)
4646

47-
fh = open('data/inverses.xml')
48-
data = fh.read()
49-
fh.close()
50-
invdom = etree.XML(data)
51-
5247
stuff = []
5348
propXHash = {}
5449
classXHash = {}
@@ -157,9 +152,7 @@ def process_props(dom):
157152
else:
158153
subProp = ""
159154

160-
inverse = dom.xpath('./owl:inverseOf/@rdf:resource', namespaces=NS)
161-
if not inverse:
162-
inverse = invdom.xpath('//rdf:Property[@rdf:about="%s"]/owl:inverseOf/@rdf:resource' % name, namespaces=NS)
155+
inverse = p.xpath('./owl:inverseOf/@rdf:resource', namespaces=NS)
163156
if inverse:
164157
inverse = inverse[0]
165158
else:

0 commit comments

Comments
 (0)