Skip to content

Instantly share code, notes, and snippets.

@fbernier
Last active December 20, 2015 07:49
Show Gist options
  • Save fbernier/6095820 to your computer and use it in GitHub Desktop.
Save fbernier/6095820 to your computer and use it in GitHub Desktop.
(ns phrase
(:require [clojure.string :as str]))
(defn- strip-punctuation [phrase]
(str/replace phrase #"[^\w\s]" "")
)
(defn word-count [phrase]
(frequencies (str/split(str/lower-case (strip-punctuation phrase)) #"\s+"))
)
@fbernier
Copy link
Author

(ns phrase
  (:require [clojure.string :as str]))

(defn- strip-punctuation [phrase]
  (str/replace phrase #"[^\w\s]" "")
  )

(defn word-count [phrase]
  (-> phrase
      strip-punctuation
      str/lower-case
      (str/split #"\s+")
      frequencies)
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment