PCA RDL Verification
Posted: Fri Apr 19, 2013 9:56 am
In this topic I'll collect results of verification tests performed for PCA reference data library. Code snippets for .15926 Editor used to run tests will be published also.
Code: Select all
cois = find(type = part2.any.ClassOfIndividual)
expr = find(type=part2.any.ClassOfInformationRepresentation)
subont = (cois-expr)
nonroot = find(type = part2.Specialization, hasSubclass=out)
roots=subont-nonroot
show(id=roots)
Code: Select all
root = 'http://posccaesar.org/rdl/RDS398732751'
next = set([root])
all = set()
cycles = set()
while True:
next = find(type = part2.Specialization, hasSubclass=out, hasSuperclass=next)
if not next - all:
break
all |= next
found = next
show(id = found )
for item in found:
next = set([item])
all = set()
while True:
next = find(type = part2.Specialization, hasSubclass=out, hasSuperclass=next)
if item in next:
cycles.add(item)
if not next - all:
break
all |= next
show(id = cycles )
This test doesn't cover taxonomies not connected to "ISO 15926-4 THING" (see the test described above). It should be run again after taxonomy structure is unified."CHP 406.4 X 9.53 ASME B36.19M" http://posccaesar.org/rdl/RDS22601516315 which is declared subclass of itself by specialization relationship http://posccaesar.org/rdl/RDS2260812411
"SFT CLASS 200" http://posccaesar.org/rdl/RDS978526101 and "WATER" http://posccaesar.org/rdl/RDS1012769 are each declared subclass of another.
Code: Select all
show("all_prop", type=part2.Property)
Code: Select all
show("quant_prop", type=part2.PropertyQuantification, hasInput=out, hasResult=find(type=part2.RealNumber))
Code: Select all
show("scaled_prop", hasInput=out, id=find(type=part2.Classification, hasClassifier=find(type=part2.Scale), hasClassified=out==check(type=part2.PropertyQuantification, hasResult=find(type=part2.RealNumber))))
Code: Select all
show('non_quant', id=all_prop - quant_prop)
Code: Select all
show('non_scaled', id=quant_prop - scaled_prop)
Code: Select all
show(type=part2.Specialization, hasSubclass=find(type=part2.any.ClassOfClassOfIndividual), hasSuperclass=find(type=part2.any.ClassOfRelationship))
Code: Select all
show(type=part2.Specialization, hasSubclass=find(type=part2.any.ClassOfRelationship), hasSuperclass=find(type=part2.any.ClassOfClassOfIndividual))
Code: Select all
alls = find(type = part2.any.Thing)
expr = find(type=part2.any.ClassOfInformationRepresentation)
rels = find(type=part2.any.Relationship)
corels = find(type=part2.any.ClassOfRelationship)
cocorels = find(type=part2.any.ClassOfClassOfRelationship)
props = find(type=part2.Property)
numbs = find(type=part2.any.ArithmeticNumber)
ranges= find(type=part2.PropertyRange)
subont = (alls-expr-rels-corels-props-numbs-ranges-cocorels)
show('nodef', id=subont, hasDefinition=void)
Code: Select all
import iso15926.kb as kb
from graphlib import compact_uri, expand_uri, curi_head, curi_tail
def GetClassified(uri):
result = set()
curi = compact_uri(uri)
name = curi_tail(curi)
entry = kb.part2_itself["part2:" + name]
classified = entry.get("classified")
if classified:
for v in classified:
entry = kb.part2_itself[v]
result.add(expand_uri(curi_head(curi)) + entry['name'])
return result
def GetSubtypes(uriset):
result = set()
for uri in uriset:
name = uri[max(uri.rfind('#'), uri.rfind('/'))+1:]
if isinstance(getattr(part2.any, name).uri, set):
subtypes = getattr(part2.any, name).uri- set([getattr(part2, name).uri])
result |= subtypes
return result
all_classifiers=find(type=part2.Classification, hasClassifier=out)
cls=find(type=part2.Classification, hasClassifier=out==find(type=part2.Class))
esocs=find(type=part2.Classification, hasClassifier=out==find(type=part2.EnumeratedSetOfClass))
propr=find(type=part2.Classification, hasClassifier=out==find(type=part2.PropertyRange))
spds=find(type=part2.Classification, hasClassifier=out==find(type=part2.SinglePropertyDimension))
scls=find(type=part2.Classification, hasClassifier=out==find(type=part2.Scale))
docds= find(type=part2.Classification, hasClassifier=out==find(type=part2.DocumentDefinition))
rfrms= find(type=part2.Classification, hasClassifier=out==find(type=part2.RepresentationForm))
classifiers= all_classifiers-esocs-propr-scls-cls-spds-docds-rfrms
show(id=classifiers)
mist =set()
counter=0
for classifier in classifiers:
counter+=1
print(counter)
classifier_type=find(id=classifier, type=out).pop()
classified_type_must=GetClassified(classifier_type)
classified_types_must= GetSubtypes(classified_type_must)
classified_types_must |= classified_type_must
classified_types=find(id=find(type=part2.Classification, hasClassifier=classifier, hasClassified=out), type=out)
if classified_types&classified_types_must != classified_types:
mist.add(classifier)
show(id=mist)
Code: Select all
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX RDL: <http://posccaesar.org/rdl/>
SELECT ?y
WHERE { GRAPH <http://irm.dnv.com/ontologies/iring.map> {
?x RDL:rdsWipEquivalent ?y .}
OPTIONAL { ?y ?p ?z } .
FILTER (!bound(?z)) }