mecab-syllable 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,11 +20,17 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ ### source code
24
+
23
25
  require 'MeCab'
24
26
  require 'mecab-syllable'
25
27
 
26
28
  p MeCab::Syllable.new("今日は雨").count #=> 5
27
29
 
30
+ ### command line
31
+
32
+ $ mecab-syllable-count 今日は雨 #=> 5
33
+
28
34
  ## Contributing
29
35
 
30
36
  1. Fork it
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'mecab-syllable'
5
+ puts MeCab::Syllable.new(ARGV[0]).count
@@ -5,10 +5,6 @@ require 'mecab-modern'
5
5
 
6
6
  module MeCab
7
7
  class Node
8
- def part
9
- surface
10
- end
11
-
12
8
  def kana
13
9
  feature.split(/,/)[8]
14
10
  end
@@ -25,17 +21,16 @@ module MeCab
25
21
 
26
22
  private
27
23
  def split(text)
28
- mecab = MeCab::Tagger.new
29
- nodes = mecab.parseToNode(text)
24
+ nodes = MeCab::Tagger.new.parseToNode(text)
30
25
  syllables = []
31
26
  nodes.each do |node|
32
- part = node.part
33
- next if part.empty?
27
+ surface = node.surface
28
+ next if surface.empty?
34
29
  kana = node.kana
35
30
  if kana
36
31
  syllables << select_syllable(kana)
37
32
  else
38
- syllables << select_syllable(part)
33
+ syllables << select_syllable(surface)
39
34
  end
40
35
  end
41
36
  syllables
@@ -1,5 +1,5 @@
1
1
  module MeCab
2
2
  class Syllable
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mecab-syllable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-06 00:00:00.000000000 Z
12
+ date: 2012-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mecab-modern
@@ -62,7 +62,8 @@ dependencies:
62
62
  description: Function addition for mecab-ruby. Supporting syllable parse.
63
63
  email:
64
64
  - myokoym@gmail.com
65
- executables: []
65
+ executables:
66
+ - mecab-syllable-count
66
67
  extensions: []
67
68
  extra_rdoc_files: []
68
69
  files:
@@ -75,6 +76,7 @@ files:
75
76
  - LICENSE.txt
76
77
  - README.md
77
78
  - Rakefile
79
+ - bin/mecab-syllable-count
78
80
  - lib/mecab-syllable.rb
79
81
  - lib/mecab-syllable/syllable.rb
80
82
  - lib/mecab-syllable/version.rb