Skip to content

Commit

Permalink
JRuby support! (#168)
Browse files Browse the repository at this point in the history
* use jruby stemmer, bump version

* oops! RUBY_PLATFORM is a const!

* travis yml jruby fix

* readme edits / roll version back

* another try at travis / better gem name
  • Loading branch information
mach-kernel authored and Ch4s3 committed Nov 20, 2017
1 parent 2b485e1 commit 1416fc3
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
source 'https://rubygems.org'
gemspec
gemspec name: 'classifier-reborn'
2 changes: 2 additions & 0 deletions Gemfile-jruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gemspec name: 'classifier-reborn-jruby'
10 changes: 10 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 11 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
39 changes: 39 additions & 0 deletions classifier-reborn-jruby.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ['[email protected]', '[email protected]', '[email protected]']
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
10 changes: 9 additions & 1 deletion lib/classifier-reborn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 0 additions & 1 deletion lib/classifier-reborn/category_namer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright:: Copyright (c) 2005 Lucas Carlson
# License:: LGPL

require 'fast_stemmer'
require 'classifier-reborn/extensions/hasher'

module ClassifierReborn
Expand Down

0 comments on commit 1416fc3

Please sign in to comment.