ocr_space 2.1 → 2.2

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: 1209e9f604146297bca5c5a382d32231026396c1
4
- data.tar.gz: 25acb8ade98ac094e9cdc387756364ba515b9af3
3
+ metadata.gz: c34462559994e00ea9b84c27a4d7f54bb54bc62c
4
+ data.tar.gz: 8bdfe01771c7fc294ceb458f6231bfa4e2c950b3
5
5
  SHA512:
6
- metadata.gz: ec007815f8b4ef564a1e153b9b72e621beb7a34a4c498c25edfac37aab6dc1ef9945c28a6c97fdb7b5e39e383e938646920c895d939d216d014145b20629db32
7
- data.tar.gz: b7ac2508555f4a4032d984fd4a926fb2cd1aadeabf160a0e3c7caefa72d0e7a5e9bb93264cd4703b0684575fb99c66d213b11a3778eec9b4c86e9323c828657f
6
+ metadata.gz: 6ad76cda15eb4b316db677020002ed1990214dd42e4ffad65b55146e88dd14cb2d557f87769656178502e629261edabf892915e2674565da1187226b82fa2514
7
+ data.tar.gz: 58a0b8a673b4875dcda3571aff024ff37a6e133fc2771aa0df305926cb0136cb8fab57b152d1106e50f7179fca598136dc1d9b08e2a27f68877b1fd04ea86660
data/README.md CHANGED
@@ -50,7 +50,7 @@ resource = OcrSpace::Resource.new(apikey: "YOUR API KEY")
50
50
 
51
51
  result = resource.convert url: "http://bit.ly/2ih9aXt"
52
52
 
53
- puts result.data
53
+ puts result
54
54
  => #[{"TextOverlay"=>{"Lines"=>[], "HasOverlay"=>false, "Message"=>"Text overlay is not provided as it is not requested"}, "FileParseExitCode"=>1, "ParsedText"=>"If you want to find the secrets of the \r\nuniverse, think in terms of energy, \r\nfrequency and vibration. \r\nAZ QUOTES \r\n", "ErrorMessage"=>"", "ErrorDetails"=>""}]
55
55
 
56
56
  puts result.text_data #Clean result
@@ -65,7 +65,7 @@ puts result.text_data #Clean result
65
65
 
66
66
  result = resource.convert file: "/Users/suyesh/Desktop/nicola_tesla.jpg"
67
67
 
68
- puts result.data #Raw result
68
+ puts result #Raw result
69
69
 
70
70
  => #{"TextOverlay"=>{"Lines"=>[], "HasOverlay"=>false, "Message"=>"Text overlay is not provided as it is not requested"}, "FileParseExitCode"=>1, "ParsedText"=>"If you want to find the secrets of the \r\nuniverse, think in terms of energy, \r\nfrequency and vibration. \r\nAZ QUOTES \r\n", "ErrorMessage"=>"", "ErrorDetails"=>""}
71
71
 
data/exe/ocrspace CHANGED
@@ -9,7 +9,7 @@ else
9
9
  begin
10
10
  resource = OcrSpace::Resource.new
11
11
  result = resource.convert file: ARGV[0]
12
- puts result.text_data.colorize(:orange)
12
+ puts result[0]['ParsedText'].delete("\n").delete("\r").strip
13
13
  rescue
14
14
  puts "Something went wrong, Please try again.".colorize(:red)
15
15
  end
data/lib/ocr_space.rb CHANGED
@@ -12,9 +12,5 @@ module OcrSpace
12
12
  @api_key = apikey
13
13
  @data = nil
14
14
  end
15
-
16
- def text_data
17
- @data[0]['ParsedText'].delete("\n").delete("\r").strip
18
- end
19
15
  end
20
16
  end
@@ -2,7 +2,7 @@ require 'ocr_space/file_post'
2
2
 
3
3
  module OcrSpace
4
4
  module Convert
5
- def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil)
5
+ def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil, clean_result: false)
6
6
  if file
7
7
  @files = File.new(file)
8
8
  @data = OcrSpace::FilePost.post('/parse/image',
@@ -11,6 +11,7 @@ module OcrSpace
11
11
  isOverlayRequired: isOverlayRequired,
12
12
  file: @files })
13
13
  @data = @data.parsed_response['ParsedResults']
14
+ clean_result == true ? @data[0]['ParsedText'].delete("\n").delete("\r").strip : @data = @data.parsed_response['ParsedResults']
14
15
  elsif url
15
16
  @data = HTTParty.post('https://api.ocr.space/parse/image',
16
17
  body: { apikey: apikey,
@@ -18,6 +19,7 @@ module OcrSpace
18
19
  isOverlayRequired: isOverlayRequired,
19
20
  url: url })
20
21
  @data = @data.parsed_response['ParsedResults']
22
+ clean_result == true ? @data[0]['ParsedText'].delete("\n").delete("\r").strip : @data = @data.parsed_response['ParsedResults']
21
23
  else
22
24
  "You need to Pass either file or url."
23
25
  end
@@ -1,3 +1,3 @@
1
1
  module OcrSpace
2
- VERSION = '2.1'.freeze
2
+ VERSION = '2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocr_space
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suyesh Bhandari