gpt4 book ai didi

java - 实现 Clojure 库

转载 作者:行者123 更新时间:2023-12-01 13:06:12 25 4
gpt4 key购买 nike

我一直在尝试实现 https://github.com/herdrick/hierarchical-text/blob/master/src/hierarchical-classifier.clj*directory-string* 中的路径更改为包含文本文件的保管箱。在 org.apache.commons.io.FileUtils/listFiles 的 REPL 中发出编译器异常,给出 java.lang.ClassNotFoundException

除了我添加的链接中的源代码

(def clustered (cluster *txt-files*))

其后有以下注释:要查看此树的可视化,请确保您拥有 Visualize/目录。将 protovis.clj 中的 protovis-json-file 更改为 Visualize/protovis-3.2/flare.js 的完整路径然后:

(def json (.replace (pof->js clustered 3) "/path/to/documents/" ""))
;;I have left the path to documents here for generality, the path is fully specified in my text editor
;;removing the dir path to each file keeps everything much cleaner.
(write-protovis-file json)

聚集中的*txt-files*包括

(def *txt-files* (seq (org.apache.commons.io.FileUtils/listFiles (new java.io.File *directory-string*) nil false)))

这是导致编译器异常的部分。

我不知道如何摆脱 org.apache 的编译器异常...此外,“要查看此树的可视化,请确保您有 Visualize/目录。更改 protovis-json -file 在 protovis.clj 中作为 Visual/protovis-3.2/flare.js 的完整路径”和“删除每个文件的目录路径使所有内容更加清晰”不是我很清楚。有人可以帮助阐明这个实现中发生了什么吗?

最佳答案

您需要将 apache.commons.io 的 mvn 依赖项添加到 project.clj 中的 :dependencies vector :

[org.apache.commons/commons-io“1.3.2”]

此外,此代码是一个概念证明(可以制作成一个库),而不是一个库,正如它在文件中具有硬编码路径以及文件加载时的副作用所显示的那样关于那些硬编码值。

关于java - 实现 Clojure 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23247234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com