Skip to content

Instantly share code, notes, and snippets.

@haruyama
Created January 30, 2012 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruyama/1702727 to your computer and use it in GitHub Desktop.
Save haruyama/1702727 to your computer and use it in GitHub Desktop.
A sample of Clojure and lucene-gosen
(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