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 +6 -0
- data/bin/mecab-syllable-count +5 -0
- data/lib/mecab-syllable/syllable.rb +4 -9
- data/lib/mecab-syllable/version.rb +1 -1
- metadata +5 -3
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
|
@@ -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
|
-
|
29
|
-
nodes = mecab.parseToNode(text)
|
24
|
+
nodes = MeCab::Tagger.new.parseToNode(text)
|
30
25
|
syllables = []
|
31
26
|
nodes.each do |node|
|
32
|
-
|
33
|
-
next if
|
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(
|
33
|
+
syllables << select_syllable(surface)
|
39
34
|
end
|
40
35
|
end
|
41
36
|
syllables
|
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.
|
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-
|
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
|