to_nouns 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: 5c9e257a2eba62b0c0cfede04f006c2b1b1c515e
4
- data.tar.gz: 572df05f9bc07799e37d12b6efc01635d5694e85
2
+ SHA256:
3
+ metadata.gz: e1d8ed005072679ed576386307ad5e682b361a08c210e634fc43137a98657f6b
4
+ data.tar.gz: 5218104f821b4488fd229696b798f80bcfd2d37b069b75670d6bf86adfb4271b
5
5
  SHA512:
6
- metadata.gz: 161e530bb9a9f2fd879cdf9918eab7c1302c4dd5ce5e2ccf8f7a178a142f819eaa37ea31e48a9b652b16371a9b9b8149fcedae63c857f7eef38644b363f6c920
7
- data.tar.gz: c5bd82cd1b5a0bc5c445dfd511308b043daae87333c4aeaf32cec921e7db705982d1f5e2871f80e68d13b9f26596d8d0bda7a7d4efca1cc1f41df4fb5c0320e0
6
+ metadata.gz: 431b6936c5281536022940ea84c086d6d8eeeff414111df1ef8c98fc402f2a89086468bc26b404eb1a9eb3c3d48b721f9621bf8cf23afdc189b93902992a7684
7
+ data.tar.gz: f12661c43a2fe79f42f3c6c783b6c0ab58ecfb3393b21e1893bafa5ac3ffa84173dd855ce64c6c451180807f522df16e6070fb2538a642971fb0d5c783fc1dbb
data/README.md CHANGED
@@ -1,15 +1,27 @@
1
1
  # ToNouns
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/to_nouns`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Using `MeCab` for Retrieving nouns from self.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ ### Prerequisites
8
+
9
+ Make sure following dependencies are installed.
10
+
11
+ * `mecab`
12
+ * `libmecab-dev`
13
+ * `mecab-ipadic-utf8`
14
+
15
+ If `Ubuntu` is running on your machine, these are how you install dependencies:
16
+
17
+ ```shell
18
+ sudo apt-get install mecab libmecab-dev mecab-ipadic-utf8
19
+ ```
20
+
21
+ Add this line to your application's `Gemfile`:
10
22
 
11
23
  ```ruby
12
- gem 'to_nouns'
24
+ gem 'to_nouns', require: false
13
25
  ```
14
26
 
15
27
  And then execute:
@@ -22,7 +34,19 @@ Or install it yourself as:
22
34
 
23
35
  ## Usage
24
36
 
25
- TODO: Write usage instructions here
37
+ Instance method `:to_nouns` will be added to `String` class.
38
+
39
+ ```ruby
40
+ require 'to_nouns'
41
+
42
+ using ToNouns
43
+
44
+ '私は現在、北海道旭川市に住んでいます。'.to_nouns
45
+ => ["私", "現在", "北海道", "旭川", "市"]
46
+
47
+ '私は現在、北海道旭川市に住んでいます。'.to_nouns(general: true)
48
+ => ["私"]
49
+ ```
26
50
 
27
51
  ## Development
28
52
 
data/lib/to_nouns.rb CHANGED
@@ -1,35 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'natto'
2
4
  require 'to_nouns/version'
3
5
 
4
6
  module ToNouns
5
- REQUIRED_METHOD_NAME = :to_s
6
- METHOD_NAME = :to_nouns
7
-
8
- def self.append_features(klass)
9
- unless klass.instance_methods.include? REQUIRED_METHOD_NAME
10
- raise NoMethodError, "##{REQUIRED_METHOD_NAME} is required!"
11
- end
12
-
13
- if klass.instance_methods.include? METHOD_NAME
14
- raise NameError, "##{METHOD_NAME} has already defined!"
15
- end
7
+ refine String do
8
+ def to_nouns(general: false)
9
+ append = general ? ',一般' : nil
10
+ nouns = []
16
11
 
17
- super
18
- end
19
-
20
- def self.included(klass)
21
- klass.class_exec do
22
- define_method(METHOD_NAME) do |general: false|
23
- nouns = []
24
- append = general ? ',一般' : nil
25
-
26
- Natto::MeCab.new.parse(to_s) do |n|
27
- next unless n.feature =~ /名詞#{append}/
28
- nouns << n.surface
29
- end
30
-
31
- nouns
12
+ Natto::MeCab.new.parse(to_s) do |n|
13
+ next unless n.feature =~ /名詞#{append}/
14
+ nouns << n.surface
32
15
  end
16
+
17
+ nouns
33
18
  end
34
19
  end
35
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ToNouns
2
- VERSION = "0.1.0"
4
+ VERSION = '0.2.0'
3
5
  end
data/to_nouns.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
+ spec.required_ruby_version = ">= 2.4.0"
24
25
 
25
26
  spec.add_runtime_dependency "natto"
26
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_nouns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosuke Kabuto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2018-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: natto
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: 2.4.0
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.11
124
+ rubygems_version: 2.7.6
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Retrieving nouns from self.