尽管添加了 desired dependency到我的project.clj 文件,
(defproject word-tree "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"]
[clojure-opennlp "0.5.0"] ; <----------------------here
[reagent "0.8.1"]]
...
我无法访问依赖项提供的功能。
在我的一个文件中引用命名空间后,
(ns word-tree.suffix-tree
(:require [clojure.string :as str]
[opennlp.nlp :as nlp])) ; <-----this is the namespace of the dependency
我收到此错误:
No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"
最奇怪的部分是当我运行 lein deps :tree
时依赖关系出现了!
$ lein deps :tree
...
[cider/piggieback "0.4.1" :scope "test"]
[cljfmt "0.5.7"]
[rewrite-clj "0.5.2"]
[rewrite-cljs "0.4.3"]
[clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
[clojure-opennlp "0.5.0"] <------------------------------------------------here!!!
[instaparse "1.4.9"]
[org.apache.opennlp/opennlp-tools "1.9.0"]
[figwheel-sidecar "0.5.19" :scope "test"]
...
对于我的项目,我真的想使用这个依赖项,但它不起作用。任何建议都将受到欢迎。谢谢。
最佳答案
在我看来,问题在于该库仅适用于 JVM 上的 Clojure,而您正尝试在 ClojureScript 项目上使用它。
No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"
编译器尝试查找 ClojureScript 代码(扩展名 .cljs
)或与 Clojure 和 ClojureScript(扩展名 .cljc
)兼容或纯 JavaScript,但没有找到。
关于clojure - 使用 lein 将依赖项添加到 clojure 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58985920/