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 +4 -4
- data/.gitignore +2 -1
- data/README.md +15 -14
- data/lib/rubyrubi/api.rb +2 -2
- data/lib/rubyrubi/parser/base.rb +7 -0
- data/lib/rubyrubi/version.rb +1 -1
- data/rubyrubi.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cb77ba08c3b3dc229e661780995c5ab14642ded
|
4
|
+
data.tar.gz: 91061794091f1a8f75be1cb86474fae3434364df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81489f35977a484b9a99904bf1fa07394cd3c1e39d5798f1bffe308ac2c27ebe57c5aedb34307d0d53e723f5f4f1e0cf507ab1a95cbc7d7afbad1f0e17f4fc1
|
7
|
+
data.tar.gz: 6b29c681a67f9b066f0a8871c12a6ac2b68b9f88200ac2caa4720717e71c884cbf6003ad4b8266dfb5535527bfa3ef7e0ef22331f62da9232c01f334b9b8950d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
# Rubyrubi
|
2
2
|
|
3
|
-
|
3
|
+
Yahoo!形態素解析を利用して文字列を解析し、ルビ関係のタグを振って返します。
|
4
4
|
|
5
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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
|
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
|
-
|
data/lib/rubyrubi/parser/base.rb
CHANGED
@@ -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}$"), '')
|
data/lib/rubyrubi/version.rb
CHANGED
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{
|
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.
|
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:
|
97
|
+
description: Yahoo!形態素解析を利用して文字列を解析し、ルビ関係のタグを振って返します。
|
98
98
|
email:
|
99
99
|
- u@110chang.com
|
100
100
|
executables: []
|