Created
December 19, 2008 03:04
-
-
Save francois/37856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Documents/work/twitter-word-cloud (master) $ clj | |
Clojure | |
user=> (ns twitter.reader | |
(:require [clojure.zip :as zip] | |
[clojure.xml :as xml] | |
[clojure.contrib.zip-filter :as zf]) | |
(:use clojure.contrib.zip-filter.xml | |
clojure.contrib.duck-streams)) | |
nil | |
twitter.reader=> | |
(def xml (zip/xml-zip (xml/parse "./twitter.xml"))) ;"http://twitter.com/statuses/public_timeline.xml" | |
#'twitter.reader/xml | |
twitter.reader=> | |
(def status (first (xml-> xml :status :text text))) | |
; status contains "@Epitymbidia Oh, wie amüsant. Nach Besäufnissen verspüre ich selten Lust nach Nahrung, eher nach Nikotin, Nikotin und ein wenig Nikotin." | |
#'twitter.reader/status | |
twitter.reader=> (def rdr (java.io.PushbackReader. (java.io.StringReader. status))) | |
#'twitter.reader/rdr | |
twitter.reader=> (distinct | |
(loop [words []] | |
(let [word (read rdr false nil)] | |
(if (word) | |
(recur (conj words word)) | |
words)))) | |
java.lang.ClassCastException: clojure.lang.PersistentList (NO_SOURCE_FILE:0) | |
twitter.reader=> (.printStackTrace *e) | |
java.lang.ClassCastException: clojure.lang.PersistentList (NO_SOURCE_FILE:0) | |
at clojure.lang.Compiler.eval(Compiler.java:4153) | |
at clojure.lang.Repl.main(Repl.java:93) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | |
at java.lang.reflect.Method.invoke(Method.java:585) | |
at jline.ConsoleRunner.main(ConsoleRunner.java:69) | |
Caused by: java.lang.ClassCastException: clojure.lang.PersistentList | |
at twitter.reader$eval__158.invoke(Unknown Source) | |
at clojure.lang.Compiler.eval(Compiler.java:4142) | |
... 6 more | |
nil | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment