rubyrubi 0.1.3 → 0.2.0

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: ea1bbd4fb734d2d150a68403ab95c26041612118
4
- data.tar.gz: 9dcbe1c6170587a18c51306477546530de1ad9e5
3
+ metadata.gz: 7cb77ba08c3b3dc229e661780995c5ab14642ded
4
+ data.tar.gz: 91061794091f1a8f75be1cb86474fae3434364df
5
5
  SHA512:
6
- metadata.gz: 956ed124508a41c6b86f2ea62367ae39d36bb8cf58451ee647058141b006f938c26bd58ead934c21a4b98565163ee48f2aff82b10a401fdb049b98c265ab1c7d
7
- data.tar.gz: 3e2a43fd1bc67707b8ae7e833d97102d151957947c0c0896ccc1be7396778a94864cb6e35d6163f316cb4b6b9a8bc574c4288bee47b0fac69b4fa25380cbfe1b
6
+ metadata.gz: a81489f35977a484b9a99904bf1fa07394cd3c1e39d5798f1bffe308ac2c27ebe57c5aedb34307d0d53e723f5f4f1e0cf507ab1a95cbc7d7afbad1f0e17f4fc1
7
+ data.tar.gz: 6b29c681a67f9b066f0a8871c12a6ac2b68b9f88200ac2caa4720717e71c884cbf6003ad4b8266dfb5535527bfa3ef7e0ef22331f62da9232c01f334b9b8950d
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /vendor/
10
+ /vendor/
11
+ **/spec_config.yml
data/README.md CHANGED
@@ -1,13 +1,11 @@
1
1
  # Rubyrubi
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/rubyrubi`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Yahoo!形態素解析を利用して文字列を解析し、ルビ関係のタグを振って返します。
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ [日本語形態素解析](http://developer.yahoo.co.jp/webapi/jlp/ma/v1/parse.html)
6
6
 
7
7
  ## Installation
8
8
 
9
- Add this line to your application's Gemfile:
10
-
11
9
  ```ruby
12
10
  gem 'rubyrubi'
13
11
  ```
@@ -22,20 +20,23 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
23
+ ```ruby
24
+ rubyrubi = Rubyrubi::Client.new(YOUR_API_KEY)
25
+ rubyrubi.furu(YOUR_TEXT)
26
+ ```
34
27
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/110chang/rubyrubi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
28
+ 出力例
36
29
 
30
+ ```html
31
+ <ruby>青<rp>(</rp><rt>あお</rt><rp>)</rp></ruby>い<ruby>空<rp>(</rp><rt>そら</rt><rp>)</rp></ruby>
32
+ ```
37
33
 
38
34
  ## License
39
35
 
40
36
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
37
 
38
+ ## Acknowledgment
39
+
40
+ このgemは私の作成した初めてのgemです。
41
+ ファイル構造等[Rubyfuri](https://github.com/karur4n/rubyfuri)をベースにさせていただきました。
42
+
data/lib/rubyrubi/api.rb CHANGED
@@ -14,7 +14,8 @@ module Rubyrubi
14
14
  uri.query = {
15
15
  appid: app_id,
16
16
  filter: [*1..13].join('|'),
17
- results: 'ma,uniq',
17
+ results: 'ma',
18
+ ma_response: 'surface,reading,pos,feature',
18
19
  sentence: text,
19
20
  }.to_param
20
21
  #p uri
@@ -37,4 +38,3 @@ module Rubyrubi
37
38
  end
38
39
 
39
40
 
40
-
@@ -2,6 +2,7 @@ module Rubyrubi
2
2
  module Parser
3
3
  KANJI = /^[一-龠]+/
4
4
  OKURI = /[\p{hiragana}\p{katakana}ー〜]+$/
5
+ KOMEI = /固名商品/
5
6
 
6
7
  class Base
7
8
  def initialize(result)
@@ -20,10 +21,16 @@ module Rubyrubi
20
21
 
21
22
  def add_rubi_and_okuri(word)
22
23
  #p word
24
+ if word['feature'] && word['feature'].scan(KOMEI).size > 0
25
+ return word.clone
26
+ end
27
+
23
28
  kanji = word['surface'].scan(KANJI)[0]
29
+
24
30
  if kanji == nil
25
31
  return word.clone
26
32
  end
33
+
27
34
  okuri = word['surface'].scan(OKURI)[0]
28
35
  rubi = kanji == nil && okuri == nil ? nil
29
36
  : word['reading'].gsub(Regexp.new("#{okuri}$"), '')
@@ -1,3 +1,3 @@
1
1
  module Rubyrubi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/rubyrubi.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["u@110chang.com"]
11
11
 
12
12
  spec.summary = %q{Add furigana to japanese “kanji”}
13
- spec.description = %q{Add furigana to japanese “kanji”}
13
+ spec.description = %q{Yahoo!形態素解析を利用して文字列を解析し、ルビ関係のタグを振って返します。}
14
14
  spec.homepage = "https://github.com/110chang/rubyrubi"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyrubi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 110chang
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.2'
97
- description: Add furigana to japanese “kanji”
97
+ description: Yahoo!形態素解析を利用して文字列を解析し、ルビ関係のタグを振って返します。
98
98
  email:
99
99
  - u@110chang.com
100
100
  executables: []