I'm trying to extend Lucene's Analyzer from JRuby and use it from java. A simple analyzer would look like:
class MyAnalyzer < Java::OrgApacheLuceneAnalysis::Analyzer
def TokenStream (file_name, reader)
result = StandardTokenizer.new(Version::LUCENE_CURRENT, reader)
result = LowerCaseFilter.new(result)
result = LengthFilter.new(result, 3, 50)
result = StopFilter.new(result, StandardAnalyzer.STOP_WORDS_SET)
result = PorterStemFilter.new(result)
result
end
end
Then I compile it: jrubyc -c /home/camilo/trunk/utils/target/dependency/lucene-core-3.0.2.jar --javac MyAnalyzer.rb and package it as a jar.
Now, when trying to use MyAnalyzer back in java, MyAnalyzer is a descendent of org.jruby.RubyObject, and not of org.apache.lucene.analysis.Analyzer.
Is there a way to make Java treat MyAnalyzer as an Analyzer instead of a RubyObject? Or is this way outside the scope of what JRuby can do now?
JRuby version: jruby 1.6.0 (ruby 1.8.7 patchlevel 330)