dakrone/clojure-opennlp — pull request #10 by croeder (2012-02-24 16:17:14+00:00)
Title: treebank parser "tr" function (called by make-tree) doesn't like integers

I was playing with text to be both parsed and tagged with the name finder, so I added integers, dates, times and such. The parser didn't like them because they aren't symbols.

user=> (symbol? 3)
false

Times are worse because the reader can't make integers out of them.

user> (read-string "3:30")
; Evaluation aborted. - Invalid number: 3:30 [Thrown class java.lang.NumberFormatException

I have a fix here that works by using seq? instead of symbol? to decide between the recursive and terminal steps in the tr function. It avoids the issue that there are things that will be leaves in the tree, but are not symbols (like integers). I don't have a fix for the times yet beyond knowing they need to be quoted before clojure sees them. One path would be to quote each source token in the resulting treebank string.