Created
March 8, 2019 09:50
-
-
Save mathiasp/b00c5d9b5052d74aa5acff674393848e to your computer and use it in GitHub Desktop.
How do I import gist in tawny-owl?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns csd.gist | |
(:require [tawny | |
[owl :as owl] | |
[read :as rd] | |
[reasoner :as rs] | |
[lookup :as lk]]) | |
(:import | |
(org.semanticweb.owlapi.model | |
OWLOntologyID))) | |
;;(alter-var-root #'tawny.read/*noisy-intern* (constantly true ) ) | |
;; No use importing Core, that will not import everything else. | |
;; (rd/defread gistCore | |
;; ;; something that the OWL API can interpret. This includes a stream, so | |
;; ;; it's totally generic. | |
;; :location (iri (clojure.java.io/resource "gistCore8.0.0.owl")) | |
;; ;; the prefix that you want to use in this case | |
;; :prefix "gist:" | |
;; ;; normally only things from this IRI will be imported | |
;; :iri "http://ontologies.semanticarts.com/o/gistCore" | |
;; :filter | |
;; (clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
;; for importing many files with the same namespace I need to set filter to the common namespace, | |
;; otherwise nothing gets imported (it will filter by file name/iri by default | |
(rd/defread gistCategory | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistCategory8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistCategory" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistContent | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistContent8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistContent" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistAddress | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistAddress8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistAddress" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistMagnitude | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistMagnitude8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistMagnitude" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistOrganization | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistOrganization8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistOrganization" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistUnitDim | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistUnitDim8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistUnitDim" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistAgreement | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistAgreement8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistAgreement" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(rd/defread gistTemporalRelation | |
;; something that the OWL API can interpret. This includes a stream, so | |
;; it's totally generic. | |
:location (owl/iri (clojure.java.io/resource "gistTemporalRelation8.0.0.owl")) | |
;; the prefix that you want to use in this case | |
:prefix "gist" | |
;; normally only things from this IRI will be imported | |
:iri "http://ontologies.semanticarts.com/o/gistTemporalRelation" | |
:filter | |
(clojure.core/partial tawny.read/iri-starts-with-filter "http://ontologies.semanticarts.com/gist")) | |
(defn import-gist [] | |
(owl/owl-import gistCategory) | |
(owl/owl-import gistContent) | |
(owl/owl-import gistAddress) | |
(owl/owl-import gistMagnitude) | |
(owl/owl-import gistOrganization) | |
(owl/owl-import gistUnitDim) | |
(owl/owl-import gistAgreement) | |
(owl/owl-import gistTemporalRelation)) | |
(import-gist) | |
(defn makeCategory | |
"Create a gist:category with individuals of that class" | |
[categoryClass individuals] | |
(let [cat (owl/owl-class categoryClass :super Category)] | |
(rd/intern-entity *ns* cat) | |
(doseq [i individuals] | |
(rd/intern-entity | |
*ns* | |
(owl/individual (first i) :type cat :comment "find old flag in rdfs:label" :label (second i) ))))) | |
(makeCategory "OrderCategory" [["MobileProductsAllowed" "A"] | |
["MobileAndHardwareProductsAllowed" "B"]]) | |
;; TODO: add better api like this: | |
;; (makeHierarchy "MyCat" | |
;; {:_topCat {:label "tc" | |
;; :subcats {:_subCat1 {:label "s1"} | |
;; :_subCat2 {:label "s2" | |
;; :subcats {:_subCat21 {:label "s21"} | |
;; :_subCat22 {:label "s22"}}}}}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment