Question

I have been trying to implement https://github.com/herdrick/hierarchical-text/blob/master/src/hierarchical-classifier.clj while changing the path in *directory-string* to my dropbox containing text-files. A compiler exception was issued in the REPL for org.apache.commons.io.FileUtils/listFiles giving a java.lang.ClassNotFoundException.

In addition to the source code in the link I've added

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

which had the following note after it: To see this tree visualized, make sure you have the visualize/ dir. Change protovis-json-file in protovis.clj to be the full path to your visualize/protovis-3.2/flare.js Then:

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

The *txt-files* in clustered include

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

which is the piece causing the compiler exception.

I'm not sure how to get rid of the compiler exception for the org.apache... Additionally the lines "To see this tree visualized, make sure you have the visualize/ dir. Change protovis-json-file in protovis.clj to be the full path to your visualize/protovis-3.2/flare.js" and "removing the dir path to each file keeps everything much cleaner" are not clear to me. Could somebody help to elucidate what is going on in this implementation?

Was it helpful?

Solution

You will need to add the mvn dependency for apache.commons.io to your :dependencies vector in the project.clj:

[org.apache.commons/commons-io "1.3.2"]

Also, this code is a proof of concept (that could be made into a library), not a library, as displayed by the fact that it has hard coded paths in the file, and side effects at file load time that depend on those hard coded values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top