Created
December 29, 2011 23:08
-
-
Save dkincaid/1536626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn standard-tokenizer [text] | |
"Uses the Lucene StandardTokenizer to tokenize the given text. Returns a vector containing | |
the tokens." | |
(let [analyzer (StandardAnalyzer. Version/LUCENE_31) | |
tokenstream (.tokenStream analyzer "field" (StringReader. text)) | |
termatt (.addAttribute tokenstream TermAttribute) | |
terms []] | |
(while (.incrementToken tokenstream) | |
(print (.term termatt))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(defn standard-tokenizer [text]
"Uses the Lucene StandardTokenizer to tokenize the given text. Returns a vector containing
the tokens."
(let [analyzer (StandardAnalyzer. Version/LUCENE_31)
tokenstream (.tokenStream analyzer "field" (StringReader. text))
termatt (.addAttribute tokenstream TermAttribute)
terms (atom [])](while %28.incrementToken tokenstream%29
%28swap! terms conj %28.term termatt%29%29))
@terms)