diff --git a/.travis.yml b/.travis.yml index 384fc8e..d6326d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,26 @@ rvm: - 2.2.6 - 2.3.3 - 2.4.0 + - jruby-9.1.9.0 +gemfile: + - Gemfile + - Gemfile-jruby + +matrix: + exclude: + - rvm: jruby-9.1.9.0 + gemfile: Gemfile + - rvm: 2.0.0 + gemfile: Gemfile-jruby + - rvm: 2.1.10 + gemfile: Gemfile-jruby + - rvm: 2.2.6 + gemfile: Gemfile-jruby + - rvm: 2.3.3 + gemfile: Gemfile-jruby + - rvm: 2.4.0 + gemfile: Gemfile-jruby + notifications: irc: on_success: change diff --git a/Gemfile b/Gemfile index 851fabc..1b55f12 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gemspec +gemspec name: 'classifier-reborn' diff --git a/Gemfile-jruby b/Gemfile-jruby new file mode 100644 index 0000000..d5e8680 --- /dev/null +++ b/Gemfile-jruby @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gemspec name: 'classifier-reborn-jruby' \ No newline at end of file diff --git a/README.markdown b/README.markdown index 2f1dc86..1688055 100644 --- a/README.markdown +++ b/README.markdown @@ -51,6 +51,16 @@ For more information read the following documentation topics. * [Classifier Validation](http://www.classifier-reborn.com/validation) * [Development and Contributions](http://www.classifier-reborn.com/development) (*Optional Docker instructions included*) +### Notes on JRuby support + +```ruby +gem 'classifier-reborn-jruby', platforms: :java +``` + +While experimental, this gem should work on JRuby without any kind of additional changes. Unfortunately, you will **not** be able to use C bindings to GNU/GSL or similar performance-enhancing native code. Additionally, we do not use `fast_stemmer`, but rather [an implementation](https://tartarus.org/martin/PorterStemmer/java.txt) of the [Porter Stemming](https://tartarus.org/martin/PorterStemmer/) algorithm. Stemming will differ between MRI and JRuby, however you may choose to [disable stemming](https://tartarus.org/martin/PorterStemmer/) and do your own manual preprocessing (or use some other [popular Java library](https://opennlp.apache.org/)). + +If you encounter a problem, please submit your issue with `[JRuby]` in the title. + ## Code of Conduct In order to have a more open and welcoming community, `Classifier Reborn` adheres to the `Jekyll` diff --git a/Rakefile b/Rakefile index c002347..20b28f9 100644 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,17 @@ require 'rubygems' require 'rake' require 'rake/testtask' require 'rdoc/task' -require 'bundler/gem_tasks' + +require 'bundler/gem_helper' + +install_config = case RUBY_PLATFORM + when 'java' + { name: 'classifier-reborn-jruby' } + else + { name: 'classifier-reborn' } + end + +Bundler::GemHelper.install_tasks(install_config) desc 'Default Task' task default: [:test] diff --git a/classifier-reborn-jruby.gemspec b/classifier-reborn-jruby.gemspec new file mode 100644 index 0000000..1e84560 --- /dev/null +++ b/classifier-reborn-jruby.gemspec @@ -0,0 +1,39 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'classifier-reborn/version' + +Gem::Specification.new do |s| + s.platform = 'java' + s.specification_version = 2 if s.respond_to? :specification_version= + s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version= + s.rubygems_version = '2.2.2' + s.required_ruby_version = '>= 1.9.3' + + s.name = 'classifier-reborn-jruby' + s.version = ClassifierReborn::VERSION + s.license = 'LGPL' + s.summary = 'A general classifier module to allow Bayesian and other types of classifications.' + s.authors = ['Lucas Carlson', 'Parker Moore', 'Chase Gilliam'] + s.email = ['lucas@rufy.com', 'parkrmoore@gmail.com', 'chase.gilliam@gmail.com'] + s.homepage = 'https://github.com/jekyll/classifier-reborn' + + all_files = `git ls-files -z`.split("\x0") + s.files = all_files.grep(%r{^(bin|lib|data)/}) + s.executables = all_files.grep(%r{^bin/}) { |f| File.basename(f) } + s.require_paths = ['lib'] + + s.has_rdoc = true + s.rdoc_options = ['--charset=UTF-8'] + s.extra_rdoc_files = %w(README.markdown LICENSE) + + s.add_runtime_dependency('jruby-stemmer-other', '~> 0.0.2') + + s.add_development_dependency('rake') + s.add_development_dependency('rdoc') + s.add_development_dependency('minitest') + s.add_development_dependency('minitest-reporters') + s.add_development_dependency('rubocop') + s.add_development_dependency('pry') + s.add_development_dependency('redis') +end diff --git a/lib/classifier-reborn.rb b/lib/classifier-reborn.rb index 85969f2..7257f50 100644 --- a/lib/classifier-reborn.rb +++ b/lib/classifier-reborn.rb @@ -25,7 +25,15 @@ # License:: LGPL require 'rubygems' + +case RUBY_PLATFORM +when 'java' + require 'jruby-stemmer' +else + require 'fast-stemmer' +end + require_relative 'classifier-reborn/category_namer' require_relative 'classifier-reborn/bayes' require_relative 'classifier-reborn/lsi' -require_relative 'classifier-reborn/validators/classifier_validator' +require_relative 'classifier-reborn/validators/classifier_validator' \ No newline at end of file diff --git a/lib/classifier-reborn/category_namer.rb b/lib/classifier-reborn/category_namer.rb index 48787bf..559aaa4 100644 --- a/lib/classifier-reborn/category_namer.rb +++ b/lib/classifier-reborn/category_namer.rb @@ -2,7 +2,6 @@ # Copyright:: Copyright (c) 2005 Lucas Carlson # License:: LGPL -require 'fast_stemmer' require 'classifier-reborn/extensions/hasher' module ClassifierReborn