Split variables into multiple triples.

parent 48ac0bca
(ns scg-server.core
(:require [org.httpkit.server :as http]
[scg-server.rdf-ns :as rdf-ns]
[scg.core :as scg]
[scg.grammars.cooking :as cooking]
[cheshire.core :as cheshire]
......@@ -12,9 +13,11 @@
(defn handler [req]
(require '[scg.grammars.cooking :as cooking :reload true])
(require '[scg-server.rdf-ns :as rdf-ns :reload true])
(when (= (:request-method req) :post)
(let [first-parse-result (profile {}
(first (scg/run-grammar cooking/grammar (scg/sentence-kb (slurp (:body req))))))]
(clojure.pprint/pprint (rdf-ns/to-rdf (:fs first-parse-result)))
{:status 200
:headers {"content-type" "text/json"}
:body (cheshire/generate-string [(map (fn [t] (mapv str t))
......
(ns scg-server.rdf-ns
(:require [scg.core :as scg]))
(def ns {:type "https://www.w3.org/1999/02/22-rdf-syntax-ns#type"
:label "https://www.w3.org/2000/01/rdf-schema#label"
:type-variable "https://gitlab.informatik.uni-bremen.de/vanja/scg#variable"})
(defn expand-variables-to-entities [triples]
(into #{}
(mapcat (fn [t]
(into [(into [] (map (fn [i]
(if (scg/variable? i)
(:id i)
i)))
t)]
(mapcat (fn [i]
(when (scg/variable? i)
[[(:id i) (ns :type) (ns :type-variable)],
[(:id i) (ns :label) (:name i)]])))
t)))
triples))
(defn to-rdf [triples]
triples)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment