ocr_space 0.1.1 → 0.1.6

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: 99d456f99f48b1107cc374765812db2ca039d377
4
- data.tar.gz: 5fd5b589c29276657c86eafda3219aa60d6e9e7e
3
+ metadata.gz: adf78804d8f86f505cbb85d628bacfa2d7e88252
4
+ data.tar.gz: 21b34b2138b6c64977fdc83b198f7078f8f75c60
5
5
  SHA512:
6
- metadata.gz: 2f7e8dc705a337ae1be26e8832f998702ef6e7be7495319d2a259138fcc1d250c34c65bcd0439d52ca016481c7f966efe463f9668bb11d0941106d93f0aca731
7
- data.tar.gz: 7ae0ff18bdd3c6a86fe8ec595c02692fad6b68b036f51ca4ec15fd746eb13eabfc856376424bd8de85801a499b3970525fc2aae20eca4beb921fce28703ad723
6
+ metadata.gz: e6c7af9d1ece5be97c5dcf81dfb4e2a367b9897d5fe14250be64f858b2622fe2c80ac9f6f966694f1a41104fe6e999bdcea9b7c1b1c80044017ea7c7878af1d4
7
+ data.tar.gz: fe9e96e64e427848074f2d13b8a5f9350a372acdd95d52f499d9d42b6d2e9ebccd197b7b2e0635b64fa9cc23b8665bd8259c7ad098f26c256211c15bff219cb6
data/README.md CHANGED
@@ -26,20 +26,39 @@ Or install it yourself as:
26
26
 
27
27
  ```ruby
28
28
  result = OcrSpace::FromUrl.new(apikey: "YOUR API KEY", url: "Image url")
29
- puts result.data
29
+
30
+ puts result #Raw result
31
+
32
+ => #<OcrSpace::FromUrl:0x007ff524394128 @data=#<HTTParty::Response:0x7ff52433fc68 parsed_response={"ParsedResults"=>[{"TextOverlay"=>{"Lines"=>[], "HasOverlay"=>false, "Message"=>"Text overlay is not provided as it is not requested"}, "FileParseExitCode"=>1, "ParsedText"=>"I am curious about \r\narea-filling text \r\nrendering options \r\n", "ErrorMessage"=>"", "ErrorDetails"=>""}], "OCRExitCode"=>1, "IsErroredOnProcessing"=>false, "ErrorMessage"=>nil, "ErrorDetails"=>nil, "ProcessingTimeInMilliseconds"=>"325"}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"cache-control"=>["no-cache"], "pragma"=>["no-cache"], "content-length"=>["395"], "content-type"=>["application/json; charset=utf-8"], "expires"=>["-1"], "server"=>["Microsoft-IIS/10.0"], "x-aspnet-version"=>["4.0.30319"], "x-powered-by"=>["ASP.NET"], "date"=>["Fri, 02 Dec 2016 04:09:45 GMT"], "connection"=>["close"]}>>
33
+
34
+ puts result.text_data #Clean result
35
+
36
+ => "I am curious about \r\narea-filling text \r\nrendering options \r\n"
30
37
  ```
31
38
 
32
39
  #To convert images from file upload
33
40
 
34
41
  ```ruby
35
42
  result = OcrSpace::FromFile.new(apikey: "YOUR API KEY", files: "Path to file")
36
- puts result.data
37
43
  ```
44
+ #Optional
45
+
46
+ You can also pass in Optional attributes
38
47
 
