light-mecab 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/light-mecab/version.rb +1 -1
- data/lib/light-mecab.rb +8 -8
- data/locale/morpheme.yml +10 -0
- data/test/test_morpheme.rb +4 -0
- metadata +3 -3
- data/lib/locale/morpheme.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7849c30ac309c96030a34ec2214124f56277b6d6
|
4
|
+
data.tar.gz: 23b0b4ea3af054a54fd9fe260328b237bc98a555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79085c74b79f771afa73131e553de4a076664b7a4fc26c90b9b70efa2852e44f7fccf25528b4bedb7abfad9ec7298ab2a9a1f14a978c118d556b0943fa32f79b
|
7
|
+
data.tar.gz: 951a8b39385ce2c85df94f0cc927b5c70d56a4eef537083330c8327db23ae51becce1ff7e522f8f7c808cd3fea8dd1a4a53b56c1b10d1db7127cd2695596690d
|
data/lib/light-mecab/version.rb
CHANGED
data/lib/light-mecab.rb
CHANGED
@@ -4,13 +4,13 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
module LightMecab
|
6
6
|
class Morpheme
|
7
|
-
@@i18n = ::YAML.load_file(File.expand_path(File.join(__FILE__, '..', 'locale', 'morpheme.yml')))
|
7
|
+
@@i18n = ::YAML.load_file(File.expand_path(File.join(__FILE__, '..', '..', 'locale', 'morpheme.yml')))
|
8
8
|
|
9
9
|
class << self
|
10
10
|
# @param text [String]
|
11
11
|
# @return [Array <MeCab::Node>]
|
12
12
|
def analyze(text)
|
13
|
-
nodes =
|
13
|
+
nodes = Array.new
|
14
14
|
node = ::MeCab::Tagger.new.parseToNode(text)
|
15
15
|
while node
|
16
16
|
nodes << node
|
@@ -22,9 +22,9 @@ module LightMecab
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# @param key [String or Symbol]
|
25
|
-
# @return [
|
26
|
-
def i18n
|
27
|
-
|
25
|
+
# @return [Hash]
|
26
|
+
def i18n
|
27
|
+
@@i18n
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -40,10 +40,10 @@ module LightMecab
|
|
40
40
|
|
41
41
|
# @param method_name [Symbol]
|
42
42
|
def method_missing(method_name)
|
43
|
-
if !self.class.i18n
|
43
|
+
if !self.class.i18n[method_name.to_s]
|
44
44
|
raise NoMethodError
|
45
45
|
end
|
46
|
-
extract(self.class.i18n
|
46
|
+
extract(self.class.i18n[method_name.to_s])
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
@@ -51,7 +51,7 @@ module LightMecab
|
|
51
51
|
# @param name [String]
|
52
52
|
# @return [Array <String>]
|
53
53
|
def extract(name)
|
54
|
-
morpheme =
|
54
|
+
morpheme = Array.new
|
55
55
|
@nodes.each do |node|
|
56
56
|
if name == node.feature.split(',').first.force_encoding('UTF-8')
|
57
57
|
morpheme << node.surface.force_encoding('UTF-8')
|
data/locale/morpheme.yml
ADDED
data/test/test_morpheme.rb
CHANGED
@@ -30,6 +30,10 @@ class TC_LightMecab_Morpheme < Test::Unit::TestCase
|
|
30
30
|
assert_equal(['美しい'], @morpheme.adjective)
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_method_missing_adverb
|
34
|
+
assert_equal([], @morpheme.adverb)
|
35
|
+
end
|
36
|
+
|
33
37
|
def test_method_missing_conjunction
|
34
38
|
assert_equal(['そして'], @morpheme.conjunction)
|
35
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light-mecab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kei Tsuchiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Execute morphological analysis by MeCab
|
14
14
|
email:
|
@@ -24,8 +24,8 @@ files:
|
|
24
24
|
- Rakefile
|
25
25
|
- lib/light-mecab.rb
|
26
26
|
- lib/light-mecab/version.rb
|
27
|
-
- lib/locale/morpheme.yml
|
28
27
|
- light-mecab.gemspec
|
28
|
+
- locale/morpheme.yml
|
29
29
|
- test/test_morpheme.rb
|
30
30
|
homepage: https://github.com/kei500/light-mecab
|
31
31
|
licenses:
|