xtractor 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e360ba9ddac0bd8b589bbfa0cdda7c344408b029
4
- data.tar.gz: 9ffe93ad99b50e40d8fc018b71dc2cdb78bd4273
3
+ metadata.gz: 1680978fbaff54a46f6782eadc169a62fd2c390e
4
+ data.tar.gz: 05fd4bb0b9fb6313f2d52e3516a88c99e08abf63
5
5
  SHA512:
6
- metadata.gz: ec2936bc8117b54e570d30cbb871555d0853da8e5e5a27778e84274df085d03c5c079293ed30e21de86f8c5e71367bde511d20cf148c9f7ce714ff376d84175f
7
- data.tar.gz: 3f917c1372895e6a3db1cd6ecfea2a56afe141299c07a2a362a89f7036d6346a65c83b243275be4062f1779e1f5ec11e4efcd7d33d6cfc4b1b5d9b7aaaa5b6ec
6
+ metadata.gz: 92d4842b906384882409a8095f18b9e0586035c231203c90e4b095aa11fd0837f27c73c838600ad549de2c2586bf83d6d4f7b24adc0be35478fba0a912f19545
7
+ data.tar.gz: c71d1009526a3ebb22ff491392c7e4c49bf7ecf05895a977dc23537b7d795b7361e911e84ac11ec1cae77946415647f02a3fcaa2151f03326824204b72eaa135
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Xtractor
2
- <img src="https://badge.fury.io/rb/xtractor.svg" alt="Gem Version" /> <img src="https://travis-ci.org/Kamalpaneru/Xtractor.svg?branch=master" alt="Build" />
2
+ <img src="https://badge.fury.io/rb/xtractor.svg" /> <img src="https://travis-ci.org/Kamalpaneru/Xtractor.svg?branch=master" alt="Build" />
3
3
 
4
4
 
5
5
  Xtractor was developed as a need to the problem of inserting data from an excelsheet image to excel.And it does the same as described.
@@ -28,7 +28,11 @@ Used to split cells from excel sheet images and extracts data. <br>
28
28
  ```ruby
29
29
  require 'xtractor'
30
30
 
31
- Xtractor::Execute.new('Image_Filename')
31
+ api_key = "Your_api_key_here"
32
+
33
+ process = Xtractor::Execute.new('Image_Filename', api_key)
34
+
35
+ process.begin_process
32
36
 
33
37
  ```
34
38
  ## Sample Image
@@ -36,7 +40,7 @@ Used to split cells from excel sheet images and extracts data. <br>
36
40
  ![image_f3](https://user-images.githubusercontent.com/13826932/31273813-03dde45a-aab0-11e7-942f-c77202f996d1.jpg)
37
41
 
38
42
  ## Generate API key
39
- Replace API_KEY in ```lib/xtractor/request.rb ``` with your Key.<br>
43
+ Generate your API key <br>
40
44
  ```https://azure.microsoft.com/en-gb/try/cognitive-services/ ```
41
45
 
42
46
  ## Contributing
@@ -3,7 +3,7 @@ require 'json'
3
3
 
4
4
  class Azure_API
5
5
 
6
- def request_API
6
+ def request_API(api_key)
7
7
  uri = URI('https://westcentralus.api.cognitive.microsoft.com/vision/v1.0/ocr')
8
8
  uri.query = URI.encode_www_form({
9
9
 
@@ -13,7 +13,7 @@ class Azure_API
13
13
 
14
14
  request = Net::HTTP::Post.new(uri.request_uri)
15
15
 
16
- request['Ocp-Apim-Subscription-Key'] = "d0154961a66b4a0aa41d6f4fbb4b2105"
16
+ request['Ocp-Apim-Subscription-Key'] = api_key
17
17
 
18
18
  request['Content-Type'] = 'application/octet-stream'
19
19
 
@@ -1,3 +1,3 @@
1
1
  module Xtractor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -5,23 +5,28 @@ require_relative "request"
5
5
  module Xtractor
6
6
  class Execute
7
7
 
8
- def initialize(image)
9
- img = Magick::Image::read(image).first
10
-
11
- if %w(TIFF).include? img.format
12
- crop_throw(img)
13
- else
14
- img.write('Conv_img.tif')
15
- img = Magick::Image::read('Conv_img.tif').first
16
- crop_throw(img)
17
- end
8
+ def initialize(image, api_key)
9
+ @image = image
10
+ @api_key = api_key
11
+ end
12
+
13
+ def begin_process
14
+ img = Magick::Image::read(@image).first
15
+
16
+ if %w(TIFF).include? img.format
17
+ crop_throw(img)
18
+ else
19
+ img.write('Conv_img.tif')
20
+ img = Magick::Image::read('Conv_img.tif').first
21
+ crop_throw(img)
22
+ end
18
23
  end
19
24
 
20
25
  def crop_throw(img)
21
- img = img.resize_to_fit(2500,906)
22
- box = img.bounding_box
23
- img.crop!(box.x, box.y, box.width, box.height)
24
- start(img)
26
+ image = img.resize_to_fit(2500,906)
27
+ box = image.bounding_box
28
+ image.crop!(box.x, box.y, box.width, box.height)
29
+ start(image)
25
30
  end
26
31
 
27
32
  def store_line_rows(img)
@@ -88,13 +93,13 @@ module Xtractor
88
93
 
89
94
  end
90
95
  end
91
- collect_hash(img)
96
+ collect_hash(img, @api_key)
92
97
  end
93
98
 
94
- def collect_hash(img)
99
+ def collect_hash(*args)
95
100
  api = Azure_API.new
96
- api.request_API
97
- out_final(img)
101
+ api.request_API(args[1])
102
+ out_final(args[0])
98
103
  end
99
104
 
100
105
  def out_final(img)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xtractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kamalpaneru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler