mindee 3.4.0 → 3.6.0

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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +6 -1
  4. data/bin/mindee.rb +45 -15
  5. data/docs/bank_account_details_v2.md +1 -1
  6. data/docs/bank_check_v1.md +1 -1
  7. data/docs/bank_statement_fr_v1.md +175 -0
  8. data/docs/barcode_reader_v1.md +1 -1
  9. data/docs/carte_grise_v1.md +5 -5
  10. data/docs/carte_vitale_v1.md +1 -1
  11. data/docs/code_samples/bank_statement_fr_v1_async.txt +19 -0
  12. data/docs/code_samples/default.txt +19 -19
  13. data/docs/code_samples/default_async.txt +25 -0
  14. data/docs/code_samples/eu_driver_license_v1.txt +19 -0
  15. data/docs/code_samples/international_id_v1_async.txt +19 -0
  16. data/docs/code_samples/international_id_v2_async.txt +19 -0
  17. data/docs/code_samples/resume_v1_async.txt +19 -0
  18. data/docs/cropper_v1.md +1 -1
  19. data/docs/custom_v1.md +1 -1
  20. data/docs/eu_driver_license_v1.md +223 -0
  21. data/docs/expense_receipts_v5.md +1 -1
  22. data/docs/financial_document_v1.md +49 -41
  23. data/docs/generated_v1.md +90 -0
  24. data/docs/getting_started.md +1 -1
  25. data/docs/idcard_fr_v2.md +1 -1
  26. data/docs/international_id_v2.md +195 -0
  27. data/docs/invoice_splitter_v1.md +1 -1
  28. data/docs/invoices_v4.md +5 -2
  29. data/docs/license_plates_v1.md +1 -1
  30. data/docs/multi_receipts_detector_v1.md +1 -1
  31. data/docs/passport_v1.md +1 -1
  32. data/docs/proof_of_address_v1.md +5 -5
  33. data/docs/resume_v1.md +334 -0
  34. data/docs/us_driver_license_v1.md +3 -3
  35. data/docs/us_w9_v1.md +1 -1
  36. data/lib/mindee/client.rb +5 -3
  37. data/lib/mindee/http/endpoint.rb +13 -12
  38. data/lib/mindee/input/sources.rb +28 -5
  39. data/lib/mindee/parsing/common/inference.rb +3 -1
  40. data/lib/mindee/parsing/generated/generated_list_field.rb +58 -0
  41. data/lib/mindee/parsing/generated/generated_object_field.rb +109 -0
  42. data/lib/mindee/parsing/generated.rb +4 -0
  43. data/lib/mindee/parsing/standard/base_field.rb +1 -1
  44. data/lib/mindee/parsing.rb +1 -0
  45. data/lib/mindee/product/.rubocop.yml +7 -2
  46. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +3 -1
  47. data/lib/mindee/product/cropper/cropper_v1.rb +3 -1
  48. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +41 -0
  49. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +88 -0
  50. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +53 -0
  51. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +3 -1
  52. data/lib/mindee/product/financial_document/financial_document_v1.rb +3 -1
  53. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +3 -1
  54. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +3 -1
  55. data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +41 -0
  56. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_document.rb +130 -0
  57. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +34 -0
  58. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_transaction.rb +64 -0
  59. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +3 -1
  60. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +0 -2
  61. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +3 -1
  62. data/lib/mindee/product/fr/id_card/id_card_v1.rb +3 -1
  63. data/lib/mindee/product/fr/id_card/id_card_v2.rb +3 -1
  64. data/lib/mindee/product/generated/generated_v1.rb +38 -0
  65. data/lib/mindee/product/generated/generated_v1_document.rb +35 -0
  66. data/lib/mindee/product/generated/generated_v1_page.rb +51 -0
  67. data/lib/mindee/product/generated/generated_v1_prediction.rb +114 -0
  68. data/lib/mindee/product/international_id/international_id_v1.rb +39 -0
  69. data/lib/mindee/product/international_id/international_id_v1_document.rb +109 -0
  70. data/lib/mindee/product/international_id/international_id_v1_page.rb +32 -0
  71. data/lib/mindee/product/international_id/international_id_v2.rb +39 -0
  72. data/lib/mindee/product/international_id/international_id_v2_document.rb +119 -0
  73. data/lib/mindee/product/international_id/international_id_v2_page.rb +32 -0
  74. data/lib/mindee/product/invoice/invoice_v4.rb +3 -1
  75. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +3 -1
  76. data/lib/mindee/product/passport/passport_v1.rb +3 -1
  77. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +3 -1
  78. data/lib/mindee/product/receipt/receipt_v5.rb +3 -1
  79. data/lib/mindee/product/resume/resume_v1.rb +39 -0
  80. data/lib/mindee/product/resume/resume_v1_certificate.rb +69 -0
  81. data/lib/mindee/product/resume/resume_v1_document.rb +322 -0
  82. data/lib/mindee/product/resume/resume_v1_education.rb +90 -0
  83. data/lib/mindee/product/resume/resume_v1_language.rb +55 -0
  84. data/lib/mindee/product/resume/resume_v1_page.rb +32 -0
  85. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +97 -0
  86. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +55 -0
  87. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +3 -1
  88. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +3 -1
  89. data/lib/mindee/product/us/w9/w9_v1.rb +3 -1
  90. data/lib/mindee/product.rb +6 -0
  91. data/lib/mindee/version.rb +1 -1
  92. data/lib/mindee.rb +4 -0
  93. metadata +41 -2
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module InternationalId
8
+ # International ID V2 document prediction.
9
+ class InternationalIdV2Document < Mindee::Parsing::Common::Prediction
10
+ include Mindee::Parsing::Standard
11
+ # The physical address of the document holder.
12
+ # @return [Mindee::Parsing::Standard::StringField]
13
+ attr_reader :address
14
+ # The date of birth of the document holder.
15
+ # @return [Mindee::Parsing::Standard::DateField]
16
+ attr_reader :birth_date
17
+ # The place of birth of the document holder.
18
+ # @return [Mindee::Parsing::Standard::StringField]
19
+ attr_reader :birth_place
20
+ # The country where the document was issued.
21
+ # @return [Mindee::Parsing::Standard::StringField]
22
+ attr_reader :country_of_issue
23
+ # The unique identifier assigned to the document.
24
+ # @return [Mindee::Parsing::Standard::StringField]
25
+ attr_reader :document_number
26
+ # The type of personal identification document.
27
+ # @return [Mindee::Parsing::Standard::ClassificationField]
28
+ attr_reader :document_type
29
+ # The date when the document becomes invalid.
30
+ # @return [Mindee::Parsing::Standard::DateField]
31
+ attr_reader :expiry_date
32
+ # The list of the document holder's given names.
33
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
34
+ attr_reader :given_names
35
+ # The date when the document was issued.
36
+ # @return [Mindee::Parsing::Standard::DateField]
37
+ attr_reader :issue_date
38
+ # The Machine Readable Zone, first line.
39
+ # @return [Mindee::Parsing::Standard::StringField]
40
+ attr_reader :mrz_line1
41
+ # The Machine Readable Zone, second line.
42
+ # @return [Mindee::Parsing::Standard::StringField]
43
+ attr_reader :mrz_line2
44
+ # The Machine Readable Zone, third line.
45
+ # @return [Mindee::Parsing::Standard::StringField]
46
+ attr_reader :mrz_line3
47
+ # The country of citizenship of the document holder.
48
+ # @return [Mindee::Parsing::Standard::StringField]
49
+ attr_reader :nationality
50
+ # The unique identifier assigned to the document holder.
51
+ # @return [Mindee::Parsing::Standard::StringField]
52
+ attr_reader :personal_number
53
+ # The biological sex of the document holder.
54
+ # @return [Mindee::Parsing::Standard::StringField]
55
+ attr_reader :sex
56
+ # The state or territory where the document was issued.
57
+ # @return [Mindee::Parsing::Standard::StringField]
58
+ attr_reader :state_of_issue
59
+ # The list of the document holder's family names.
60
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
61
+ attr_reader :surnames
62
+
63
+ # @param prediction [Hash]
64
+ # @param page_id [Integer, nil]
65
+ def initialize(prediction, page_id)
66
+ super()
67
+ @address = StringField.new(prediction['address'], page_id)
68
+ @birth_date = DateField.new(prediction['birth_date'], page_id)
69
+ @birth_place = StringField.new(prediction['birth_place'], page_id)
70
+ @country_of_issue = StringField.new(prediction['country_of_issue'], page_id)
71
+ @document_number = StringField.new(prediction['document_number'], page_id)
72
+ @document_type = ClassificationField.new(prediction['document_type'], page_id)
73
+ @expiry_date = DateField.new(prediction['expiry_date'], page_id)
74
+ @given_names = []
75
+ prediction['given_names'].each do |item|
76
+ @given_names.push(StringField.new(item, page_id))
77
+ end
78
+ @issue_date = DateField.new(prediction['issue_date'], page_id)
79
+ @mrz_line1 = StringField.new(prediction['mrz_line1'], page_id)
80
+ @mrz_line2 = StringField.new(prediction['mrz_line2'], page_id)
81
+ @mrz_line3 = StringField.new(prediction['mrz_line3'], page_id)
82
+ @nationality = StringField.new(prediction['nationality'], page_id)
83
+ @personal_number = StringField.new(prediction['personal_number'], page_id)
84
+ @sex = StringField.new(prediction['sex'], page_id)
85
+ @state_of_issue = StringField.new(prediction['state_of_issue'], page_id)
86
+ @surnames = []
87
+ prediction['surnames'].each do |item|
88
+ @surnames.push(StringField.new(item, page_id))
89
+ end
90
+ end
91
+
92
+ # @return [String]
93
+ def to_s
94
+ surnames = @surnames.join("\n #{' ' * 10}")
95
+ given_names = @given_names.join("\n #{' ' * 13}")
96
+ out_str = String.new
97
+ out_str << "\n:Document Type: #{@document_type}".rstrip
98
+ out_str << "\n:Document Number: #{@document_number}".rstrip
99
+ out_str << "\n:Surnames: #{surnames}".rstrip
100
+ out_str << "\n:Given Names: #{given_names}".rstrip
101
+ out_str << "\n:Sex: #{@sex}".rstrip
102
+ out_str << "\n:Birth Date: #{@birth_date}".rstrip
103
+ out_str << "\n:Birth Place: #{@birth_place}".rstrip
104
+ out_str << "\n:Nationality: #{@nationality}".rstrip
105
+ out_str << "\n:Personal Number: #{@personal_number}".rstrip
106
+ out_str << "\n:Country of Issue: #{@country_of_issue}".rstrip
107
+ out_str << "\n:State of Issue: #{@state_of_issue}".rstrip
108
+ out_str << "\n:Issue Date: #{@issue_date}".rstrip
109
+ out_str << "\n:Expiration Date: #{@expiry_date}".rstrip
110
+ out_str << "\n:Address: #{@address}".rstrip
111
+ out_str << "\n:MRZ Line 1: #{@mrz_line1}".rstrip
112
+ out_str << "\n:MRZ Line 2: #{@mrz_line2}".rstrip
113
+ out_str << "\n:MRZ Line 3: #{@mrz_line3}".rstrip
114
+ out_str[1..].to_s
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'international_id_v2_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module InternationalId
9
+ # International ID V2 page.
10
+ class InternationalIdV2Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = InternationalIdV2PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # International ID V2 page prediction.
22
+ class InternationalIdV2PagePrediction < InternationalIdV2Document
23
+ # @return [String]
24
+ def to_s
25
+ out_str = String.new
26
+ out_str << "\n#{super}"
27
+ out_str
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -19,7 +19,9 @@ module Mindee
19
19
  @prediction = InvoiceV4Document.new(prediction['prediction'], nil)
20
20
  @pages = []
21
21
  prediction['pages'].each do |page|
22
- @pages.push(InvoiceV4Page.new(page))
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(InvoiceV4Page.new(page))
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -19,7 +19,9 @@ module Mindee
19
19
  @prediction = MultiReceiptsDetectorV1Document.new(prediction['prediction'], nil)
20
20
  @pages = []
21
21
  prediction['pages'].each do |page|
22
- @pages.push(MultiReceiptsDetectorV1Page.new(page))
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(MultiReceiptsDetectorV1Page.new(page))
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -19,7 +19,9 @@ module Mindee
19
19
  @prediction = PassportV1Document.new(prediction['prediction'], nil)
20
20
  @pages = []
21
21
  prediction['pages'].each do |page|
22
- @pages.push(PassportV1Page.new(page))
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(PassportV1Page.new(page))
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -19,7 +19,9 @@ module Mindee
19
19
  @prediction = ProofOfAddressV1Document.new(prediction['prediction'], nil)
20
20
  @pages = []
21
21
  prediction['pages'].each do |page|
22
- @pages.push(ProofOfAddressV1Page.new(page))
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(ProofOfAddressV1Page.new(page))
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -19,7 +19,9 @@ module Mindee
19
19
  @prediction = ReceiptV5Document.new(prediction['prediction'], nil)
