Skip to content

Instantly share code, notes, and snippets.

@devn
Created March 16, 2010 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save devn/333921 to your computer and use it in GitHub Desktop.
Save devn/333921 to your computer and use it in GitHub Desktop.
(ns irc-parser
(:use clojure.contrib.duck-streams
clojure.contrib.str-utils))
(defn flatten
"Takes any nested combination of sequential things (lists, vectors,
etc.) and returns their contents as a single, flat sequence.
(flatten nil) returns nil."
[x]
(filter (complement sequential?)
(rest (tree-seq sequential? seq x))))
(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 (or nil? "")
(map #(rest (re-split #".*<.*>\s" %))
(read-lines (str logfile)))))
(def parsed (map flatten (map parse-irc-log (rest dates))))
;;(filter #(re-matches #".*zipmap.*") parsed)
(map #(re-find #"zipmap" (str %)) parsed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment