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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 34419f00a9e7998a774c20e2904fe320d7e26e70
4
- data.tar.gz: 33d55403194525ae299cd2da0df58b33563853f1
2
+ SHA256:
3
+ metadata.gz: c77fdb882e8e311bbdb239cb5cdc33ad3f8814b3060e8da9b77b627280f45753
4
+ data.tar.gz: dace2a87002bddfb217ee40b454297c6afb7efba0da68e7f7c76bbf8265f69af
5
5
  SHA512:
6
- metadata.gz: 46fe404872c41ff3ab6c368758aaf0ab3b05eebe96fa510e04618af98fb931ced7bdc2a35795c6870486c7c909276c9f3a232b0e0503f733fbc4794666091774
7
- data.tar.gz: 598d32a044a60f6658d786207c19810adca25c8b5930cec13ddd34479a49b11dd04a886e077be323f24ed26224e6511d16553f72022a825bd624feabe2216300
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
@@ -4,10 +4,10 @@
4
4
  $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
5
5
 
6
6
  require 'rginger'
7
- require 'trollop'
7
+ require 'optimist'
8
8
  require 'rainbow/ext/string'
9
9
 
10
- opts = Trollop::options do
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
- Trollop::die "Input text needs to be given" if !input_text || /\A\s*\z/ =~ input_text
28
- Trollop::die "Either 'Correction' or 'Rephrase' option needs to be turned on" if !opts[:correction] && !opts[:rephrase]
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
- Sickill::Rainbow.enabled = false unless opts[:coloring]
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
- puts "Original:".background(:cyan)
78
- puts "\t#{input_text}".bright
79
- end
76
+ # else
77
+ # puts "Original:".background(:cyan)
78
+ # puts "\t#{input_text}".bright
79
+ # end
80
80
 
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
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
 
@@ -14,4 +14,4 @@ module RGinger
14
14
  end
15
15
 
16
16
  require 'rginger/parser'
17
- require 'rginger/version'
17
+ require 'rginger/version'
@@ -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 = URI.escape(text)
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
- text = input.dup
73
- results = {"original" => input, "alternatives" => []}
74
- return results if !text || text == ""
73
+ # text = input.dup
74
+ # results = {"original" => input, "alternatives" => []}
75
+ # return results if !text || text == ""
75
76
 
76
- width = text.length
77
- escaped = URI.escape(text)
78
- url = "#{REPHRASE_ENDPOINT}?s=#{escaped}"
77
+ # width = text.length
78
+ # escaped = CGI.escape(text)
79
+ # url = "#{REPHRASE_ENDPOINT}?s=#{escaped}"
79
80
 
80
- json_data = get_json(url)
81
+ # json_data = get_json(url)
81
82
 
82
- unless json_data.empty? || json_data["Sentences"].empty?
83
- results["alternatives"] = json_data["Sentences"].map{|s| s["Sentence"]}
84
- end
85
- results
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
 
@@ -1,3 +1,3 @@
1
1
  module RGinger
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_development_dependency "bundler"
25
25
  gem.add_development_dependency "rake"
26
- gem.add_runtime_dependency "trollop"
26
+ gem.add_runtime_dependency "optimist"
27
27
  gem.add_runtime_dependency "rainbow"
28
28
  end
@@ -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
- result = @ginger.rephrase(@corrected)
32
+ # def test_rephrasing_sentence
33
+ # result = @ginger.rephrase(@corrected)
34
34
 
35
- assert_equal @corrected, result['original']
36
- assert_equal 4, result['alternatives'].size
37
- assert_equal @alternative, result['alternatives'].first
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
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
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: 2016-02-21 00:00:00.000000000 Z
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: trollop
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
- rubyforge_project:
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: