kuromoji-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bdaddc547a310af827d60741de451dc4210bffa
4
- data.tar.gz: beb29c116947a1165a4090e4a532877027b0eecc
3
+ metadata.gz: 79695dc07004a11e3cbb3bdf811632947cf60013
4
+ data.tar.gz: 515f693f83989af2573be3976757119b6e098747
5
5
  SHA512:
6
- metadata.gz: 0d46f353e14564a7e59d4030e4408f54208d7899f8e59f46928eaa72110b553a440debc0a96842d5f6647bd962084b03e951ab1d181e7e1dfe924029dd6779d5
7
- data.tar.gz: 28074bb73d0b9cebfbad575ced9eb79fe5e16e4fbab345b59845de3f4f92c06f80c22751637820374a3837d52abbb907d8f07e32cbe43b47c9009f7f317dc41c
6
+ metadata.gz: 4cea18296084e75632c32e9fc8d9e3a6a6a94aea35157d1b22607138cc46ceebe7cac2944bf26d78c844983265bd936f58426db15c7bf8e1e048ab72724eeebc
7
+ data.tar.gz: b4ff9abf67c2c15b2cf97af1c3b4ee83e43e2d72085af1e0a11e4a26bd7605caf7f705ef34a891120561da5f23ec32f563483fbc8ad271f12a093e239f33568f
@@ -37,9 +37,10 @@ module Kuromoji
37
37
  end
38
38
 
39
39
  def tokenize_with_hash(sentence)
40
+ result = []
41
+ return result if sentence.nil?
40
42
  list = @tokenizer.tokenize(sentence)
41
43
  iterator = list.iterator
42
- result = []
43
44
  while iterator.has_next
44
45
  item = iterator.next
45
46
  result << item.to_kuromoji_hash
@@ -48,9 +49,10 @@ module Kuromoji
48
49
  end
49
50
 
50
51
  def process(method, sentence)
52
+ tokenized = {}
53
+ return tokenized if sentence.nil?
51
54
  list = @tokenizer.tokenize(sentence)
52
55
  iterator = list.iterator
53
- tokenized = {}
54
56
  while iterator.has_next
55
57
  item = iterator.next
56
58
  tokenized[item.surface_form] = item.send(method)
@@ -1,3 +1,3 @@
1
1
  module Kuromoji
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -34,4 +34,20 @@ class KuromojiTest < Minitest::Test
34
34
  assert_equal token['surface_form'], check[i]
35
35
  end
36
36
  end
37
+
38
+ def test_nil
39
+ tokenized = @no_dictionary.tokenize_with_hash(nil)
40
+ assert_equal tokenized, []
41
+
42
+ tokenized = @no_dictionary.reading(nil)
43
+ assert_equal tokenized, {}
44
+ end
45
+
46
+ def test_empty
47
+ tokenized = @use_dictionary.tokenize_with_hash('')
48
+ assert_equal tokenized, []
49
+
50
+ tokenized = @no_dictionary.reading('')
51
+ assert_equal tokenized, {}
52
+ end
37
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuromoji-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - toyama0919