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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f71e38a8bffc439780889b8159cc4eb0edfb4ddc
4
- data.tar.gz: c2b6da744a3da6bf59838437cf9af4d7919d3107
3
+ metadata.gz: 7849c30ac309c96030a34ec2214124f56277b6d6
4
+ data.tar.gz: 23b0b4ea3af054a54fd9fe260328b237bc98a555
5
5
  SHA512:
6
- metadata.gz: 5ba527248b849472c1e4d3ea9d3070c2df322e6a605c43ea40181e14b9e7f427f994d09b00134959f8b88665002dcb1f6bb792d99c8c9386eb03991caf43a9f9
7
- data.tar.gz: 3439477c732e5c94bfe65cc1409c75e0d81765c973bff8c809374ee2563a406ba11e36c89d44476d87121961747ef3455c45c1d33e5d85bc9d05dd11d7e6a9d5
6
+ metadata.gz: 79085c74b79f771afa73131e553de4a076664b7a4fc26c90b9b70efa2852e44f7fccf25528b4bedb7abfad9ec7298ab2a9a1f14a978c118d556b0943fa32f79b
7
+ data.tar.gz: 951a8b39385ce2c85df94f0cc927b5c70d56a4eef537083330c8327db23ae51becce1ff7e522f8f7c808cd3fea8dd1a4a53b56c1b10d1db7127cd2695596690d
@@ -1,3 +1,3 @@
1
1
  module LightMecab
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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 [String]
26
- def i18n(key)
27
- key.is_a?(Symbol) ? @@i18n[key.to_s] : @@i18n[key]
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(method_name)
43
+ if !self.class.i18n[method_name.to_s]
44
44
  raise NoMethodError
45
45
  end
46
- extract(self.class.i18n(method_name))
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')
@@ -0,0 +1,10 @@
1
+ noun: '名詞'
2
+ verb: '動詞'
3
+ aux_verb: '助動詞'
4
+ adjective: '形容詞'
5
+ adverb: '副詞'
6
+ conjunction: '接続詞'
7
+ interjection: '感動詞'
8
+ particle: '助詞'
9
+ ad_adjective: '連体詞'
10
+ symbol: '記号'
@@ -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.2
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-03 00:00:00.000000000 Z
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:
@@ -1,9 +0,0 @@
1
- noun: '名詞'
2
- verb: '動詞'
3
- aux_verb: '助動詞'
4
- adjective: '形容詞'
5
- conjunction: '接続詞'
6
- interjection: '感動詞'
7
- particle: '助詞'
8
- ad_adjective: '連体詞'
9
- symbol: '記号'