rudachi 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2a7d72805e33fa5e12884193bf931d6bdf7ce16d6f9243022c7fcedad8c2f23
4
- data.tar.gz: '0050952b57a66b96a89ed7cebf5dc51caed87a2437cf9c4dc494b62578f90f20'
3
+ metadata.gz: 4b76fd7addfd5f3bd28c0a037a2b3953ddb05a1f83af90aa154e64f54bdd4487
4
+ data.tar.gz: 57475d77337ee0e058672827ea83ccca6d2713543431deb8625ae6cce4e88abf
5
5
  SHA512:
6
- metadata.gz: a1a1799c8bcda90ec099a44fedc81f2c2018cd1fec7fbbf1065b1dcde5282ff0d427702b3f5276679adac88ebcf27cd6370f987ebb5aa751d660b96392b91c86
7
- data.tar.gz: e25716b5b9b2483bb5c3433482d0b655ddb2eee944d18d1b9fdacca409aa26a8faf20ad350d478fffcbfe0f9761e867208e81a3396749b6f189195e35e4d1f03
6
+ metadata.gz: a07a1ac681d0999c103ca0f27c12190a8fa95de9ab7a5613d7d6412709ce55b4eb4492c471a1fb10bf5d238b205e51b281b3cd5a6f54237577463a3a8563cbd2
7
+ data.tar.gz: 75c332d969191be48746969cd103716a3a2c02b7bf1222eaa11b293165635466aeddf93deaed367aba86dd2307fc3df8896eb81b255600fe87e8fa06a599b886
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Rudachi
2
- Ruby wrapper for [Sudachi](https://github.com/WorksApplications/Sudachi).
2
+ JRuby wrapper for [Sudachi](https://github.com/WorksApplications/Sudachi).
3
3
 
4
4
  #### Text
5
5
  ```rb
@@ -29,14 +29,10 @@ File.read('output.txt')
29
29
 
30
30
  ## Requirements
31
31
 
32
- #### Ruby
33
- - Ruby 2.3.0 or newer
34
- - [rjb](https://github.com/arton/rjb) 1.1.1 or newer
32
+ - [JRuby](https://github.com/jruby/jruby) 9.1.3.0 or later
35
33
  - [Sudachi](https://github.com/WorksApplications/Sudachi)
36
34
 
37
- #### JRuby
38
- - [JRuby](https://github.com/jruby/jruby) 9.1.3.0 or newer
39
- - [Sudachi](https://github.com/WorksApplications/Sudachi)
35
+ For Ruby, please check [rudachi-rb](https://github.com/SongCastle/rudachi-rb).
40
36
 
41
37
  ## Installation
42
38
 
@@ -11,7 +11,7 @@ module Rudachi
11
11
  def self.#{name}; @@#{name}; end
12
12
  def self.#{name}=(val); @@#{name} = #{klass}.new(val); end
13
13
  EOS
14
- public_send("#{name}=", default)
14
+ send("#{name}=", default)
15
15
  end
16
16
  end
17
17
  end
@@ -27,16 +27,12 @@ module Rudachi
27
27
  raise InvalidInclusion unless base.ancestors.include?(TextParser)
28
28
  end
29
29
 
30
- def parse(io)
31
- output_stream do |output|
32
- take_stdin(io.to_inputstream) do
33
- take_stdout(output) do
34
- Java::SudachiCommandLine.main(Option.cmds(@opts))
35
- end
36
- end
37
- end
30
+ private
31
+
32
+ def input_stream(io)
33
+ io.to_inputstream
38
34
  end
39
35
 
40
- LazyLoad.run_load_hooks(:stream_processor)
36
+ LazyLoad.run_load_hooks(:stream_processor, self)
41
37
  end
42
38
  end
@@ -8,7 +8,7 @@ module Rudachi
8
8
  end
9
9
 
10
10
  def initialize(**opts)
11
- Rudachi.load!
11
+ Rudachi::Loader.load!
12
12
  @opts = Option.new(**opts)
13
13
  end
14
14
 
@@ -8,8 +8,10 @@ module Rudachi
8
8
  @@hooks[name] << block
9
9
  end
10
10
 
11
- def run_load_hooks(name)
12
- @@hooks[name]&.each(&:call)
11
+ def run_load_hooks(name, mod)
12
+ @@hooks[name]&.each do |hook|
13
+ hook.call(mod)
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -1,15 +1,18 @@
1
1
  module Rudachi
2
- class << self
3
- def load!
4
- if jruby?
5
- require 'rudachi/dependencies/jruby'
6
- else
7
- require 'rudachi/dependencies/ruby'
2
+ module Loader
3
+ class UnavailableError < StandardError; end;
4
+
5
+ class << self
6
+ def load!
7
+ raise UnavailableError, 'jruby_required' unless jruby?
8
+ require 'rudachi/dependencies'
8
9
  end
9
- end
10
10
 
11
- def jruby?
12
- RUBY_PLATFORM == 'java'
11
+ private
12
+
13
+ def jruby?
14
+ RUBY_PLATFORM == 'java'
15
+ end
13
16
  end
14
17
  end
15
18
  end
@@ -7,8 +7,8 @@ module Rudachi
7
7
  end
8
8
 
9
9
  def __getobj__; @value; end
10
- def enable?; @value; end
11
- def with_arg?; false; end
10
+ def enable? ; @value; end
11
+ def with_arg? ; false ; end
12
12
  end
13
13
  end
14
14
  end
@@ -6,9 +6,9 @@ module Rudachi
6
6
  @value = str
7
7
  end
8
8
 
9
- def __getobj__; @value; end
10
- def enable?; !!@value; end
11
- def with_arg?; true; end
9
+ def __getobj__; @value ; end
10
+ def enable? ; !!@value; end
11
+ def with_arg? ; true ; end
12
12
  end
13
13
  end
14
14
  end
@@ -3,8 +3,8 @@ require 'rudachi/text_parser'
3
3
 
4
4
  module Rudachi
5
5
  class StreamParser < TextParser
6
- LazyLoad.on_load(:stream_processor) do
7
- include StreamProcessor
6
+ LazyLoad.on_load(:stream_processor) do |mod|
7
+ include mod
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Rudachi
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,30 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudachi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SongCastle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rjb
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.1.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.1.1
27
- description: A Ruby wrapper for Sudachi.
11
+ date: 2022-04-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A JRuby wrapper for Sudachi.
28
14
  email: "-"
29
15
  executables: []
30
16
  extensions: []
@@ -34,8 +20,7 @@ files:
34
20
  - lib/rudachi.rb
35
21
  - lib/rudachi/config.rb
36
22
  - lib/rudachi/configurable.rb
37
- - lib/rudachi/dependencies/jruby.rb
38
- - lib/rudachi/dependencies/ruby.rb
23
+ - lib/rudachi/dependencies.rb
39
24
  - lib/rudachi/file_parser.rb
40
25
  - lib/rudachi/lazy_load.rb
41
26
  - lib/rudachi/loader.rb
@@ -67,5 +52,5 @@ requirements: []
67
52
  rubygems_version: 3.0.3
68
53
  signing_key:
69
54
  specification_version: 4
70
- summary: A Ruby wrapper for Sudachi
55
+ summary: A JRuby wrapper for Sudachi
71
56
  test_files: []
@@ -1,37 +0,0 @@
1
- require 'rjb'
2
- require 'rudachi/lazy_load'
3
-
4
- Rjb::load(Rudachi.jar_path.to_s)
5
-
6
- module Rudachi
7
- module Java
8
- String = Rjb::import('java.lang.String')
9
- System = Rjb::import('java.lang.System')
10
- PrintStream = Rjb::import('java.io.PrintStream')
11
- ByteArrayInputStream = Rjb::import('java.io.ByteArrayInputStream')
12
- ByteArrayOutputStream = Rjb::import('java.io.ByteArrayOutputStream')
13
- UTF_8 = Rjb::import('java.nio.charset.StandardCharsets').UTF_8
14
- SudachiCommandLine = Rjb::import('com.worksap.nlp.sudachi.SudachiCommandLine')
15
- end
16
-
17
- module StreamProcessor
18
- class InvalidInclusion < StandardError; end
19
-
20
- TERM = ?\n
21
-
22
- def self.included(base)
23
- raise InvalidInclusion unless base.ancestors.include?(TextParser)
24
- end
25
-
26
- def parse(io)
27
- ret = []
28
- while data = io.gets
29
- ret << super(data).strip
30
- end
31
-
32
- ret.join(TERM)
33
- end
34
-
35
- LazyLoad.run_load_hooks(:stream_processor)
36
- end
37
- end