Skip to content

Instantly share code, notes, and snippets.

@devn
Created March 16, 2010 21:47
Show Gist options
  • Select an option

  • Save devn/334570 to your computer and use it in GitHub Desktop.

Select an option

Save devn/334570 to your computer and use it in GitHub Desktop.
(ns irc-parser
(:use clojure.contrib.duck-streams
clojure.contrib.str-utils
clojure.contrib.seq-utils))
(def dates (file-seq (java.io.File. "/Users/defn/git/clojure-irc")))
(defn parse-irc-log
"Gets rid of all the junk in the irc log groupings and gives us a list of strings which is the content found in the channel."
[logfile]
(remove empty?
(map #((rest second (re-find #"^[^<]*<[^>]*>\s(.*)$" %)))
(line-seq (reader logfile)))))
(def parsed (map parse-irc-log (rest dates)))
(defn find-lines
[text]
(remove empty? (map
(fn [d] (filter #(< 0 (.indexOf % text)) d))
parsed)))
;(time (def zm (map (fn [l] (map #(re-find #"zipmap" %) l)) parsed)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment