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 +4 -4
- data/README.md +2 -2
- data/exe/ocrspace +1 -1
- data/lib/ocr_space.rb +0 -4
- data/lib/ocr_space/convert.rb +3 -1
- data/lib/ocr_space/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c34462559994e00ea9b84c27a4d7f54bb54bc62c
|
4
|
+
data.tar.gz: 8bdfe01771c7fc294ceb458f6231bfa4e2c950b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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.
|
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
data/lib/ocr_space/convert.rb
CHANGED
@@ -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
|
data/lib/ocr_space/version.rb
CHANGED