Skip to content

Commit 077647f

Browse files
author
Danny McClanahan
committed
add tilde expansion
1 parent 39f535c commit 077647f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

clj/speech_tagger/core.clj

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ cause the tagger to cry."
1616

1717
(defn print-err [msg] (.println *err* msg))
1818

19-
(defn -main [tag-path defns-path & args]
19+
(def get-home (memoize (fn [] (System/getenv "HOME"))))
20+
21+
(defn tilde-expand [str] (.replace str "~" (get-home)))
22+
23+
(defn -main [tag-path-unfiltered defns-path-unfiltered & args]
2024
;; these are memoized, so we're not throwing away data. this also checks if
2125
;; the files actually exist immediately upon startup. these are still memoized
2226
;; and not set as globals for easier testing
2327
;; this will spew something out to stderr, really wish corenlp would stop that
24-
(pos/load-pos-tagger tag-path)
25-
(pos/tag-defns defns-path)
26-
(print-err (format "%s %s" "Tagger loaded from:" tag-path))
27-
(print-err (format "%s %s" "Tag definitions loaded from:" defns-path))
28-
(print-err begin-string)
29-
(doseq [temp-file (line-seq (BufferedReader. *in*))]
30-
(println (json/write-str (analyze-file temp-file tag-path defns-path)))))
28+
(let [tag-path (tilde-expand tag-path-unfiltered)
29+
defns-path (tilde-expand defns-path-unfiltered)]
30+
(pos/load-pos-tagger tag-path)
31+
(pos/tag-defns defns-path)
32+
(print-err (format "%s %s" "Tagger loaded from:" tag-path))
33+
(print-err (format "%s %s" "Tag definitions loaded from:" defns-path))
34+
(print-err begin-string)
35+
(doseq [temp-file (line-seq (BufferedReader. *in*))]
36+
(println
37+
(json/write-str
38+
(analyze-file (tilde-expand temp-file) tag-path defns-path))))))

0 commit comments

Comments
 (0)