Re: Clojure example code snippets

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:47 PM, Andreas Kostler wrote: > Hi Armando, > I'm working on a Clojurej library for sentiment analysis which doesn't > contain everything you'd want for nlp but quite a nice subset of input > modules (plain text corpora, rss feeds, html, etc...), > tokenising/normalisin

Re: Clojure example code snippets

2011-05-19 Thread Andreas Kostler
Hi Armando, I'm working on a Clojurej library for sentiment analysis which doesn't contain everything you'd want for nlp but quite a nice subset of input modules (plain text corpora, rss feeds, html, etc...), tokenising/normalising filters (noise removal, porter stemmer, etc), distance/similarit

Re: Clojure example code snippets

2011-05-19 Thread Armando Blancas
Just in case I'll mention that Meikel's use of (with-open) will automatically close the reader. On May 19, 11:40 am, dokondr wrote: > On May 19, 6:52 pm, Meikel Brandmeyer wrote: > > > Hi, > > > something like the following should work. > > > (with-open [rdr (java.io.FileReader. "file.txt")] > >

Re: Clojure example code snippets

2011-05-19 Thread dokondr
On May 19, 6:52 pm, Meikel Brandmeyer wrote: > Hi, > > something like the following should work. > > (with-open [rdr (java.io.FileReader. "file.txt")] >   (doseq [line (line-seq rdr) >           word (.split line "\\s")] >     (when (.endsWith word "ing") >       (println word > > Sincerely >

Re: Clojure example code snippets

2011-05-19 Thread Benny Tsai
I think there can be multiple words on each line, so they have to be split into words first. Maybe something like: (ns example (:use [clojure.contrib.duck-streams :only (read-lines)])) (let [lines (read-lines "file.txt") words (mapcat #(.split % "\\s") lines) ing-words (filter (pa

Re: Clojure example code snippets

2011-05-19 Thread Jonathan Fischer Friberg
There is clojure.contrib.duck-streams/read-lines http://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/read-lines Then it's a matter of (filter (partial re-matches #".*ing") (read-lines "/path/to/file")) Jonathan On Thu, May 19, 2011 at 4:52 PM, Meikel Brandmeyer wrote: > Hi, >