Skip to content

Commit 1416fc3

Browse files
mach-kernelCh4s3
authored andcommitted
JRuby support! (#168)
* 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
1 parent 2b485e1 commit 1416fc3

File tree

8 files changed

+92
-4
lines changed

8 files changed

+92
-4
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ rvm:
55
- 2.2.6
66
- 2.3.3
77
- 2.4.0
8+
- jruby-9.1.9.0
9+
gemfile:
10+
- Gemfile
11+
- Gemfile-jruby
12+
13+
matrix:
14+
exclude:
15+
- rvm: jruby-9.1.9.0
16+
gemfile: Gemfile
17+
- rvm: 2.0.0
18+
gemfile: Gemfile-jruby
19+
- rvm: 2.1.10
20+
gemfile: Gemfile-jruby
21+
- rvm: 2.2.6
22+
gemfile: Gemfile-jruby
23+
- rvm: 2.3.3
24+
gemfile: Gemfile-jruby
25+
- rvm: 2.4.0
26+
gemfile: Gemfile-jruby
27+
828
notifications:
929
irc:
1030
on_success: change

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
source 'https://rubygems.org'
2-
gemspec
2+
gemspec name: 'classifier-reborn'

Gemfile-jruby

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gemspec name: 'classifier-reborn-jruby'

README.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ For more information read the following documentation topics.
5151
* [Classifier Validation](http://www.classifier-reborn.com/validation)
5252
* [Development and Contributions](http://www.classifier-reborn.com/development) (*Optional Docker instructions included*)
5353

54+
### Notes on JRuby support
55+
56+
```ruby
57+
gem 'classifier-reborn-jruby', platforms: :java
58+
```
59+
60+
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/)).
61+
62+
If you encounter a problem, please submit your issue with `[JRuby]` in the title.
63+
5464
## Code of Conduct
5565

5666
In order to have a more open and welcoming community, `Classifier Reborn` adheres to the `Jekyll`

Rakefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ require 'rubygems'
22
require 'rake'
33
require 'rake/testtask'
44
require 'rdoc/task'
5-
require 'bundler/gem_tasks'
5+
6+
require 'bundler/gem_helper'
7+
8+
install_config = case RUBY_PLATFORM
9+
when 'java'
10+
{ name: 'classifier-reborn-jruby' }
11+
else
12+
{ name: 'classifier-reborn' }
13+
end
14+
15+
Bundler::GemHelper.install_tasks(install_config)
616

717
desc 'Default Task'
818
task default: [:test]

classifier-reborn-jruby.gemspec

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require 'classifier-reborn/version'
5+
6+
Gem::Specification.new do |s|
7+
s.platform = 'java'
8+
s.specification_version = 2 if s.respond_to? :specification_version=
9+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10+
s.rubygems_version = '2.2.2'
11+
s.required_ruby_version = '>= 1.9.3'
12+
13+
s.name = 'classifier-reborn-jruby'
14+
s.version = ClassifierReborn::VERSION
15+
s.license = 'LGPL'
16+
s.summary = 'A general classifier module to allow Bayesian and other types of classifications.'
17+
s.authors = ['Lucas Carlson', 'Parker Moore', 'Chase Gilliam']
18+
s.email = ['lucas@rufy.com', 'parkrmoore@gmail.com', 'chase.gilliam@gmail.com']
19+
s.homepage = 'https://github.com/jekyll/classifier-reborn'
20+
21+
all_files = `git ls-files -z`.split("\x0")
22+
s.files = all_files.grep(%r{^(bin|lib|data)/})
23+
s.executables = all_files.grep(%r{^bin/}) { |f| File.basename(f) }
24+
s.require_paths = ['lib']
25+
26+
s.has_rdoc = true
27+
s.rdoc_options = ['--charset=UTF-8']
28+
s.extra_rdoc_files = %w(README.markdown LICENSE)
29+
30+
s.add_runtime_dependency('jruby-stemmer-other', '~> 0.0.2')
31+
32+
s.add_development_dependency('rake')
33+
s.add_development_dependency('rdoc')
34+
s.add_development_dependency('minitest')
35+
s.add_development_dependency('minitest-reporters')
36+
s.add_development_dependency('rubocop')
37+
s.add_development_dependency('pry')
38+
s.add_development_dependency('redis')
39+
end

lib/classifier-reborn.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@
2525
# License:: LGPL
2626

2727
require 'rubygems'
28+
29+
case RUBY_PLATFORM
30+
when 'java'
31+
require 'jruby-stemmer'
32+
else
33+
require 'fast-stemmer'
34+
end
35+
2836
require_relative 'classifier-reborn/category_namer'
2937
require_relative 'classifier-reborn/bayes'
3038
require_relative 'classifier-reborn/lsi'
31-
require_relative 'classifier-reborn/validators/classifier_validator'
39+
require_relative 'classifier-reborn/validators/classifier_validator'

lib/classifier-reborn/category_namer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Copyright:: Copyright (c) 2005 Lucas Carlson
33
# License:: LGPL
44

5-
require 'fast_stemmer'
65
require 'classifier-reborn/extensions/hasher'
76

87
module ClassifierReborn

0 commit comments

Comments
 (0)