light-mecab 0.0.3 → 0.0.4

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: 7849c30ac309c96030a34ec2214124f56277b6d6
4
- data.tar.gz: 23b0b4ea3af054a54fd9fe260328b237bc98a555
3
+ metadata.gz: 68e3e72d4f025c81ade1963d6d0d556ceb91e2ad
4
+ data.tar.gz: f2d313ced0c67a085dcc1a4a33c0b500b4225f23
5
5
  SHA512:
6
- metadata.gz: 79085c74b79f771afa73131e553de4a076664b7a4fc26c90b9b70efa2852e44f7fccf25528b4bedb7abfad9ec7298ab2a9a1f14a978c118d556b0943fa32f79b
7
- data.tar.gz: 951a8b39385ce2c85df94f0cc927b5c70d56a4eef537083330c8327db23ae51becce1ff7e522f8f7c808cd3fea8dd1a4a53b56c1b10d1db7127cd2695596690d
6
+ metadata.gz: a1abeafdabb72ba2056735ff8d7473802c04ce8be5b81b2a9efebb54605d4b5d47e59fb61e326819ee0802a692d547f12916832816b51bcd1f44aab83332a173
7
+ data.tar.gz: eaba3a9e21dc751204e59e3bdf16243ae333e50a94354bf3a1c04d2f165ae04c957ae1ffcaa8e84a1d1fb0503be66513d4d4f2a16ca6378c1d1bfe2119e26745
data/lib/light-mecab.rb CHANGED
@@ -4,6 +4,7 @@ require 'yaml'
4
4
 
5
5
  module LightMecab
6
6
  class Morpheme
7
+ @@tagger = ::MeCab::Tagger.new
7
8
  @@i18n = ::YAML.load_file(File.expand_path(File.join(__FILE__, '..', '..', 'locale', 'morpheme.yml')))
8
9
 
9
10
  class << self
@@ -11,7 +12,7 @@ module LightMecab
11
12
  # @return [Array <MeCab::Node>]
12
13
  def analyze(text)
13
14
  nodes = Array.new
14
- node = ::MeCab::Tagger.new.parseToNode(text)
15
+ node = @@tagger.parseToNode(text)
15
16
  while node
16
17
  nodes << node
17
18
  node = node.next
@@ -21,7 +22,6 @@ module LightMecab
21
22
  nodes
22
23
  end
23
24
 
24
- # @param key [String or Symbol]
25
25
  # @return [Hash]
26
26
  def i18n
27
27
  @@i18n
@@ -53,7 +53,7 @@ module LightMecab
53
53
  def extract(name)
54
54
  morpheme = Array.new
55
55
  @nodes.each do |node|
56
- if name == node.feature.split(',').first.force_encoding('UTF-8')
56
+ if name == node.feature.force_encoding('UTF-8').split(',').first
57
57
  morpheme << node.surface.force_encoding('UTF-8')
58
58
  end
59
59
  end
@@ -1,3 +1,3 @@
1
1
  module LightMecab
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/locale/morpheme.yml CHANGED
@@ -2,7 +2,7 @@ noun: '名詞'
2
2
  verb: '動詞'
3
3
  aux_verb: '助動詞'
4
4
  adjective: '形容詞'
5
- adverb: '副詞'
5
+ adverb: '副詞'
6
6
  conjunction: '接続詞'
7
7
  interjection: '感動詞'
8
8
  particle: '助詞'
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.3
4
+ version: 0.0.4
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-23 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Execute morphological analysis by MeCab
14
14
  email: