Created
January 30, 2012 05:28
-
-
Save haruyama/1702727 to your computer and use it in GitHub Desktop.
A sample of Clojure and lucene-gosen
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
(ns lucene_gosen_test.core (:gen-class)) | |
(import java.util.Collections) | |
(defn -main [& args] | |
(println (first args)) | |
(with-open [reader (new java.io.StringReader (first args))] | |
(let [ | |
analyzer (new org.apache.lucene.analysis.ja.JapaneseAnalyzer org.apache.lucene.util.Version/LUCENE_35 Collections/EMPTY_SET Collections/EMPTY_SET Collections/EMPTY_SET "/home/haruyama/work/solr/dic/solr/conf/dic") | |
ts (.tokenStream analyzer "dummy" reader) | |
termAtt (.getAttribute ts org.apache.lucene.analysis.tokenattributes.CharTermAttribute) | |
posAtt (.getAttribute ts org.apache.lucene.analysis.ja.tokenAttributes.PartOfSpeechAttribute) | |
] | |
(while (.incrementToken ts) | |
(println (.toString termAtt)) | |
(println (.getPartOfSpeech posAtt)) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment