mecab-light 0.0.1 → 0.1.1

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: 203c20a8c5d25180dc33640456ac56a975689fa3
4
- data.tar.gz: 0f3605e2ed97c113dc3f01cc9b495936da30dc7c
3
+ metadata.gz: 9bc1034d15fd3f35b2b1ad7d0ef37c2cc73cc827
4
+ data.tar.gz: cfbdc262474d9d30a56e9963e9f8b586f319dd33
5
5
  SHA512:
6
- metadata.gz: 44d1f604138c01311fef9c8a2fabbf649850a7fb557dcc0d6449cb662ce7b5e8739aa506d9059614cea1c5c7b2c9261f2e4abdd24008d63c63a0460f2172f9d5
7
- data.tar.gz: 1388fa676d029f704cf7aa61e8c0b4671fa0e47042005818c93504840f7ba10cb0b0566a540feac431efa468c3ce71bf39ca6947fac0006cddcfdf58ab59d41e
6
+ metadata.gz: 1880e49178c264d6c9fb4e702d022d41742f2f6d9d0f9c46fd25367b155744b55c61518063d03e743dcd9734f10b306070c06bf6ff678f2d29ddcefc9203b614
7
+ data.tar.gz: aa31d0b6a51a66a097815dc30ca973a20fb23d468a8f1ef8cf68ff562f23cf409f4087fe2deaaeea13b23a84a2ed9acba32706ddd781bca038c9f77ed20bfdcf
data/README.md CHANGED
@@ -4,6 +4,8 @@ Use a sequence of results as an Enumerable object.
4
4
 
5
5
  ## Installation
6
6
 
7
+ At first, install the official gem "mecab-ruby" manually.
8
+
7
9
  Add this line to your application's Gemfile:
8
10
 
9
11
  gem 'mecab-light'
@@ -19,11 +21,11 @@ Or install it yourself as:
19
21
  ## Usage
20
22
 
21
23
  ```ruby
22
- require 'mecab-light'
24
+ require 'mecab/light'
23
25
 
24
- mecab = Mecab.new
25
- text = 'この文を形態素解析してください。'
26
- result = mecab.parse(text)
26
+ tagger = MeCab::Light::Tagger.new
27
+ string = 'この文を形態素解析してください。'
28
+ result = tagger.parse(string)
27
29
  result[0].surface #=> "この"
28
30
  result.map{|morpheme| morpheme.surface }
29
31
  #=> ["この", "文", "を", "形態素", "解析", "し", "て", "ください", "。"]
@@ -0,0 +1,6 @@
1
+ require 'MeCab'
2
+ require 'mecab/tagger'
3
+ require 'mecab/light/version'
4
+ require 'mecab/light/morpheme'
5
+ require 'mecab/light/result'
6
+ require 'mecab/light/tagger'
@@ -0,0 +1,10 @@
1
+ module MeCab
2
+ module Light
3
+ class Morpheme
4
+ def initialize(line)
5
+ @surface, @feature = line.chomp.split(/\t/)
6
+ end
7
+ attr_reader :surface, :feature
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ module MeCab
2
+ module Light
3
+ class Result
4
+ include Enumerable
5
+ def initialize(line_enum)
6
+ @morphemes = line_enum.map{|line| Morpheme.new(line) }
7
+ end
8
+
9
+ def each(&block)
10
+ if block_given?
11
+ @morphemes.each(&block)
12
+ self
13
+ else
14
+ self.to_enum
15
+ end
16
+ end
17
+
18
+ def [](nth)
19
+ @morphemes[nth]
20
+ end
21
+
22
+ alias at []
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module MeCab
2
+ module Light
3
+ class Tagger
4
+ def initialize(*args)
5
+ @core_tagger = MeCab::Tagger.new(*args)
6
+ end
7
+
8
+ def parse(string)
9
+ Result.new(@core_tagger.parse_to_enum(string))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module MeCab
2
+ module Light
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module MeCab
2
+ class Tagger
3
+ def parse_to_enum(string)
4
+ self.parse(string).sub(/EOS\n$/, '').each_line
5
+ end
6
+ end
7
+ end
data/mecab-light.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'mecab-light/version'
4
+ require 'mecab/light/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "mecab-light"
8
- gem.version = Mecab::VERSION
8
+ gem.version = MeCab::Light::VERSION
9
9
  gem.authors = ["Hajime WAKAHARA"]
10
10
  gem.email = ["hajime.wakahara@gmail.com"]
11
11
  gem.description = %q{Use a sequence of results as an Enumerable object.}
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+ gem.required_ruby_version = '>= 1.9'
19
20
 
20
21
  gem.add_development_dependency 'rake'
21
22
  gem.add_development_dependency 'rspec'
data/spec/mecab_spec.rb CHANGED
@@ -3,12 +3,12 @@
3
3
  $:.unshift(File.expand_path(File.dirname(__FILE__)) + '/lib')
4
4
 
5
5
  require 'rspec'
6
- require 'mecab-light'
6
+ require 'mecab/light'
7
7
 
8
- describe Mecab::Morpheme do
8
+ describe MeCab::Light::Morpheme do
9
9
  context 'when initialized with the result line of the word "見る"' do
10
10
  before do
11
- @morpheme = Mecab::Morpheme.new(
11
+ @morpheme = MeCab::Light::Morpheme.new(
12
12
  "見る\t動詞,自立,*,*,一段,基本形,見る,ミル,ミル\n")
13
13
  end
14
14
  subject { @morpheme }
@@ -24,10 +24,10 @@ describe Mecab::Morpheme do
24
24
  end
25
25
  end
26
26
  end
27
- describe Mecab::Result do
27
+ describe MeCab::Light::Result do
28
28
  context 'when initialized with the result Enumerator of the word "見る"' do
29
29
  before do
30
- @result = Mecab::Result.new(
30
+ @result = MeCab::Light::Result.new(
31
31
  ["見る\t動詞,自立,*,*,一段,基本形,見る,ミル,ミル\n"].to_enum)
32
32
  end
33
33
  subject { @result }
@@ -51,19 +51,19 @@ describe Mecab::Result do
51
51
  describe '#[]' do
52
52
  context 'when argument 0' do
53
53
  subject { @result[0] }
54
- it { should be_an_instance_of Mecab::Morpheme }
54
+ it { should be_an_instance_of MeCab::Light::Morpheme }
55
55
  end
56
56
  end
57
57
  describe '#at' do
58
58
  context 'when argument 0' do
59
59
  subject { @result.at(0) }
60
- it { should be_an_instance_of Mecab::Morpheme }
60
+ it { should be_an_instance_of MeCab::Light::Morpheme }
61
61
  end
62
62
  end
63
63
  end
64
64
  end
65
- describe Mecab::Tagger do
66
- before { @tagger = Mecab::Tagger.new }
65
+ describe MeCab::Tagger do
66
+ before { @tagger = MeCab::Tagger.new }
67
67
  subject { @tagger }
68
68
  it { should respond_to :parse_to_enum }
69
69
  describe '#parse_to_enum' do
@@ -76,26 +76,26 @@ describe Mecab::Tagger do
76
76
  end
77
77
  end
78
78
  end
79
- describe Mecab do
80
- before { @mecab = Mecab.new }
81
- subject { @mecab }
79
+ describe MeCab::Light::Tagger do
80
+ before { @tagger = MeCab::Light::Tagger.new }
81
+ subject { @tagger }
82
82
  it { should respond_to :parse }
83
83
  describe '#parse' do
84
84
  context 'when argument "見る"' do
85
- before { @result = @mecab.parse('見る') }
85
+ before { @result = @tagger.parse('見る') }
86
86
  subject { @result }
87
- it 'should return Mecab::Result object' do
88
- should be_an_instance_of Mecab::Result
87
+ it 'should return MeCab::Light::Result object' do
88
+ should be_an_instance_of MeCab::Light::Result
89
89
  end
90
90
  its(:count){ should be 1 }
91
- describe 'returned Mecab::Result object' do
91
+ describe 'returned MeCab::Light::Result object' do
92
92
  context '#[0]' do
93
93
  before { @morpheme = @result[0] }
94
94
  subject { @morpheme }
95
- it 'should return Mecab::Morpheme object' do
96
- should be_an_instance_of Mecab::Morpheme
95
+ it 'should return MeCab::Light::Morpheme object' do
96
+ should be_an_instance_of MeCab::Light::Morpheme
97
97
  end
98
- describe 'returned Mecab::Morpheme object' do
98
+ describe 'returned MeCab::Light::Morpheme object' do
99
99
  context '#surface' do
100
100
  subject { @morpheme.surface }
101
101
  it { should eq '見る' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mecab-light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hajime WAKAHARA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-15 00:00:00.000000000 Z
11
+ date: 2013-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -50,11 +50,12 @@ files:
50
50
  - LICENSE.txt
51
51
  - README.md
52
52
  - Rakefile
53
- - lib/mecab-light.rb
54
- - lib/mecab-light/morpheme.rb
55
- - lib/mecab-light/result.rb
56
- - lib/mecab-light/tagger.rb
57
- - lib/mecab-light/version.rb
53
+ - lib/mecab/light.rb
54
+ - lib/mecab/light/morpheme.rb
55
+ - lib/mecab/light/result.rb
56
+ - lib/mecab/light/tagger.rb
57
+ - lib/mecab/light/version.rb
58
+ - lib/mecab/tagger.rb
58
59
  - mecab-light.gemspec
59
60
  - spec/lib/MeCab.rb
60
61
  - spec/mecab_spec.rb
@@ -69,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
70
  requirements:
70
71
  - - '>='
71
72
  - !ruby/object:Gem::Version
72
- version: '0'
73
+ version: '1.9'
73
74
  required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
76
  - - '>='
data/lib/mecab-light.rb DELETED
@@ -1,15 +0,0 @@
1
- require 'MeCab'
2
- require 'mecab-light/version'
3
- require 'mecab-light/tagger'
4
- require 'mecab-light/result'
5
- require 'mecab-light/morpheme'
6
-
7
- class Mecab
8
- def initialize
9
- @tagger = Tagger.new
10
- end
11
-
12
- def parse(string)
13
- Result.new(@tagger.parse_to_enum(string))
14
- end
15
- end
@@ -1,8 +0,0 @@
1
- class Mecab
2
- class Morpheme
3
- def initialize(line)
4
- @surface, @feature = line.chomp.split(/\t/)
5
- end
6
- attr_reader :surface, :feature
7
- end
8
- end
@@ -1,23 +0,0 @@
1
- class Mecab
2
- class Result
3
- include Enumerable
4
- def initialize(line_enum)
5
- @morphemes = line_enum.map{|line| Morpheme.new(line) }
6
- end
7
-
8
- def each(&block)
9
- if block_given?
10
- @morphemes.each(&block)
11
- self
12
- else
13
- self.to_enum
14
- end
15
- end
16
-
17
- def [](nth)
18
- @morphemes[nth]
19
- end
20
-
21
- alias at []
22
- end
23
- end
@@ -1,11 +0,0 @@
1
- class Mecab
2
- class Tagger
3
- def initialize
4
- @tagger = MeCab::Tagger.new
5
- end
6
-
7
- def parse_to_enum(string)
8
- @tagger.parse(string).sub(/EOS\n$/, '').each_line
9
- end
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- class Mecab
2
- VERSION = "0.0.1"
3
- end