jkproof 0.1.0 → 1.0.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 +4 -4
- data/.env.sample +2 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +6 -2
- data/README.md +50 -6
- data/jkproof.gemspec +6 -6
- data/lib/jkproof/sentence.rb +10 -5
- data/lib/jkproof/version.rb +1 -1
- data/lib/jkproof.rb +2 -7
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0addda3ea12086f43d3170f5e24aae959c91c6c37b6ef2a493f2308c4cb0650c
|
4
|
+
data.tar.gz: 88f34a95526329f102c061f9f6cc99568437b36257a70724f18435b87b89344c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82beac07b25fa4677d459301af44475d03ffafdb1fcf31e550fd81eb63c95726db6d81551c1dcac0ca45ea098cc0746a357bffecae5c1a91f91644ecbe0d21ac
|
7
|
+
data.tar.gz: 87bcf0b06d7dc56fe73ebc658abc95d990e2f97cbdb2859c0c5e2f9abbb6b2e779819442a133377fc8b192e289e8e991347bd53f07181e2aad624f8c479bde68
|
data/.env.sample
ADDED
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,6 +2,10 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
jkproof (0.1.0)
|
5
|
+
activesupport
|
6
|
+
dotenv
|
7
|
+
highline
|
8
|
+
xml-simple
|
5
9
|
|
6
10
|
GEM
|
7
11
|
remote: https://rubygems.org/
|
@@ -13,6 +17,8 @@ GEM
|
|
13
17
|
tzinfo (~> 1.1)
|
14
18
|
concurrent-ruby (1.1.4)
|
15
19
|
diff-lcs (1.3)
|
20
|
+
dotenv (2.5.0)
|
21
|
+
highline (2.0.0)
|
16
22
|
i18n (1.3.0)
|
17
23
|
concurrent-ruby (~> 1.0)
|
18
24
|
minitest (5.11.3)
|
@@ -39,12 +45,10 @@ PLATFORMS
|
|
39
45
|
ruby
|
40
46
|
|
41
47
|
DEPENDENCIES
|
42
|
-
activesupport
|
43
48
|
bundler (~> 1.17)
|
44
49
|
jkproof!
|
45
50
|
rake (~> 10.0)
|
46
51
|
rspec (~> 3.0)
|
47
|
-
xml-simple
|
48
52
|
|
49
53
|
BUNDLED WITH
|
50
54
|
1.17.1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# [Jkproof](https://rubygems.org/gems/jkproof)
|
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/
|
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/jkproof`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'jkproof'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,11 +18,55 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install
|
21
|
+
$ gem install jkproof
|
22
|
+
|
23
|
+
### `dictionary.yml` を任意の場所に追加する
|
24
|
+
|
25
|
+
`config/dictionary.yml` など、好きな場所に辞書ファイルを準備します。
|
26
|
+
|
27
|
+
**config/dictionary.yml**
|
28
|
+
```yml
|
29
|
+
word1:
|
30
|
+
correct : correct_word_1
|
31
|
+
wrongs :
|
32
|
+
word1 : wrong-word-1
|
33
|
+
word2 : WrongWord1
|
34
|
+
word2:
|
35
|
+
correct : CorrectWord2
|
36
|
+
wrongs :
|
37
|
+
word1 : wrong_word_2
|
38
|
+
word1 : wrongword2
|
39
|
+
```
|
40
|
+
|
41
|
+
一つの単号に対して、誤りのある単語を複数追加できます。
|
42
|
+
|
43
|
+
必ず文字数が多いものから降順になるように並べてください。
|
44
|
+
|
45
|
+
```yml
|
46
|
+
# いい例
|
47
|
+
wrongs :
|
48
|
+
word1 : wrong-word-1
|
49
|
+
word2 : WrongWord1
|
50
|
+
word3 : Wrong1
|
51
|
+
|
52
|
+
# 悪い例
|
53
|
+
wrongs :
|
54
|
+
word1 : Wrong1
|
55
|
+
word2 : WrongWord1
|
56
|
+
word3 : wrong-word-1
|
57
|
+
```
|
22
58
|
|
23
59
|
## Usage
|
24
60
|
|
25
|
-
|
61
|
+
```ruby
|
62
|
+
# 検出された場合
|
63
|
+
Jkproof.detect_words_has_error("検知したい文章", "config/dictionary.yml")
|
64
|
+
# => [{ wrong: WrongWord, correct:CorrectWord }]
|
65
|
+
|
66
|
+
# 検出されなかった場合
|
67
|
+
Jkproof.detect_words_has_error("", "config/dictionary.yml")
|
68
|
+
# => []
|
69
|
+
```
|
26
70
|
|
27
71
|
## Development
|
28
72
|
|
@@ -32,4 +76,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
76
|
|
33
77
|
## Contributing
|
34
78
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/
|
79
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jkproof.
|
data/jkproof.gemspec
CHANGED
@@ -7,9 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = Jkproof::VERSION
|
8
8
|
spec.authors = ['tosite']
|
9
9
|
spec.email = ['tl091264@gmail.com']
|
10
|
-
|
11
|
-
spec.
|
12
|
-
spec.description = 'test.'
|
10
|
+
spec.summary = 'This performs sentence proofreading using a dictionary.yml.'
|
11
|
+
spec.description = 'This performs sentence proofreading using a dictionary.yml.'
|
13
12
|
spec.homepage = 'https://github.com/tosite0345/jkproof'
|
14
13
|
|
15
14
|
# spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.}
|
@@ -41,7 +40,8 @@ Gem::Specification.new do |spec|
|
|
41
40
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
42
41
|
spec.add_development_dependency 'rake', '~> 10.0'
|
43
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
44
|
-
|
45
|
-
spec.
|
46
|
-
spec.
|
43
|
+
spec.add_dependency 'activesupport'
|
44
|
+
spec.add_dependency 'xml-simple'
|
45
|
+
spec.add_dependency 'dotenv'
|
46
|
+
spec.add_dependency 'highline'
|
47
47
|
end
|
data/lib/jkproof/sentence.rb
CHANGED
@@ -2,12 +2,16 @@ module Jkproof
|
|
2
2
|
class Sentence
|
3
3
|
require 'yaml'
|
4
4
|
require 'uri'
|
5
|
+
require 'dotenv'
|
5
6
|
require 'net/https'
|
6
7
|
require 'active_support'
|
7
8
|
require 'active_support/core_ext'
|
8
9
|
|
9
|
-
def initialize(buf
|
10
|
-
|
10
|
+
def initialize(buf)
|
11
|
+
Dotenv.load
|
12
|
+
yml_path = ENV["DICTIONARY_YML_PATH"]
|
13
|
+
@yahoo_api_key = ENV["YAHOO_API_KEY"]
|
14
|
+
@dictionary_words = (yml_path.blank?) ? [] : YAML.load_file(yml_path)
|
11
15
|
@yahoo_words = []
|
12
16
|
@buf = buf
|
13
17
|
fetch_yahoo_lint_words
|
@@ -36,13 +40,16 @@ module Jkproof
|
|
36
40
|
private
|
37
41
|
|
38
42
|
def fetch_yahoo_lint_words
|
43
|
+
if @yahoo_api_key.blank? || @yahoo_api_key.size < 10
|
44
|
+
raise "There is no Yahoo API Key.Please set API Key in 'jkproof/.env'.(ref: https://e.developer.yahoo.co.jp/dashboard/)"
|
45
|
+
end
|
39
46
|
# ref: http://developer.yahoo.co.jp/webapi/jlp/kousei/v1/kousei.html
|
40
47
|
uri = URI.parse('https://jlp.yahooapis.jp/KouseiService/V1/kousei')
|
41
48
|
http = Net::HTTP.new(uri.host, uri.port)
|
42
49
|
http.use_ssl = true
|
43
50
|
reqest = Net::HTTP::Post.new(uri.path)
|
44
51
|
reqest.set_form_data(
|
45
|
-
appid:
|
52
|
+
appid: @yahoo_api_key,
|
46
53
|
sentence: @buf,
|
47
54
|
no_filter: '11'
|
48
55
|
# no_filter: "11,12,14,15"
|
@@ -52,8 +59,6 @@ module Jkproof
|
|
52
59
|
[Hash.from_xml(s)['ResultSet']['Result']].flatten.each do |r|
|
53
60
|
next unless r['Surface']
|
54
61
|
next unless r['ShitekiWord']
|
55
|
-
|
56
|
-
# p r
|
57
62
|
@yahoo_words.push(correct: r['ShitekiWord'], wrong: r['Surface'])
|
58
63
|
end
|
59
64
|
end
|
data/lib/jkproof/version.rb
CHANGED
data/lib/jkproof.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
require 'jkproof/version'
|
2
2
|
require 'jkproof/sentence'
|
3
|
-
require 'yaml'
|
4
|
-
require 'uri'
|
5
|
-
require 'net/https'
|
6
|
-
require 'active_support'
|
7
|
-
require 'active_support/core_ext'
|
8
3
|
|
9
4
|
module Jkproof
|
10
5
|
class Error < StandardError; end
|
11
6
|
|
12
|
-
def self.detect_words_has_error(sentence
|
13
|
-
obj = Sentence.new(sentence
|
7
|
+
def self.detect_words_has_error(sentence)
|
8
|
+
obj = Sentence.new(sentence)
|
14
9
|
obj.fetch_wrong_words
|
15
10
|
end
|
16
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jkproof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tosite
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -73,20 +73,49 @@ dependencies:
|
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dotenv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: highline
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
|
-
description:
|
111
|
+
description: This performs sentence proofreading using a dictionary.yml.
|
84
112
|
email:
|
85
113
|
- tl091264@gmail.com
|
86
114
|
executables: []
|
87
115
|
extensions: []
|
88
116
|
extra_rdoc_files: []
|
89
117
|
files:
|
118
|
+
- ".env.sample"
|
90
119
|
- ".gitignore"
|
91
120
|
- ".rspec"
|
92
121
|
- ".travis.yml"
|
@@ -126,5 +155,5 @@ rubyforge_project:
|
|
126
155
|
rubygems_version: 2.7.6
|
127
156
|
signing_key:
|
128
157
|
specification_version: 4
|
129
|
-
summary:
|
158
|
+
summary: This performs sentence proofreading using a dictionary.yml.
|
130
159
|
test_files: []
|