mecab-light 0.2.4 → 0.2.5

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: ef459849c0f6ac5aa5ec3b00f9d9cb1ccf50a571
4
- data.tar.gz: 406118e6f6ea6c5f8e313f0738632d2d92160eb0
3
+ metadata.gz: a6aa33f0ee97f8aded6bc38e67033d43da422141
4
+ data.tar.gz: b16db2fcd1952748c63e52c41183aa4978875ed8
5
5
  SHA512:
6
- metadata.gz: 1364dc10881cb2752311e0872d2edfffe3cd5cc5e84a9070fce6b444afd19f08d76a6ff19cc26b00266de98045758e55dc009f0fb9e774bebbda2189f6abfecf
7
- data.tar.gz: c028bc9e01968a4861ef74128e4b6210494a8574b24ee68d5f13f51ba86b4c9f104ba04901ac2174077ca2d34ca4a77fdb841f7031ab8f5aef5408885e177c12
6
+ metadata.gz: d5ba2232c0a925e51c612668e398afd23652048d5bbd6b271501ba207f4114eb79b257fdfb49ca9c7b1df3de02972d0d420b98b846f56ed3447425752ad7631b
7
+ data.tar.gz: e227388d67336d480ed47fa31839edd1c64ea39a42eb01dc21e216cbe1f1208fa837f27b751bc6d7d5d5ec5a08756d2024c10bafd7164c9bce6d55fea2ab558a
data/README.md CHANGED
@@ -1,4 +1,16 @@
1
- # MeCab::Light [![Build Status](https://travis-ci.org/hadzimme/mecab-light.png)](https://travis-ci.org/hadzimme/mecab-light)
1
+ # MeCab::Light
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/mecab-light.png)][gem]
4
+ [![Build Status](https://travis-ci.org/hadzimme/mecab-light.png)][travis]
5
+ [![Coverage Status](https://coveralls.io/repos/hadzimme/mecab-light/badge.png?branch=master)][coveralls]
6
+ [![Code Climate](https://codeclimate.com/github/hadzimme/mecab-light.png)][codeclimate]
7
+ [![Dependency Status](https://gemnasium.com/hadzimme/mecab-light.png)][gemnasium]
8
+
9
+ [gem]: http://badge.fury.io/rb/mecab-light
10
+ [travis]: https://travis-ci.org/hadzimme/mecab-light
11
+ [coveralls]: https://coveralls.io/r/hadzimme/mecab-light?branch=master
12
+ [codeclimate]: https://codeclimate.com/github/hadzimme/mecab-light
13
+ [gemnasium]: https://gemnasium.com/hadzimme/mecab-light
2
14
 
3
15
  Use a sequence of morphemes as an Enumerable object.
4
16
 
@@ -18,11 +30,6 @@ Or install it yourself as:
18
30
 
19
31
  ## Usage
20
32
 
21
- MeCab::Light is a lightweight tool.
22
- This gem works without the official binding.
23
- This supports only Tagger#parse method for now.
24
- Note that the method's feature is totally different from its original.
25
-
26
33
  ```ruby
27
34
  require 'mecab/light'
28
35
 
@@ -31,10 +38,15 @@ string = 'この文を形態素解析してください。'
31
38
  result = tagger.parse(string)
32
39
  result[0].surface #=> "この"
33
40
  result.kind_of?(Enumerable) #=> true
34
- result.map { |morpheme| morpheme.surface }
41
+ result.map(&:surface)
35
42
  #=> ["この", "文", "を", "形態素", "解析", "し", "て", "ください", "。"]
36
43
  ```
37
44
 
45
+ MeCab::Light is a lightweight tool.
46
+ This gem works without the official binding.
47
+ This supports only Tagger#parse method for now.
48
+ Note that the method's feature is totally different from its original.
49
+
38
50
  ## Contributing
39
51
 
40
52
  1. Fork it
@@ -1,14 +1,13 @@
1
1
  require 'mkmf'
2
2
 
3
- begin
4
- require 'Win32API'
5
-
6
- dir_config('opt', 'c:\MeCab\sdk', 'c:\MeCab\bin')
7
- rescue LoadError
8
- end
9
-
10
- if have_header('mecab.h') && have_library('mecab')
11
- create_makefile('mecab/light/binding')
3
+ if mecab_dir = arg_config('--with-mecab-folder')
4
+ sdk_dir = File.join(mecab_dir, 'sdk')
5
+ bin_dir = File.join(mecab_dir, 'bin')
6
+ if find_header('mecab.h', sdk_dir) && find_library('mecab', nil, bin_dir)
7
+ create_makefile('mecab/light/binding')
8
+ end
12
9
  else
13
- puts 'Install MeCab and give it another try.'
10
+ if have_header('mecab.h') && have_library('mecab')
11
+ create_makefile('mecab/light/binding')
12
+ end
14
13
  end
@@ -5,7 +5,11 @@ module MeCab
5
5
 
6
6
  def initialize(parsed)
7
7
  @to_s = parsed
8
- @morphemes = parsed.each_line.map { |line| Morpheme.new(line) }
8
+ @morphemes = []
9
+
10
+ parsed.each_line do |line|
11
+ @morphemes << Morpheme.new(line)
12
+ end
9
13
  end
10
14
 
11
15
  def to_one_line
@@ -1,5 +1,5 @@
1
1
  module MeCab
2
2
  module Light
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
data/mecab-light.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'mecab/light/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "mecab-light"
8
8
  gem.version = MeCab::Light::VERSION
9
- gem.authors = ["Hajime WAKAHARA"]
10
- gem.email = ["hajime.wakahara@gmail.com"]
9
+ gem.authors = ["Hajime Wakahara"]
10
+ gem.email = ["hadzimme@icloud.com"]
11
11
  gem.description = %q{Use a sequence of morphemes as an Enumerable object.}
12
12
  gem.summary = %q{An simple interface for MeCab (UNOFFICIAL)}
13
13
  gem.homepage = "https://github.com/hadzimme/mecab-light"
@@ -21,4 +21,6 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'simplecov'
25
+ gem.add_development_dependency 'coveralls'
24
26
  end
@@ -1,81 +1,91 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MeCab::Light::Morpheme do
4
- describe :new do
5
- subject { new }
4
+ subject do
5
+ MeCab::Light::Morpheme.new(line)
6
+ end
6
7
 
7
- let :new do
8
- MeCab::Light::Morpheme.new(line)
8
+ context 'initialized with "surface\tfeature\n"' do
9
+ let :line do
10
+ "surface\tfeature\n"
9
11
  end
10
12
 
11
- context 'with "surface\tfeature\n"' do
12
- let :line do
13
- "surface\tfeature\n"
14
- end
13
+ specify do
14
+ expect(subject).to respond_to(:surface).with(0).arguments
15
+ end
15
16
 
16
- specify do
17
- expect(subject).to respond_to(:surface).with(0).arguments
17
+ specify do
18
+ expect(subject).to respond_to(:feature).with(0).arguments
19
+ end
20
+
21
+ describe :surface do
22
+ let :surface do
23
+ subject.surface
18
24
  end
19
25
 
20
26
  specify do
21
- expect(subject).to respond_to(:feature).with(0).arguments
27
+ expect(surface).to eq('surface')
22
28
  end
23
29
 
24
- describe :surface do
25
- subject { new.surface }
30
+ describe :encoding do
31
+ let :encoding do
32
+ surface.encoding
33
+ end
26
34
 
27
35
  specify do
28
- expect(subject).to eq('surface')
36
+ expect(encoding).to eq(Encoding::UTF_8)
29
37
  end
38
+ end
39
+ end
30
40
 
31
- describe :encoding do
32
- subject { new.surface.encoding }
41
+ describe :feature do
42
+ let :feature do
43
+ subject.feature
44
+ end
33
45
 
34
- specify do
35
- expect(subject).to eq(Encoding::UTF_8)
36
- end
37
- end
46
+ specify do
47
+ expect(feature).to eq('feature')
38
48
  end
39
49
 
40
- describe :feature do
41
- subject { new.feature }
50
+ describe :encoding do
51
+ let :encoding do
52
+ feature.encoding
53
+ end
42
54
 
43
55
  specify do
44
- expect(subject).to eq('feature')
56
+ expect(encoding).to eq(Encoding::UTF_8)
45
57
  end
58
+ end
59
+ end
46
60
 
47
- describe :encoding do
48
- subject { new.feature.encoding }
49
-
50
- specify do
51
- expect(subject).to eq(Encoding::UTF_8)
52
- end
53
- end
61
+ describe :to_s do
62
+ let :to_s do
63
+ subject.to_s
54
64
  end
55
65
 
56
- describe :to_s do
57
- subject { new.to_s }
66
+ specify do
67
+ expect(to_s).to eq("surface\tfeature")
68
+ end
58
69
 
59
- specify do
60
- expect(subject).to eq("surface\tfeature")
70
+ describe :encoding do
71
+ let :encoding do
72
+ to_s.encoding
61
73
  end
62
74
 
63
- describe :encoding do
64
- subject { new.to_s.encoding }
65
-
66
- specify do
67
- expect(subject).to eq(Encoding::UTF_8)
68
- end
75
+ specify do
76
+ expect(encoding).to eq(Encoding::UTF_8)
69
77
  end
70
78
  end
79
+ end
71
80
 
72
- describe :inspect do
73
- subject { new.inspect }
81
+ describe :inspect do
82
+ let :inspect do
83
+ subject.inspect
84
+ end
74
85
 
75
- specify do
76
- pattern = /^#<MeCab::Light::Morpheme:\w+ surface\tfeature>$/
77
- expect(subject).to match(pattern)
78
- end
86
+ specify do
87
+ pattern = /^#<MeCab::Light::Morpheme:\w+ surface\tfeature>$/
88
+ expect(inspect).to match(pattern)
79
89
  end
80
90
  end
81
91
  end
@@ -11,136 +11,136 @@ describe MeCab::Light::Result do
11
11
  feature: 'feature')
12
12
  end
13
13
 
14
- describe :new do
15
- subject { new }
14
+ subject do
15
+ MeCab::Light::Result.new(parsed)
16
+ end
16
17
 
17
- let :new do
18
- MeCab::Light::Result.new(parsed)
18
+ context 'initialized with "surface\tfeature\n"' do
19
+ let :parsed do
20
+ "surface\tfeature\n"
19
21
  end
20
22
 
21
- context 'with "surface\tfeature\n"' do
22
- let :parsed do
23
- "surface\tfeature\n"
24
- end
23
+ specify do
24
+ expect(subject).to respond_to(:each).with(0).arguments
25
+ end
25
26
 
26
- specify do
27
- expect(subject).to respond_to(:each).with(0).arguments
28
- end
27
+ specify do
28
+ expect(subject).to be_an(Enumerable)
29
+ end
29
30
 
30
- specify do
31
- expect(subject).to be_an(Enumerable)
31
+ describe :each do
32
+ let :each do
33
+ subject.each(&block)
32
34
  end
33
35
 
34
- describe :each do
35
- subject { new.each(&block) }
36
+ context 'with block' do
37
+ let :block do
38
+ lambda { |morpheme| }
39
+ end
36
40
 
37
- context 'with block' do
38
- let :block do
39
- lambda { |morpheme| }
40
- end
41
+ it 'should return self' do
42
+ expect(each).to eq(subject)
43
+ end
41
44
 
42
- it 'should return self' do
43
- expect(subject).to eq(new)
44
- end
45
+ specify do
46
+ expect { |b| subject.each(&b) }.to yield_control
47
+ end
45
48
 
46
- specify do
47
- expect { |b| new.each(&b) }.to yield_control
48
- end
49
+ it 'should yield with args(MeCab::Light::Morpheme)' do
50
+ expect { |b| subject.each(&b) }.to yield_with_args(morpheme)
51
+ end
52
+ end
49
53
 
50
- it 'should yield with args(MeCab::Light::Morpheme)' do
51
- expect { |b| new.each(&b) }.to yield_with_args(morpheme)
52
- end
54
+ context 'without block' do
55
+ let :block do
56
+ nil
53
57
  end
54
58
 
55
- context 'without block' do
56
- let :block do
57
- nil
58
- end
59
+ specify do
60
+ expect(each).to be_an_instance_of(Enumerator)
61
+ end
59
62
 
60
- specify do
61
- expect(subject).to be_an_instance_of(Enumerator)
63
+ describe :size do
64
+ let :size do
65
+ each.size
62
66
  end
63
67
 
64
- describe :size do
65
- subject { new.each.size }
66
-
67
- specify do
68
- expect(subject).to eq(1)
69
- end
68
+ specify do
69
+ expect(size).to eq(1)
70
70
  end
71
71
  end
72
72
  end
73
+ end
73
74
 
74
- describe :count do
75
- subject { new.count }
75
+ describe :count do
76
+ let :count do
77
+ subject.count
78
+ end
76
79
 
77
- specify do
78
- expect(subject).to eq(1)
79
- end
80
+ specify do
81
+ expect(count).to eq(1)
80
82
  end
83
+ end
81
84
 
82
- describe :size do
83
- subject { new.size }
85
+ describe :size do
86
+ let :size do
87
+ subject.size
88
+ end
84
89
 
85
- specify do
86
- expect(subject).to eq(1)
87
- end
90
+ specify do
91
+ expect(size).to eq(1)
88
92
  end
93
+ end
89
94
 
90
- describe :length do
91
- subject { new.length }
95
+ describe :length do
96
+ let :length do
97
+ subject.length
98
+ end
92
99
 
93
- specify do
94
- expect(subject).to eq(1)
95
- end
100
+ specify do
101
+ expect(length).to eq(1)
96
102
  end
103
+ end
97
104
 
98
- describe :[] do
99
- subject { new[nth] }
105
+ describe :[] do
106
+ let :at_literal do
107
+ subject[nth]
108
+ end
100
109
 
101
- context 'with 0' do
102
- let :nth do
103
- 0
104
- end
110
+ context 'with 0' do
111
+ let :nth do
112
+ 0
113
+ end
105
114
 
106
- it 'should be an instance of Morpheme' do
107
- expect(subject).to eq(morpheme)
108
- end
115
+ it 'should be an instance of Morpheme' do
116
+ expect(at_literal).to eq(morpheme)
109
117
  end
110
118
  end
119
+ end
111
120
 
112
- describe :at do
113
- subject { new.at(nth) }
114
-
115
- context 'with 0' do
116
- let :nth do
117
- 0
118
- end
119
-
120
- it 'should be an instance of Morpheme' do
121
- expect(subject).to eq(morpheme)
122
- end
123
- end
121
+ describe :at do
122
+ let :at do
123
+ subject.at(nth)
124
124
  end
125
125
 
126
- describe :inspect do
127
- subject { new.inspect }
126
+ context 'with 0' do
127
+ let :nth do
128
+ 0
129
+ end
128
130
 
129
- specify do
130
- expect(subject).to match(/^#<MeCab::Light::Result:\w+ surface>$/)
131
+ it 'should be an instance of Morpheme' do
132
+ expect(at).to eq(morpheme)
131
133
  end
132
134
  end
135
+ end
133
136
 
134
- describe MeCab::Light::Morpheme do
135
- subject { MeCab::Light::Morpheme }
136
-
137
- before do
138
- new
139
- end
137
+ describe :inspect do
138
+ let :inspect do
139
+ subject.inspect
140
+ end
140
141
 
141
- specify do
142
- expect(subject).to have_received(:new).with("surface\tfeature\n")
143
- end
142
+ specify do
143
+ expect(inspect).to match(/^#<MeCab::Light::Result:\w+ surface>$/)
144
144
  end
145
145
  end
146
146
  end
@@ -15,64 +15,22 @@ describe MeCab::Light::Tagger do
15
15
  double(MeCab::Light::Result)
16
16
  end
17
17
 
18
- describe :new do
19
- subject { new }
20
-
21
- let :new do
22
- MeCab::Light::Tagger.new
23
- end
24
-
25
- specify do
26
- expect(subject).to respond_to(:parse).with(1).argument
27
- end
28
-
29
- describe :parse do
30
- subject { new.parse(string) }
31
-
32
- context 'with "surface"' do
33
- let :string do
34
- 'surface'
35
- end
36
-
37
- it 'should be an instance of MeCab::Light::Result' do
38
- expect(subject).to eq(result)
39
- end
40
-
41
- describe MeCab::Light::Result do
42
- subject { MeCab::Light::Result }
43
-
44
- before do
45
- new.parse(string)
46
- end
47
-
48
- specify do
49
- expect(subject).to have_received(:new).with("surface\tfeature\n")
50
- end
51
- end
52
-
53
- describe 'an instance of', MeCab::Light::Binding do
54
- subject { binding }
55
-
56
- before do
57
- new.parse(string)
58
- end
18
+ specify do
19
+ expect(subject).to respond_to(:parse).with(1).argument
20
+ end
59
21
 
60
- specify do
61
- expect(subject).to have_received(:parse_to_s).with('surface')
62
- end
63
- end
64
- end
22
+ describe :parse do
23
+ let :parse do
24
+ subject.parse(string)
65
25
  end
66
26
 
67
- describe MeCab::Light::Binding do
68
- subject { MeCab::Light::Binding }
69
-
70
- before do
71
- new
27
+ context 'with "surface"' do
28
+ let :string do
29
+ 'surface'
72
30
  end
73
31
 
74
- specify do
75
- expect(subject).to have_received(:new).with('')
32
+ it 'should be an instance of MeCab::Light::Result' do
33
+ expect(parse).to eq(result)
76
34
  end
77
35
  end
78
36
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,22 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ Coveralls.wear!
5
+ formatters = [
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter,
8
+ ]
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters]
10
+
11
+ SimpleCov.start do
12
+ add_filter 'spec'
13
+ end
2
14
 
15
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
16
  require 'mecab/light/morpheme'
4
17
  require 'mecab/light/result'
5
18
  require 'mecab/light/tagger'
6
19
 
20
+
7
21
  class MeCab::Light::Binding
8
22
  end
metadata CHANGED
@@ -1,53 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mecab-light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
- - Hajime WAKAHARA
7
+ - Hajime Wakahara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-14 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
41
69
  description: Use a sequence of morphemes as an Enumerable object.
42
70
  email:
43
- - hajime.wakahara@gmail.com
71
+ - hadzimme@icloud.com
44
72
  executables: []
45
73
  extensions:
46
74
  - ext/mecab/light/extconf.rb
47
75
  extra_rdoc_files: []
48
76
  files:
49
- - ".gitignore"
50
- - ".travis.yml"
77
+ - .gitignore
78
+ - .travis.yml
51
79
  - Gemfile
52
80
  - LICENSE.txt
53
81
  - README.md
@@ -73,17 +101,17 @@ require_paths:
73
101
  - lib
74
102
  required_ruby_version: !ruby/object:Gem::Requirement
75
103
  requirements:
76
- - - ">="
104
+ - - '>='
77
105
  - !ruby/object:Gem::Version
78
106
  version: '1.9'
79
107
  required_rubygems_version: !ruby/object:Gem::Requirement
80
108
  requirements:
81
- - - ">="
109
+ - - '>='
82
110
  - !ruby/object:Gem::Version
83
111
  version: '0'
84
112
  requirements: []
85
113
  rubyforge_project:
86
- rubygems_version: 2.2.0
114
+ rubygems_version: 2.2.2
87
115
  signing_key:
88
116
  specification_version: 4
89
117
  summary: An simple interface for MeCab (UNOFFICIAL)