20
20
  @pages = []
21
21
  prediction['pages'].each do |page|
22
- @pages.push(ReceiptV5Page.new(page))
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(ReceiptV5Page.new(page))
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'resume_v1_document'
5
+ require_relative 'resume_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # Resume module.
10
+ module Resume
11
+ # Resume V1 prediction inference.
12
+ class ResumeV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'resume'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = ResumeV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(ResumeV1Page.new(page))
24
+ end
25
+ end
26
+ end
27
+
28
+ class << self
29
+ # Name of the endpoint for this product.
30
+ # @return [String]
31
+ attr_reader :endpoint_name
32
+ # Version for this product.
33
+ # @return [String]
34
+ attr_reader :endpoint_version
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module Resume
8
+ # The list of certificates obtained by the candidate.
9
+ class ResumeV1Certificate < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The grade obtained for the certificate.
12
+ # @return [String]
13
+ attr_reader :grade
14
+ # The name of certification.
15
+ # @return [String]
16
+ attr_reader :name
17
+ # The organization or institution that issued the certificate.
18
+ # @return [String]
19
+ attr_reader :provider
20
+ # The year when a certificate was issued or received.
21
+ # @return [String]
22
+ attr_reader :year
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @grade = prediction['grade']
29
+ @name = prediction['name']
30
+ @provider = prediction['provider']
31
+ @year = prediction['year']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:grade] = format_for_display(@grade, 10)
39
+ printable[:name] = format_for_display(@name, 30)
40
+ printable[:provider] = format_for_display(@provider, 25)
41
+ printable[:year] = format_for_display(@year, nil)
42
+ printable
43
+ end
44
+
45
+ # @return [String]
46
+ def to_table_line
47
+ printable = printable_values
48
+ out_str = String.new
49
+ out_str << format('| %- 11s', printable[:grade])
50
+ out_str << format('| %- 31s', printable[:name])
51
+ out_str << format('| %- 26s', printable[:provider])
52
+ out_str << format('| %- 5s', printable[:year])
53
+ out_str << '|'
54
+ end
55
+
56
+ # @return [String]
57
+ def to_s
58
+ printable = printable_values
59
+ out_str = String.new
60
+ out_str << "\n :Grade: #{printable[:grade]}"
61
+ out_str << "\n :Name: #{printable[:name]}"
62
+ out_str << "\n :Provider: #{printable[:provider]}"
63
+ out_str << "\n :Year: #{printable[:year]}"
64
+ out_str
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,322 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'resume_v1_social_networks_url'
5
+ require_relative 'resume_v1_language'
6
+ require_relative 'resume_v1_education'
7
+ require_relative 'resume_v1_professional_experience'
8
+ require_relative 'resume_v1_certificate'
9
+
10
+ module Mindee
11
+ module Product
12
+ module Resume
13
+ # Resume V1 document prediction.
14
+ class ResumeV1Document < Mindee::Parsing::Common::Prediction
15
+ include Mindee::Parsing::Standard
16
+ # The location information of the candidate, including city, state, and country.
17
+ # @return [Mindee::Parsing::Standard::StringField]
18
+ attr_reader :address
19
+ # The list of certificates obtained by the candidate.
20
+ # @return [Array<Mindee::Product::Resume::ResumeV1Certificate>]
21
+ attr_reader :certificates
22
+ # The ISO 639 code of the language in which the document is written.
23
+ # @return [Mindee::Parsing::Standard::StringField]
24
+ attr_reader :document_language
25
+ # The type of the document sent.
26
+ # @return [Mindee::Parsing::Standard::ClassificationField]
27
+ attr_reader :document_type
28
+ # The list of the candidate's educational background.
29
+ # @return [Array<Mindee::Product::Resume::ResumeV1Education>]
30
+ attr_reader :education
31
+ # The email address of the candidate.
32
+ # @return [Mindee::Parsing::Standard::StringField]
33
+ attr_reader :email_address
34
+ # The candidate's first or given names.
35
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
36
+ attr_reader :given_names
37
+ # The list of the candidate's technical abilities and knowledge.
38
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
39
+ attr_reader :hard_skills
40
+ # The position that the candidate is applying for.
41
+ # @return [Mindee::Parsing::Standard::StringField]
42
+ attr_reader :job_applied
43
+ # The list of languages that the candidate is proficient in.
44
+ # @return [Array<Mindee::Product::Resume::ResumeV1Language>]
45
+ attr_reader :languages
46
+ # The ISO 3166 code for the country of citizenship of the candidate.
47
+ # @return [Mindee::Parsing::Standard::StringField]
48
+ attr_reader :nationality
49
+ # The phone number of the candidate.
50
+ # @return [Mindee::Parsing::Standard::StringField]
51
+ attr_reader :phone_number
52
+ # The candidate's current profession.
53
+ # @return [Mindee::Parsing::Standard::StringField]
54
+ attr_reader :profession
55
+ # The list of the candidate's professional experiences.
56
+ # @return [Array<Mindee::Product::Resume::ResumeV1ProfessionalExperience>]
57
+ attr_reader :professional_experiences
58
+ # The list of social network profiles of the candidate.
59
+ # @return [Array<Mindee::Product::Resume::ResumeV1SocialNetworksUrl>]
60
+ attr_reader :social_networks_urls
61
+ # The list of the candidate's interpersonal and communication abilities.
62
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
63
+ attr_reader :soft_skills
64
+ # The candidate's last names.
65
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
66
+ attr_reader :surnames
67
+
68
+ # @param prediction [Hash]
69
+ # @param page_id [Integer, nil]
70
+ def initialize(prediction, page_id)
71
+ super()
72
+ @address = StringField.new(prediction['address'], page_id)
73
+ @certificates = []
74
+ prediction['certificates'].each do |item|
75
+ @certificates.push(ResumeV1Certificate.new(item, page_id))
76
+ end
77
+ @document_language = StringField.new(prediction['document_language'], page_id)
78
+ @document_type = ClassificationField.new(prediction['document_type'], page_id)
79
+ @education = []
80
+ prediction['education'].each do |item|
81
+ @education.push(ResumeV1Education.new(item, page_id))
82
+ end
83
+ @email_address = StringField.new(prediction['email_address'], page_id)
84
+ @given_names = []
85
+ prediction['given_names'].each do |item|
86
+ @given_names.push(StringField.new(item, page_id))
87
+ end
88
+ @hard_skills = []
89
+ prediction['hard_skills'].each do |item|
90
+ @hard_skills.push(StringField.new(item, page_id))
91
+ end
92
+ @job_applied = StringField.new(prediction['job_applied'], page_id)
93
+ @languages = []
94
+ prediction['languages'].each do |item|
95
+ @languages.push(ResumeV1Language.new(item, page_id))
96
+ end
97
+ @nationality = StringField.new(prediction['nationality'], page_id)
98
+ @phone_number = StringField.new(prediction['phone_number'], page_id)
99
+ @profession = StringField.new(prediction['profession'], page_id)
100
+ @professional_experiences = []
101
+ prediction['professional_experiences'].each do |item|
102
+ @professional_experiences.push(ResumeV1ProfessionalExperience.new(item, page_id))
103
+ end
104
+ @social_networks_urls = []
105
+ prediction['social_networks_urls'].each do |item|
106
+ @social_networks_urls.push(ResumeV1SocialNetworksUrl.new(item, page_id))
107
+ end
108
+ @soft_skills = []
109
+ prediction['soft_skills'].each do |item|
110
+ @soft_skills.push(StringField.new(item, page_id))
111
+ end
112
+ @surnames = []
113
+ prediction['surnames'].each do |item|
114
+ @surnames.push(StringField.new(item, page_id))
115
+ end
116
+ end
117
+
118
+ # @return [String]
119
+ def to_s
120
+ given_names = @given_names.join("\n #{' ' * 13}")
121
+ surnames = @surnames.join("\n #{' ' * 10}")
122
+ social_networks_urls = social_networks_urls_to_s
123
+ languages = languages_to_s
124
+ hard_skills = @hard_skills.join("\n #{' ' * 13}")
125
+ soft_skills = @soft_skills.join("\n #{' ' * 13}")
126
+ education = education_to_s
127
+ professional_experiences = professional_experiences_to_s
128
+ certificates = certificates_to_s
129
+ out_str = String.new
130
+ out_str << "\n:Document Language: #{@document_language}".rstrip
131
+ out_str << "\n:Document Type: #{@document_type}".rstrip
132
+ out_str << "\n:Given Names: #{given_names}".rstrip
133
+ out_str << "\n:Surnames: #{surnames}".rstrip
134
+ out_str << "\n:Nationality: #{@nationality}".rstrip
135
+ out_str << "\n:Email Address: #{@email_address}".rstrip
136
+ out_str << "\n:Phone Number: #{@phone_number}".rstrip
137
+ out_str << "\n:Address: #{@address}".rstrip
138
+ out_str << "\n:Social Networks:"
139
+ out_str << social_networks_urls
140
+ out_str << "\n:Profession: #{@profession}".rstrip
141
+ out_str << "\n:Job Applied: #{@job_applied}".rstrip
142
+ out_str << "\n:Languages:"
143
+ out_str << languages
144
+ out_str << "\n:Hard Skills: #{hard_skills}".rstrip
145
+ out_str << "\n:Soft Skills: #{soft_skills}".rstrip
146
+ out_str << "\n:Education:"
147
+ out_str << education
148
+ out_str << "\n:Professional Experiences:"
149
+ out_str << professional_experiences
150
+ out_str << "\n:Certificates:"
151
+ out_str << certificates
152
+ out_str[1..].to_s
153
+ end
154
+
155
+ private
156
+
157
+ # @param char [String]
158
+ # @return [String]
159
+ def social_networks_urls_separator(char)
160
+ out_str = String.new
161
+ out_str << ' '
162
+ out_str << "+#{char * 22}"
163
+ out_str << "+#{char * 52}"
164
+ out_str << '+'
165
+ out_str
166
+ end
167
+
168
+ # @return [String]
169
+ def social_networks_urls_to_s
170
+ return '' if @social_networks_urls.empty?
171
+
172
+ line_items = @social_networks_urls.map(&:to_table_line).join("\n#{social_networks_urls_separator('-')}\n ")
173
+ out_str = String.new
174
+ out_str << "\n#{social_networks_urls_separator('-')}"
175
+ out_str << "\n |"
176
+ out_str << ' Name |'
177
+ out_str << ' URL |'
178
+ out_str << "\n#{social_networks_urls_separator('=')}"
179
+ out_str << "\n #{line_items}"
180
+ out_str << "\n#{social_networks_urls_separator('-')}"
181
+ out_str
182
+ end
183
+
184
+ # @param char [String]
185
+ # @return [String]
186
+ def languages_separator(char)
187
+ out_str = String.new
188
+ out_str << ' '
189
+ out_str << "+#{char * 10}"
190
+ out_str << "+#{char * 22}"
191
+ out_str << '+'
192
+ out_str
193
+ end
194
+
195
+ # @return [String]
196
+ def languages_to_s
197
+ return '' if @languages.empty?
198
+
199
+ line_items = @languages.map(&:to_table_line).join("\n#{languages_separator('-')}\n ")
200
+ out_str = String.new
201
+ out_str << "\n#{languages_separator('-')}"
202
+ out_str << "\n |"
203
+ out_str << ' Language |'
204
+ out_str << ' Level |'
205
+ out_str << "\n#{languages_separator('=')}"
206
+ out_str << "\n #{line_items}"
207
+ out_str << "\n#{languages_separator('-')}"
208
+ out_str
209
+ end
210
+
211
+ # @param char [String]
212
+ # @return [String]
213
+ def education_separator(char)
214
+ out_str = String.new
215
+ out_str << ' '
216
+ out_str << "+#{char * 17}"
217
+ out_str << "+#{char * 27}"
218
+ out_str << "+#{char * 11}"
219
+ out_str << "+#{char * 10}"
220
+ out_str << "+#{char * 27}"
221
+ out_str << "+#{char * 13}"
222
+ out_str << "+#{char * 12}"
223
+ out_str << '+'
224
+ out_str
225
+ end
226
+
227
+ # @return [String]
228
+ def education_to_s
229
+ return '' if @education.empty?
230
+
231
+ line_items = @education.map(&:to_table_line).join("\n#{education_separator('-')}\n ")
232
+ out_str = String.new
233
+ out_str << "\n#{education_separator('-')}"
234
+ out_str << "\n |"
235
+ out_str << ' Domain |'
236
+ out_str << ' Degree |'
237
+ out_str << ' End Month |'
238
+ out_str << ' End Year |'
239
+ out_str << ' School |'
240
+ out_str << ' Start Month |'
241
+ out_str << ' Start Year |'
242
+ out_str << "\n#{education_separator('=')}"
243
+ out_str << "\n #{line_items}"
244
+ out_str << "\n#{education_separator('-')}"
245
+ out_str
246
+ end
247
+
248
+ # @param char [String]
249
+ # @return [String]
250
+ def professional_experiences_separator(char)
251
+ out_str = String.new
252
+ out_str << ' '
253
+ out_str << "+#{char * 17}"
254
+ out_str << "+#{char * 12}"
255
+ out_str << "+#{char * 27}"
256
+ out_str << "+#{char * 11}"
257
+ out_str << "+#{char * 10}"
258
+ out_str << "+#{char * 22}"
259
+ out_str << "+#{char * 13}"
260
+ out_str << "+#{char * 12}"
261
+ out_str << '+'
262
+ out_str
263
+ end
264
+
265
+ # @return [String]
266
+ def professional_experiences_to_s
267
+ return '' if @professional_experiences.empty?
268
+
269
+ line_items = @professional_experiences.map(&:to_table_line).join(
270
+ "\n#{professional_experiences_separator('-')}\n "
271
+ )
272
+ out_str = String.new
273
+ out_str << "\n#{professional_experiences_separator('-')}"
274
+ out_str << "\n |"
275
+ out_str << ' Contract Type |'
276
+ out_str << ' Department |'
277
+ out_str << ' Employer |'
278
+ out_str << ' End Month |'
279
+ out_str << ' End Year |'
280
+ out_str << ' Role |'
281
+ out_str << ' Start Month |'
282
+ out_str << ' Start Year |'
283
+ out_str << "\n#{professional_experiences_separator('=')}"
284
+ out_str << "\n #{line_items}"
285
+ out_str << "\n#{professional_experiences_separator('-')}"
286
+ out_str
287
+ end
288
+
289
+ # @param char [String]
290
+ # @return [String]
291
+ def certificates_separator(char)
292
+ out_str = String.new
293
+ out_str << ' '
294
+ out_str << "+#{char * 12}"
295
+ out_str << "+#{char * 32}"
296
+ out_str << "+#{char * 27}"
297
+ out_str << "+#{char * 6}"
298
+ out_str << '+'
299
+ out_str
300
+ end
301
+
302
+ # @return [String]
303
+ def certificates_to_s
304
+ return '' if @certificates.empty?
305
+
306
+ line_items = @certificates.map(&:to_table_line).join("\n#{certificates_separator('-')}\n ")
307
+ out_str = String.new
308
+ out_str << "\n#{certificates_separator('-')}"
309
+ out_str << "\n |"
310
+ out_str << ' Grade |'
311
+ out_str << ' Name |'
312
+ out_str << ' Provider |'
313
+ out_str << ' Year |'
314
+ out_str << "\n#{certificates_separator('=')}"
315
+ out_str << "\n #{line_items}"
316
+ out_str << "\n#{certificates_separator('-')}"
317
+ out_str
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end