I've got a decent-sized corpus of tweets, organized by hashtag, in a 
CouchDB db. I'm doing some initial explorations of my data, and was curious 
about which hashtags show up together in tweets. I want to do a NSA-style 
"hops" kind of algorithm--get all the hashtags that show up in the same 
tweets as hashtags that show up in the same tweets as hashtags that show up 
in the same tweets as my "target hashtag", to an arbitrary depth. I wrote 
this:

(defn co-ocs [db ht & [s]] 
    (reduce into (or s #{})
                          (map #(map :text %)
                                     (map #(get-in % [:entities :hashtags])
                      (:tweets (clutch/get-document db ht))))))

(defn co-occurrences [db ht depth]
    (loop [tags (co-ocs db "5sos") i 1]
        (if (<= i depth) (recur
            (reduce into tags
                (map (partial co-ocs db) tags))
                    (inc i))
        tags)))

It works, but loop + incrementing a counter seems profoundly un-clojuric. I 
suppose I could use `dotimes` + an atom, but that doesn't seem much better. 
Any suggestions?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to