Skip to content

Instantly share code, notes, and snippets.

@jtoy
Created October 5, 2012 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtoy/625d3b1666a949bb1baf to your computer and use it in GitHub Desktop.
Save jtoy/625d3b1666a949bb1baf to your computer and use it in GitHub Desktop.
(defn train_classifier []
(with-open [rdr (reader "data/sentiment_training.txt")]
(doseq [line (line-seq rdr)]
(let [tweet ( first (clojure.string/split line #"\t"))
type (last (clojure.string/split line #"\t"))]
(.train! classifier tweet (type2class type) ))
)))
#convert above method to use resource
(defn train_classifier []
(with-open [rdr (clojure.java.io/make-input-stream (clojure.java.io/resource "sentiment_training.txt"))]
(doseq [line (line-seq rdr)]
(let [tweet ( first (clojure.string/split line #"\t"))
type (last (clojure.string/split line #"\t"))]
(.train! classifier tweet (type2class type) ))
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment