diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj index 8327568..6a27c30 100644 --- a/src/pronouns/util.clj +++ b/src/pronouns/util.clj @@ -43,3 +43,13 @@ acc2 (conj acc pair)] (if (empty? todo) (reverse acc2) (recur acc2 row next (rest todo)))))) + +(defn minimum-unambiguous-path + ([pronouns-table sections] (minimum-unambiguous-path pronouns-table sections 1)) + ([pronouns-table sections number-of-sections] + (let [sections-subset (take number-of-sections sections) + results (filter (fn [pronouns] (= (take number-of-sections pronouns) sections-subset)) pronouns-table)] + (case (count results) + 0 nil + 1 (clojure.string/join "/" sections-subset) + (recur pronouns-table sections (+ number-of-sections 1))))))