September 2015
Beginner to intermediate
608 pages
13h 43m
English
After you run the preceding script, the articles will be unzipped to the directory data/reuters-sgml. Each .sgm file in the extract contains around 1,000 short articles that have been wrapped in XML-style tags using Standard Generalized Markup Language (SGML). Rather than write our own parser for the format, we can make use of the one already written in the Lucene text indexer.
(:import [org.apache.lucene.benchmark.utils ExtractReuters])
(defn sgml->txt [in-path out-path]
(let [in-file (clojure.java.io/file in-path)
out-file (clojure.java.io/file out-path)]
(.extract (ExtractReuters. in-file out-file))))Here we're making use of Clojure's Java interop to simply call the extract method on Lucene's ExtractReuters class. Each article ...
Read now
Unlock full access