Clojure:协议中没有方法的实现

ble*_*fly 5 lisp java rdf clojure

我试图在Clojure REPL中为RDF clj-plaza加载Clojure库,如下所示:

user=> (use 'plaza.rdf.core)
nil
Run Code Online (Sandbox Code Playgroud)

我有一个名为plaza的文件夹,以及一个名为rdf的子文件夹和文件core.clj,据我所知,Clojure REPL可以加载库.

现在,如果我这样做

user=> (alter-root-rdf-ns “http://www.example.org/”)
"http://www.example.org"
Run Code Online (Sandbox Code Playgroud)

而且,据我所知,core.clj库正在报告它应该.现在我做

(def e (document-to-model “http://www.snee.com/rdf/elvisimp.rdf” :xml))
java.lang.IllegalArgumentException: No implementation of method: :load-stream of protocol: #’plaza.rdf.core/RDFModel found for class: nil (NO_SOURCE_FILE:2)
Run Code Online (Sandbox Code Playgroud)

如果我尝试f.ex,我会得到相同的结果.

(make-triples [["http://triple1" "http://triple2" "http://triple3"]])
Run Code Online (Sandbox Code Playgroud)

在源代码(core.clj)中,协议RDFModel中有一个名为load-stream的方法

(defprotocol RDFModel
  "Operations for the manipulation of RDF"
  ....
  (load-stream [model stream format] "Load triples from a stream")
  ....
Run Code Online (Sandbox Code Playgroud)

并且实现了加载流

(defn document-to-model
  "Adds a set of triples read from a serialized document into a model"
  ([stream format]
    (load-stream *rdf-model* stream format)))
Run Code Online (Sandbox Code Playgroud)

我似乎无法确定这里有什么问题,在源代码中它似乎都加起来了.

Mic*_*zyk 3

(defn document-to-model ...)代码片段未实现load-stream;它实现了一个名为的函数,该函数使用一堆参数document-to-model进行调用,其中第一个参数需要是协议已扩展的类型(或者直接实现协议或相应的接口)。load-stream*rdf-model*RDFModel

clj-plazaRDFModel提供了, 在命名空间中的两个实现plaza.rdf.implementations.sesame(请参阅(deftype SesameModel ...源代码中的第 218 行)和plaza.rdf.implementations.jena(请参阅(deftype JenaModel ...源代码中的第 218 行)。require- 它们应该足以引入所述实现;那么你可以将它们与*rdf-model*适当类型的 s 一起使用。