Compare commits

...

5 commits

Author SHA1 Message Date
952a2ce4da Test our parser 2023-06-21 14:08:14 +02:00
36a3e73c3c WIP: Implement simplistic converter for our purpose 2023-06-21 14:07:36 +02:00
61b2e54ded Use common ns for paths 2023-06-21 14:06:51 +02:00
9af4cd0921 Move paths to common.clj 2023-06-21 14:05:49 +02:00
5c6033b5c8 Update test paths 2023-06-21 14:03:59 +02:00
7 changed files with 106 additions and 7 deletions

View file

@ -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"]]}})

View file

@ -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"))

View file

@ -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

View file

@ -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])

View file

@ -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))))))

View 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 .

View 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
#
#################################################################