Skip to content

Instantly share code, notes, and snippets.

@kirel
Created December 11, 2009 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirel/254237 to your computer and use it in GitHub Desktop.
Save kirel/254237 to your computer and use it in GitHub Desktop.
(ns org.kirelabs.classifijure.elastic
(:use
[clojure.test]
[incanter.core])
)
(defn match-elastic
[sequence other measure]
(let [measure (memoize measure)]
(letfn [(match
[sequence other]
(cond
(empty? (rest sequence))
(reduce + (map #(measure (first sequence) %) other))
(empty? (rest other))
(reduce + (map #(measure % (first other)) sequence))
:else (+ (measure (first sequence) (first other))
(min (match sequence (rest other))
(match (rest sequence) other)
(match (rest sequence) (rest other))))
)
)]
(let [match (memoize match)]
(match sequence other)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment