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
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
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")]
> >
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
>
Oops. Just noticed that the original was not quoted in either of my
previous emails, which makes things really confusing. My first reply (the
one using read-lines) was an extension of odyssomay/Jonathan's code, and the
second (with reader) was an extension of Meikel's code. Sorry guys.
--
Y
I think line-seq needs a java.io.BufferedReader instead of a
java.io.FileReader. clojure.java.io has a reader function that constructs a
java.io.BufferedReader from a filename, so this worked for me:
(ns example
(:use [clojure.java.io :only (reader)]))
(with-open [rdr (reader "file.txt")]
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
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,
>
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
Meikel
--
You received this message because you are subscribed to
Hi!
I am thinking about using Clojure for distributed NLP.
Being an absolute newbie in Clojure I look for nice expressive code
snippets.
For example, I need an easy way to read text files such as in the
following Python code:
>>> for line in open("file.txt"):
... for word in line.split():
... if w
10 matches
Mail list logo