rginger 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -0
- data/bin/rginger +24 -24
- data/lib/rginger.rb +1 -1
- data/lib/rginger/parser.rb +15 -14
- data/lib/rginger/version.rb +1 -1
- data/rginger.gemspec +1 -1
- data/test/test_rginger.rb +6 -6
- data/vendor/cache/optimist-3.0.0.gem +0 -0
- data/vendor/cache/rainbow-3.0.0.gem +0 -0
- data/vendor/cache/rake-12.3.2.gem +0 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c77fdb882e8e311bbdb239cb5cdc33ad3f8814b3060e8da9b77b627280f45753
|
4
|
+
data.tar.gz: dace2a87002bddfb217ee40b454297c6afb7efba0da68e7f7c76bbf8265f69af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 670a6dff1c8b278a8b56735eb742c68505bc13f4bc68101058e295868d6bf04d28eb7964391d8c1a1b28e78764fd7bf4a2a409b0854a565a4dceb6965a936458
|
7
|
+
data.tar.gz: 136747c7756d76600bb29b7624f83446e2ab8b3f74b9a429961678a3e0167f3bf70647a0ec3e413d32db273363fa05741ac15708f5a748f04b675eba57dedde3
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
RGinger takes an English sentence and gives correction and rephrasing suggestions for it using Ginger proofreading API. It can be used both as a Ruby library and a command line application.
|
4
4
|
|
5
|
+
**IMPORTANT**<br />
|
6
|
+
Version 0.1.5 dropped `rephrase` option and `Rginger#rephrase` function because the API endpoint for these is no longer functioning. The relevant documentation in this readme will be kept as it was for the time being though.
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
$ gem install rginger
|
data/bin/rginger
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
$:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
|
5
5
|
|
6
6
|
require 'rginger'
|
7
|
-
require '
|
7
|
+
require 'optimist'
|
8
8
|
require 'rainbow/ext/string'
|
9
9
|
|
10
|
-
opts =
|
10
|
+
opts = Optimist::options do
|
11
11
|
version RGinger::VERSION
|
12
12
|
banner <<-EOS
|
13
13
|
RGinger uses Ginger proofreading API and acquires correction and rephrasing suggestions for input English sentence.
|
@@ -18,16 +18,16 @@ Usage:
|
|
18
18
|
EOS
|
19
19
|
|
20
20
|
opt :coloring, "Get colorful output", :default => true
|
21
|
-
opt :correction, "Get suggestions for correcting the original sentence", :default => true
|
22
|
-
opt :rephrase, "Get suggestions for rephrasing the original sentence", :default => true
|
21
|
+
# opt :correction, "Get suggestions for correcting the original sentence", :default => true
|
22
|
+
# opt :rephrase, "Get suggestions for rephrasing the original sentence", :default => true
|
23
23
|
end
|
24
24
|
|
25
25
|
input_text = ARGV ? ARGV.join(" ").dup : ""
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
Optimist::die "Input text needs to be given" if !input_text || /\A\s*\z/ =~ input_text
|
28
|
+
# Optimist::die "Either 'Correction' or 'Rephrase' option needs to be turned on" if !opts[:correction] && !opts[:rephrase]
|
29
29
|
|
30
|
-
|
30
|
+
Rainbow.enabled = false unless opts[:coloring]
|
31
31
|
|
32
32
|
begin
|
33
33
|
|
@@ -36,7 +36,7 @@ begin
|
|
36
36
|
|
37
37
|
puts ""
|
38
38
|
|
39
|
-
if opts[:correction]
|
39
|
+
# if opts[:correction]
|
40
40
|
result1 = ginger.correct(input_text)
|
41
41
|
data = result1["data"]
|
42
42
|
if !data.empty?
|
@@ -73,23 +73,23 @@ begin
|
|
73
73
|
puts "CORRECTED:".background(:green)
|
74
74
|
puts "\tNo suggestion returned".foreground(:magenta)
|
75
75
|
end
|
76
|
-
else
|
77
|
-
|
78
|
-
|
79
|
-
end
|
76
|
+
# else
|
77
|
+
# puts "Original:".background(:cyan)
|
78
|
+
# puts "\t#{input_text}".bright
|
79
|
+
# end
|
80
80
|
|
81
|
-
if opts[:rephrase]
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
81
|
+
# if opts[:rephrase]
|
82
|
+
# input_text = corrected if corrected
|
83
|
+
# result2 = ginger.rephrase(input_text)["alternatives"]
|
84
|
+
# puts "ALTERNATIVES:".background(:cyan)
|
85
|
+
# if !result2.empty?
|
86
|
+
# result2.each do |r|
|
87
|
+
# puts "\t" + r.bright
|
88
|
+
# end
|
89
|
+
# else
|
90
|
+
# puts "\tNo suggestion returned".foreground(:magenta)
|
91
|
+
# end
|
92
|
+
# end
|
93
93
|
|
94
94
|
puts ""
|
95
95
|
|
data/lib/rginger.rb
CHANGED
data/lib/rginger/parser.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
|
+
require 'cgi'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module RGinger
|
@@ -18,7 +19,7 @@ module RGinger
|
|
18
19
|
end
|
19
20
|
|
20
21
|
width = text.length
|
21
|
-
escaped =
|
22
|
+
escaped = CGI.escape(text)
|
22
23
|
url = "#{API_ENDPOINT}?lang=#{DEFAULT_LANG}&clientVersion=#{API_VERSION}&apiKey=#{API_KEY}&text=#{escaped}"
|
23
24
|
|
24
25
|
json_data = get_json(url)["LightGingerTheTextResult"] rescue {}
|
@@ -67,23 +68,23 @@ module RGinger
|
|
67
68
|
results
|
68
69
|
end
|
69
70
|
|
70
|
-
def rephrase(input)
|
71
|
+
# def rephrase(input)
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
# text = input.dup
|
74
|
+
# results = {"original" => input, "alternatives" => []}
|
75
|
+
# return results if !text || text == ""
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
# width = text.length
|
78
|
+
# escaped = CGI.escape(text)
|
79
|
+
# url = "#{REPHRASE_ENDPOINT}?s=#{escaped}"
|
79
80
|
|
80
|
-
|
81
|
+
# json_data = get_json(url)
|
81
82
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
83
|
+
# unless json_data.empty? || json_data["Sentences"].empty?
|
84
|
+
# results["alternatives"] = json_data["Sentences"].map{|s| s["Sentence"]}
|
85
|
+
# end
|
86
|
+
# results
|
87
|
+
# end
|
87
88
|
|
88
89
|
:private
|
89
90
|
|
data/lib/rginger/version.rb
CHANGED
data/rginger.gemspec
CHANGED
data/test/test_rginger.rb
CHANGED
@@ -29,12 +29,12 @@ class TestRGinger < Test::Unit::TestCase
|
|
29
29
|
assert_equal "woke", result['data'].first['new']
|
30
30
|
end
|
31
31
|
|
32
|
-
def test_rephrasing_sentence
|
33
|
-
|
32
|
+
# def test_rephrasing_sentence
|
33
|
+
# result = @ginger.rephrase(@corrected)
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
35
|
+
# assert_equal @corrected, result['original']
|
36
|
+
# assert_equal 4, result['alternatives'].size
|
37
|
+
# assert_equal @alternative, result['alternatives'].first
|
38
|
+
# end
|
39
39
|
|
40
40
|
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rginger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: optimist
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -86,6 +86,9 @@ files:
|
|
86
86
|
- lib/rginger/version.rb
|
87
87
|
- rginger.gemspec
|
88
88
|
- test/test_rginger.rb
|
89
|
+
- vendor/cache/optimist-3.0.0.gem
|
90
|
+
- vendor/cache/rainbow-3.0.0.gem
|
91
|
+
- vendor/cache/rake-12.3.2.gem
|
89
92
|
homepage: https://github.com/yohasebe/rginger
|
90
93
|
licenses:
|
91
94
|
- MIT
|
@@ -105,12 +108,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
108
|
- !ruby/object:Gem::Version
|
106
109
|
version: '0'
|
107
110
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.5.1
|
111
|
+
rubygems_version: 3.0.1
|
110
112
|
signing_key:
|
111
113
|
specification_version: 4
|
112
114
|
summary: RGinger takes an English sentence and gives correction and rephrasing suggestions
|
113
115
|
for it using Ginger proofreading API.
|
114
116
|
test_files:
|
115
117
|
- test/test_rginger.rb
|
116
|
-
has_rdoc:
|