Ensure that there are no definitions in the wrong ontology

This uses a 'magic property' called 'definesStatements' that is only available in TopBraid Composer. This should probably migrate to the hygiene tests suite. It's here for now for my own use.

# Find all URIs for Classes, Object, Datatype and Annotation Properties that are defined
# in a given ontology whose namespace does not match the current ontology.
# The definition should be in an imported ontology.
SELECT ?s ?p ?o
BIND ("https://spec.edmcouncil.org/fibo/LOAN/LoanContracts/LoanHMDA/" as ?ontStr)
BIND (uri(?ontology) as ?ontURI)
?ontology tops:definesStatements (?s ?p ?o) .
FILTER (?p in (rdf:type))
FILTER (?o in (owl:Class, owl:ObjectProperty, owl:DatatypeProperty, owl:AnnotationProperty))
FILTER (!(strstarts(str(?s), ?ontStr)))

Preparing to Review Definitions and Other Annotations

Run the following SPARQL query and export it as a spreadsheet.  With a bit of manual reformatting, it is in a convenient form for reviewing definitions and other annotations.  It also is helpful to spot missing definitions.  For example, the following file is such a spreadsheet reflecting the loan ontology as of 2016-01-4:  


TODO: generalize so that the loans URL is not hard coded, making it useful for other FCTs.

# Returns every resource of one or more specified types in the loan namespace along with their selected annotations. 

# Returns every resource of one or more specified types in the loan namespace along with their selected annotations. 
SELECT ?Resource ?Type ?Def ?ExpNote ?EdNote ?UseNote ?NormRef ?Comment
WHERE { ?Resource rdf:type ?Type .
FILTER(?Type in (owl:Class, owl:DatatypeProperty,owl:ObjectProperty ))
OPTIONAL { ?Resource skos:definition ?Def. }
OPTIONAL { ?Resource rdfs:comment ?Comment. }
OPTIONAL { ?Resource skos:editorialNote ?EdNote. }
OPTIONAL { ?Resource sm:normativeReference ?NormRef. }
OPTIONAL { ?Resource fibo-fnd-utl-av:usageNote ?UseNote. }
OPTIONAL { ?Resource fibo-fnd-utl-av:explanatoryNote ?ExpNote. }
#FILTER(STRSTARTS(STR(?Resource), # use this to get URIs in the loans namespace
# "http://spec.edmcouncil.org/fibo/LOAN/LoanContracts/LoanCore/") )
#FILTER(!(STRSTARTS(STR(?Resource), # use this to avoid URIs prefixed with fibo-
# "http://spec.edmcouncil.org/fibo/LOAN/LoanContracts/LoanCore/fibo-") ))
# FILTER(STRSTARTS(STR(?Resource), # use this to get URIs prefixed with lnu:
# "http://spec.edmcouncil.org/fibo/LOAN/LoanContracts/LoanUpperTemp/") )
FILTER(!(STRSTARTS(STR(?Resource), # use this to get things not in loans namespace
"http://spec.edmcouncil.org/fibo/LOAN/LoanContracts/LoanCore/")) )
FILTER(!(STRSTARTS(STR(?Resource), # ignore things in owl namespace
"http://www.w3.org/2002/07/owl#") ))
ORDER BY ?Type ?Resource

Usage instructions:

  1. AllFibo: uncomment out the last two filter statements
    NEXT: remove the import statement so only stuff in loans ontology is left 
  2. UsedFromFibo: Run same query as for AllFibo (the definitions will be missing)
  3. AddToFibo: use only the 3rd filter
  4. Loans: use only the first two filters

Then take a prior version of a loansannotations spreadsheet, remove the existing contents and bring in the new content from the new .txt files exported by TBC.

Find uses of rdfs:comment, it should not be used at all. Probably have it be an ASK query. 

SELECT ?Resource ?Type ?Comment
WHERE { ?Resource rdf:type ?Type .
?Resource rdfs:comment ?Comment.
FILTER(?Type in (owl:Class, owl:DatatypeProperty,owl:ObjectProperty ))
FILTER(!(STRSTARTS(STR(?Resource), # ignore things in owl namespace
"http://www.w3.org/2002/07/owl#") ))
FILTER(!(STRSTARTS(STR(?Resource), # ignore things in skos namespace
"http://www.w3.org/2004/02/skos/core#") ))
ORDER BY ?Type ?Resource

Concepts that are not specific to loans.

I did a thorough look through the loans ontology and considered which things are not loan-specific, and thus eventually should be somewhere else in FIBO.  

The convention I am using is to prefix the URI of all non- loan-specific  concepts with: “fibo-“.  I grouped some of them by topic (using skoc:editorialNote), to give an idea where they should go. In some cases, I was pretty sure where they would go, so I gave a more specific prefix like: “fibo-alx” which means the concept belongs in the ontology: http://spec.edmcouncil.org/fibo/FND/Utilities/Analytics/ or fibo-fnd-utl-alx, which is the standard prefix for this.

For example:

 This spreadsheet  below was generated from SPARQL, and has all the annotations for all the classes and properties in the ontology, but for convenience, I have a filter on the leftmost column so only the ones prefixed with “fibo-“ show up. All of this will be updated in due course.