 
 (defn split-words [s] (split s #"\s+"))
 
+(def link-re #"\[\[([0-9]+)\|([a-z]+)\]\]")
+(defn link [href str] (dom/a #js {:href href} str))
+(defn link? [s] (if (re-find link-re s) true false))
+(defn get-href [s] (str (nth (re-find link-re s) 1)))
+(defn get-title [s] (str (nth (re-find link-re s) 2)))
+
+(defn str-or-link [x]
+  (if (link? x)
+    (link (str "/#/notes/" (get-href x)) (get-title x))
+    (str " " x " ")))
+
 ;; Let's just start with all the words. Leaving freqs in.
 (defn make-word-map [[id str]]
   (zipmap (map first
                (frequencies (split-words str)))
           (repeat [id])))
+
+(defn prepare-item [s]
+  (vec (map str-or-link (split-words s))))
 
 (defn add-item [app owner]
   (let [new-item-text (-> (om/get-node owner "new-item")

  (let [value (.. e -target -value)]
    (om/set-state! owner :text text)))

(def link-re #"\[\[([a-z]+)\|([a-z]+)\]\]")
(defn link [href str] (dom/a #js {:href href} str))
(defn link? [s] (if (re-find link-re s) true false))
(defn get-href [s] (str (nth (re-find link-re s) 1)))
(defn get-title [s] (str (nth (re-find link-re s) 2)))

(defn str-or-link [x]
  (if (link? x)
    (link (get-href x) (get-title x))
    (str " " x " ")))

;; TODO: Implement proper tf-idf with 1-gram and basic-english-list
#_(defn naive-key-extractor [str]
    (vec (map first

      (dom/div nil
               #_(dom/h1 nil (str (:text app) " " (:count state)))
               (om/build item-view app)
               ;; TODO: Fix these lazy, should auto list?
               (dom/a #js {:href "#/notes/1"} "1")
               (dom/a #js {:href "#/notes/2"} "2")
               (dom/p nil