39
- #NOTE
48
+ ```ruby
40
49
 
41
- I will continue working on this to make it awesomer.
50
+ isOverlayRequired:
51
+ [#Optional] Default = False Allows you to specify if the image/pdf text overlay is required. Overlay could be #used to show the text over the image
42
52
 
43
- #TODO
53
+ language:
44
54
 
45
- Make command line utility
55
+ #Czech = ce; Danish = dan; Dutch = dut; English = eng; Finnish = fin; French = fre; German = ger;Hungarian=hun;
56
+ #Italian = ita; Norwegian = nor; Polish = pol; Portuguese = por; Spanish = spa; Swedish = swe; #ChineseSimplified = chs; Greek = gre; Japanese = jpn; Russian = rus; Turkish = tur; ChineseTraditional = cht; #Korean = kor
57
+ ```
58
+ #COMMAND LINE INTERFACE ***BONUS***
59
+
60
+ You can run ocr_space through shell to get quick result from a image in a folder
61
+
62
+ ```
63
+ $ ocrspace hello.png
64
+ ```
data/exe/ocr_space ADDED
@@ -0,0 +1,15 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ require_relative "../lib/ocr_space/from_file"
4
+
5
+ if ARGV.empty?
6
+ puts "You need to mention the image path"
7
+ else
8
+ begin
9
+ result = OcrSpace::FromFile.new(files: ARGV[0])
10
+ rescue
11
+ puts "Something went wrong, Please try again."
12
+ end
13
+ end
14
+
15
+ puts result.text_data
@@ -0,0 +1,8 @@
1
+ require 'httmultiparty'
2
+
3
+ module OcrSpace
4
+ class FilePost
5
+ include HTTMultiParty
6
+ base_uri 'https://api.ocr.space'
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ require 'ocr_space/file_post'
2
+ require 'fileutils'
3
+
4
+ module OcrSpace
5
+ class FromFile
6
+ attr_reader :data
7
+ def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil, ocr_space: "https://api.ocr.space/parse/image")
8
+ @file = File.new(files)
9
+ @data = OcrSpace::FilePost.post("/parse/image",
10
+ body: { apikey: apikey,
11
+ language: language,
12
+ isOverlayRequired: isOverlayRequired,
13
+ files: @file})
14
+ end
15
+ def text_data
16
+ self.data.parsed_response["ParsedResults"][0]["ParsedText"]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'httparty'
2
+
3
+ module OcrSpace
4
+ class FromUrl
5
+ attr_reader :data
6
+ def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, url: nil, ocr_space: "https://api.ocr.space/parse/image")
7
+ @data = HTTParty.post("https://api.ocr.space/parse/image",
8
+ body: { apikey: apikey,
9
+ language: language,
10
+ isOverlayRequired: isOverlayRequired,
11
+ url: url})
12
+ end
13
+
14
+ def text_data
15
+ self.data.parsed_response["ParsedResults"][0]["ParsedText"]
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module OcrSpace
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/ocr_space.rb CHANGED
@@ -1,34 +1,3 @@
1
1
  require "ocr_space/version"
2
- require 'httparty'
3
- require 'httmultiparty'
4
- require 'fileutils'
5
-
6
- module OcrSpace
7
- class FromUrl
8
- attr_reader :data
9
- def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, url: nil, ocr_space: "https://api.ocr.space/parse/image")
10
- @data = HTTParty.post("https://api.ocr.space/parse/image",
11
- body: { apikey: apikey,
12
- language: language,
13
- isOverlayRequired: isOverlayRequired,
14
- url: url})
15
- end
16
- end
17
-
18
- class FilePost
19
- include HTTMultiParty
20
- base_uri 'https://api.ocr.space'
21
- end
22
-
23
- class FromFile
24
- attr_reader :data
25
- def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil, ocr_space: "https://api.ocr.space/parse/image")
26
- @file = File.new(files)
27
- @data = FilePost.post("/parse/image",
28
- body: { apikey: apikey,
29
- language: language,
30
- isOverlayRequired: isOverlayRequired,
31
- files: @file})
32
- end
33
- end
34
- end
2
+ require "ocr_space/from_url"
3
+ require "ocr_space/from_file"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocr_space
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suyesh Bhandari
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2016-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,7 @@ description: 'Free Online OCR - Convert images to text '
98
98
  email:
99
99
  - suyeshb@gmail.com
100
100
  executables:
101
- - ocrspace
101
+ - ocr_space
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
@@ -110,8 +110,11 @@ files:
110
110
  - Rakefile
111
111
  - bin/console
112
112
  - bin/setup
113
- - exe/ocrspace
113
+ - exe/ocr_space
114
114
  - lib/ocr_space.rb
115
+ - lib/ocr_space/file_post.rb
116
+ - lib/ocr_space/from_file.rb
117
+ - lib/ocr_space/from_url.rb
115
118
  - lib/ocr_space/version.rb
116
119
  - ocr_space.gemspec
117
120
  homepage: https://github.com/suyesh/ocr_space
data/exe/ocrspace DELETED
File without changes