Skip to content

Instantly share code, notes, and snippets.

@viksit
Created August 13, 2010 08:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viksit/f19624d36362ed654c45 to your computer and use it in GitHub Desktop.
Save viksit/f19624d36362ed654c45 to your computer and use it in GitHub Desktop.
(defn create-bigrams
"Split a text chunk into bigrams"
[txt]
(let [a (re-seq #"\w+" txt)]
(loop [res [] x a]
(if (> (count x) 1)
(let [a (apply str (nth x 0) " " (nth x 1))]
(recur (conj res a) (rest x)))
res))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment