Compare commits
5 commits
f8ca3140c7
...
952a2ce4da
Author | SHA1 | Date | |
---|---|---|---|
952a2ce4da | |||
36a3e73c3c | |||
61b2e54ded | |||
9af4cd0921 | |||
5c6033b5c8 |
7 changed files with 106 additions and 7 deletions
|
@ -23,6 +23,6 @@
|
|||
[org.clojars.quoll/raphael "0.1.6"]
|
||||
[instaparse "1.4.12"]]
|
||||
:main ^:skip-aot org.domaindrivenarchitecture.activity-pub-poc.core
|
||||
:profiles {:test {:test-paths ["src/test/cljc"]
|
||||
:profiles {:test {:test-paths ["src/test/clj"]
|
||||
:resource-paths ["src/test/resources"]
|
||||
:dependencies [[dda/data-test "0.1.1"]]}})
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
(ns org.domaindrivenarchitecture.activity-pub-poc.common)
|
||||
|
||||
(def resource-path "src/main/resources/")
|
||||
|
||||
(def activitystreams-ttl (str resource-path "activitystreams_2.0_owl.ttl"))
|
||||
(def rdf-schema-ttl (str resource-path "rdf_schema_1.1.ttl"))
|
||||
(def rdf-syntax-ttl (str resource-path "rdf_syntax_ns_22.ttl"))
|
|
@ -2,6 +2,7 @@
|
|||
(:require [lambdaisland.souk.activitypub :as ap]
|
||||
[lambdaisland.souk.json-ld :as ld]
|
||||
[quoll.raphael.core :refer [parse]]
|
||||
[org.domaindrivenarchitecture.activity-pub-poc.common :as cm]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.inspector :as ins]
|
||||
[hato.client :as hato]
|
||||
|
@ -19,15 +20,13 @@
|
|||
|
||||
(def team (ap/GET team-url))
|
||||
|
||||
(def resource-path "src/main/resources/")
|
||||
|
||||
(def activitystreams-ttl (str resource-path "activitystreams_2.0_owl.ttl"))
|
||||
(def rdf-schema-ttl (str resource-path "rdf_schema_1.1.ttl"))
|
||||
(def rdf-syntax-ttl (str resource-path "rdf_syntax_ns_22.ttl"))
|
||||
(def parsed-rdf-syntax (parse (slurp cm/activitystreams-ttl)))
|
||||
|
||||
|
||||
(def parsed-rdf-syntax (parse (slurp rdf-syntax-ttl)))
|
||||
|
||||
; ToDo
|
||||
; Prädikat das langString parsen/validieren kann, evtl auch für xsd:string
|
||||
; Prädikat für Name und Person ausformulieren
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
(ns org.domaindrivenarchitecture.activity-pub-poc.parser
|
||||
(:require [org.domaindrivenarchitecture.activity-pub-poc.common :as cm]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(def activitystreams-turtle (slurp cm/activitystreams-ttl))
|
||||
|
||||
; pre-format
|
||||
(defn delete-comments-and-newlines [resource-file]
|
||||
(apply str
|
||||
(remove
|
||||
#(or (re-matches #"^#.*" %) (re-matches #"" %))
|
||||
(str/split-lines
|
||||
(slurp resource-file)))))
|
||||
|
||||
; find definitions
|
||||
(defn find-definitions [string-input]
|
||||
(str/split string-input #" \."))
|
||||
|
||||
|
||||
; make list of vectors/map from well known input-string
|
||||
; distinguish iri,keyword and prefix
|
||||
; if keyword make a triple
|
||||
; if iri or prefix make a map:
|
||||
;
|
||||
;{{prefix:xyz prefix:zab}
|
||||
; [{prefix:bla "possibly string"@someKeyword}
|
||||
; {prefix:foo prefix:orSthElse}
|
||||
; {prefix:range ; range muss sich liebevoll angeschaut werden
|
||||
; [
|
||||
; prefix:Type
|
||||
; prefix:Type
|
||||
;
|
||||
; ]}]}
|
||||
(defn to-map-from-def [string-input])
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
(ns org.domaindrivenarchitecture.activity-pub-poc.parser-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[org.domaindrivenarchitecture.activity-pub-poc.parser :as sut]))
|
||||
|
||||
|
||||
(def processed (slurp "src/test/resources/deleted_comments_minimal.ttl"))
|
||||
(def expected-definitions ["@prefix : <http://www.w3.org/ns/activitystreams#>"
|
||||
"@prefix as: <http://www.w3.org/ns/activitystreams#>"
|
||||
"@prefix owl: <http://www.w3.org/2002/07/owl#>"
|
||||
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
|
||||
"@prefix xml: <http://www.w3.org/XML/1998/namespace>"
|
||||
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#>"
|
||||
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
|
||||
"@base <http://www.w3.org/ns/activitystreams>"
|
||||
"<http://www.w3.org/ns/activitystreams#> a owl:Ontology ; rdfs:comment \"Extended Activity Streams 2.0 Vocabulary\"@en ; rdfs:label \"Activity Streams 2.0\"@en ; owl:imports <http://www.w3.org/ns/prov#>"
|
||||
"rdf:langString a rdfs:Datatype"
|
||||
"xsd:duration a rdfs:Datatype"])
|
||||
|
||||
(deftest remove-comments-test
|
||||
(is
|
||||
(= processed
|
||||
(sut/delete-comments-and-newlines "src/test/resources/minimal.ttl"))))
|
||||
|
||||
((deftest find-definitions-test
|
||||
(testing "Finding definitons"
|
||||
(is (= expected-definitions
|
||||
(sut/find-definitions processed))))))
|
1
src/test/resources/deleted_comments_minimal.ttl
Normal file
1
src/test/resources/deleted_comments_minimal.ttl
Normal file
|
@ -0,0 +1 @@
|
|||
@prefix : <http://www.w3.org/ns/activitystreams#> .@prefix as: <http://www.w3.org/ns/activitystreams#> .@prefix owl: <http://www.w3.org/2002/07/owl#> .@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .@prefix xml: <http://www.w3.org/XML/1998/namespace> .@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@base <http://www.w3.org/ns/activitystreams> .<http://www.w3.org/ns/activitystreams#> a owl:Ontology ; rdfs:comment "Extended Activity Streams 2.0 Vocabulary"@en ; rdfs:label "Activity Streams 2.0"@en ; owl:imports <http://www.w3.org/ns/prov#> .rdf:langString a rdfs:Datatype .xsd:duration a rdfs:Datatype .
|
30
src/test/resources/minimal.ttl
Normal file
30
src/test/resources/minimal.ttl
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Downloaded from https://www.w3.org/ns/activitystreams-owl
|
||||
|
||||
@prefix : <http://www.w3.org/ns/activitystreams#> .
|
||||
@prefix as: <http://www.w3.org/ns/activitystreams#> .
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@base <http://www.w3.org/ns/activitystreams> .
|
||||
|
||||
<http://www.w3.org/ns/activitystreams#> a owl:Ontology ;
|
||||
rdfs:comment "Extended Activity Streams 2.0 Vocabulary"@en ;
|
||||
rdfs:label "Activity Streams 2.0"@en ;
|
||||
owl:imports <http://www.w3.org/ns/prov#> .
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# Datatypes
|
||||
#
|
||||
#################################################################
|
||||
|
||||
rdf:langString a rdfs:Datatype .
|
||||
xsd:duration a rdfs:Datatype .
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# Object Properties
|
||||
#
|
||||
#################################################################
|
Loading…
Reference in a new issue