presume 0.0.2

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.
Binary file
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe Classifide do
4
+
5
+ classifide_params = {:phone => nil, :email => nil, :address => nil, :section => nil, :professions => "Project Coordinator ", :companies => "Thorns and Thistles Ltd.", :schools => nil, :dates => "September 2012 – January 2014", :dates_2 => nil, :number_of_words => 6, :many_words => true, :verbs => nil, :cities => "Toronto, Ontario", :text => "Project Coordinator, Thorns and Thistles Ltd., Toronto, Ontario, September 2012 – January 2014", :type => "header_x"}
6
+ let(:classifide) {Classifide.new(classifide_params)}
7
+
8
+ classifide_params_2 = {:phone => nil, :email => nil, :address => nil, :section => "of Toronto School of Continuing Education", :professions => nil, :companies => nil, :schools => "University of Toronto School of Continuing", :dates => "Summer 2013", :dates_2 => nil, :cities => nil, :number_of_words => 8, :many_words => true, :verbs => nil, :text => "University of Toronto School of Continuing EducationSummer 2013", :type => "header_x"}
9
+
10
+ let(:classifide_2) {Classifide.new(classifide_params_2)}
11
+
12
+ it "checks more words than" do
13
+ expect(classifide.more_words_than?(5)).to be_truthy
14
+ expect(classifide.more_words_than?(10)).to be_falsy
15
+ end
16
+
17
+ end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ describe Header do
4
+
5
+ classifide_params = {:phone => nil, :email => nil, :address => nil, :section => nil, :professions => "Project Coordinator ", :companies => nil, :schools => nil, :dates => "September 2012 – January 2014", :cities => nil, :number_of_words => 7, :many_words => true, :verbs => nil, :text => "Project Coordinator, Thorns and Thistles Ltd., Toronto, Ontario, September 2012 – January 2014", :type => "header_x"}
6
+ classifide = Classifide.new(classifide_params)
7
+ let(:header) {Header.new(classifide)}
8
+
9
+ it "finds start time text" do
10
+ expect(header.start_time_text?).to eq("September 2012")
11
+
12
+ end
13
+
14
+ it "finds start year" do
15
+ expect(header.start_year).to eq("2012")
16
+
17
+ end
18
+
19
+ it "finds start time number" do
20
+ expect(header.start_time_number).to eq(2012 + (8/12).to_f)
21
+ end
22
+
23
+
24
+ it "finds end time text" do
25
+ expect(header.end_time_text?).to eq("January 2014")
26
+ end
27
+
28
+ it "finds end year" do
29
+ expect(header.end_year).to eq("2014")
30
+ end
31
+
32
+ it "finds end time number" do
33
+ expect(header.end_time_number).to eq(2014 + (0/12).to_f)
34
+ end
35
+
36
+ it "finds end time number" do
37
+ header.instance_variable_set("@dates", 'September 2014 to present')
38
+ puts header.dates
39
+ expect(header.start_time_text?).to eq("September 2014")
40
+ expect(header.end_time_number).to eq(2015 + (6/12).to_f)
41
+ end
42
+
43
+ it "checks if end time text is current job" do
44
+ expect(header.current?).to be_falsy
45
+ end
46
+
47
+ it "removes date from text" do
48
+ header.remove_date
49
+ expect(header.clean_profession).to eq("Project Coordinator, Thorns and Thistles Ltd., Toronto, Ontario, ")
50
+ end
51
+
52
+ it "removes city from text" do
53
+ header.remove_date
54
+ header.remove_city
55
+ expect(header.clean_profession).to eq("Project Coordinator, Thorns and Thistles Ltd., , ")
56
+ end
57
+
58
+ it "removes companies" do
59
+ header.remove_date
60
+ header.remove_city
61
+ header.remove_institution
62
+ expect(header.clean_profession).to eq("Project Coordinator, , , ")
63
+ end
64
+
65
+ it "removes companies" do
66
+ header.remove_date
67
+ header.remove_city
68
+ header.remove_institution
69
+ header.remove_all_but_profession
70
+ expect(header.clean_profession).to eq("Project Coordinator")
71
+ end
72
+
73
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe Presume do
4
+
5
+ doc = Docx::Document.open('sample_resume.docx').text
6
+
7
+ let(:presume){Presume.new(doc, "Sample Person")}
8
+
9
+ searchable_params = {"Marketing Coordinator" => 1, "Project Coordinator" => 1}
10
+
11
+ skill_params = {"present investment proposals" => 0, "clear communication" => 0}
12
+
13
+ it "should return sections" do
14
+ expect(presume.sections).to_not be_nil
15
+ end
16
+
17
+ it "should return section ids" do
18
+ expect(presume.get_sections_id.kind_of?(Array)).to be_truthy
19
+ end
20
+
21
+ it "should return section info" do
22
+ expect(presume.get_sections_info.kind_of?(Array)).to be_truthy
23
+ end
24
+
25
+ it "should return header ids" do
26
+ expect(presume.get_headers_id.kind_of?(Array)).to be_truthy
27
+ end
28
+
29
+ it "should return header info" do
30
+ expect(presume.get_headers_info.kind_of?(Array)).to be_truthy
31
+ end
32
+
33
+ it "should return children" do
34
+ expect(presume.sections[0].children.length).to be < presume.all_types[0].length
35
+ end
36
+
37
+ it "should get matched searchables" do
38
+ presume.instance_variable_set("@searchables", Searchables.new(searchable_params))
39
+ presume.instance_variable_set("@matched_searchables", [])
40
+ presume.headers.values.each do |header|
41
+ presume.instance_variable_get("@searchables").all.values.each do |searchable|
42
+ puts header.text
43
+ puts header.dates
44
+ puts searchable.duration
45
+ puts header.duration
46
+
47
+ if header.duration > searchable.duration
48
+ puts "duration is greater"
49
+ puts searchable.regex
50
+ if !header.text[searchable.regex].nil?
51
+ puts "match"
52
+ presume.instance_variable_set("@matched_searchables", presume.instance_variable_get("@matched_searchables")) + [[searchable,header]]
53
+ end
54
+ end
55
+ end
56
+ end
57
+ presume.instance_variable_get("@matched_searchables")
58
+ end
59
+
60
+ it "should find similar searchable and time" do
61
+ expect(presume.searchables?(searchable_params).class.name).to eq("Array")
62
+ expect(presume.instance_variable_get("@matched_searchables").length).to eq(1)
63
+ expect(presume.instance_variable_get("@matched_searchables")[0][0].raw_name).to eq("Project Coordinator")
64
+ end
65
+
66
+ it "should find similar skills and times" do
67
+ expect(presume.skills?(skill_params).class.name).to eq("Array")
68
+ expect(presume.instance_variable_get("@matched_searchables").length).to eq(1)
69
+ expect(presume.instance_variable_get("@matched_searchables")[0][1].text).to eq("Assisted in the financial reporting, pro forma analysis, and presentation of investment proposals to International stakeholders, leasing agents and project managers in Cantonese, Mandarin and English using Excel and Power,Point. ")
70
+ end
71
+
72
+ end
@@ -0,0 +1,213 @@
1
+ require 'spec_helper'
2
+
3
+ describe ResumeBuilder do
4
+
5
+ doc = Docx::Document.open('sample_resume.docx').text
6
+
7
+ resume_classifier = ResumeClassifier.new(doc, "Sample Person", "fake_presume_object")
8
+ resume_classifier.classify
9
+
10
+ let(:resume_builder){ResumeBuilder.new(resume_classifier.classifide_lines)}
11
+
12
+ it 'should be properly setup' do
13
+ expect(resume_classifier.classifide_lines.length).to be > 10
14
+ expect(resume_builder.classifides.length).to be > 10
15
+ end
16
+
17
+ it "it should complete first pass" do
18
+ resume_builder.first_pass
19
+ expect(resume_builder.classifides[0].type).to eq("section")
20
+ end
21
+
22
+ it "it should complete second pass" do
23
+ resume_builder.first_pass
24
+ resume_builder.second_pass
25
+ expect(resume_builder.classifides[0].type).to eq("section")
26
+ resume_builder.classifides.values.each do |classifide|
27
+ puts ("#{classifide.type} | #{classifide.text} | #{classifide.professions} | #{classifide.many_words?} ")
28
+ end
29
+ end
30
+
31
+ it "it should build resume" do
32
+ resume_builder.first_pass
33
+ resume_builder.second_pass
34
+ resume_builder.reset_header_x_start
35
+ expect(resume_builder.instance_variable_get("@header_x_start")).to eq(true)
36
+ resume_builder.instance_variable_get("@length").times do |n|
37
+ resume_builder.set_classifide(n)
38
+ @classifide = resume_builder.instance_variable_get("@classifide")
39
+ expect(@classifide.id).to eq(n)
40
+ unless @classifide.type?
41
+ unless @classifide.type == "name" or @classifide.type == "email" or @classifide.type == "phone" or @classifide.type == "address"
42
+ resume_builder.send(@classifide.type + "_build")
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ it "should build section" do
49
+ resume_builder.first_pass
50
+ resume_builder.second_pass
51
+ resume_builder.instance_variable_get("@length").times do |n|
52
+ resume_builder.set_classifide(n)
53
+ @classifide = resume_builder.instance_variable_get("@classifide")
54
+
55
+ unless @classifide.type?
56
+ unless @classifide.type == "name" or @classifide.type == "email" or @classifide.type == "phone" or @classifide.type == "address"
57
+ if @classifide.type == "section"
58
+ resume_builder.send(@classifide.type + "_build")
59
+ expect(resume_builder.instance_variable_get("@header_number")).to be_nil
60
+ expect(resume_builder.instance_variable_get("@section_number")).to eq(n)
61
+ expect(resume_builder.instance_variable_get("@header_x_start")).to be_truthy
62
+ expect(resume_builder.sections.values.length).to be > 0
63
+ expect(resume_builder.all_types.length).to be > 0
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ it "should build header" do
72
+ resume_builder.first_pass
73
+ resume_builder.second_pass
74
+ resume_builder.instance_variable_get("@length").times do |n|
75
+ resume_builder.set_classifide(n)
76
+ @classifide = resume_builder.instance_variable_get("@classifide")
77
+
78
+ if resume_builder.all_types.values.nil?
79
+ check_all_types_length = 0
80
+ else
81
+ check_all_types_length = resume_builder.all_types.values.length
82
+ end
83
+
84
+ if (parent_types =resume_builder.all_types[resume_builder.section_number?]).nil?
85
+ check_all_types_parent_length = 0
86
+ else
87
+ check_all_types_parent_length = parent_types.length
88
+ end
89
+
90
+ if (headers = resume_builder.headers.values).nil?
91
+ check_headers_length = 0
92
+ else
93
+ check_headers_length = headers.length
94
+ end
95
+
96
+
97
+ unless @classifide.type?
98
+ unless @classifide.type == "name" or @classifide.type == "email" or @classifide.type == "phone" or @classifide.type == "address"
99
+ if @classifide.type == "header"
100
+ resume_builder.send(@classifide.type + "_build")
101
+ expect(resume_builder.instance_variable_get("@header_number")).to eq(n)
102
+ expect(resume_builder.instance_variable_get("@header_x_start")).to be_truthy
103
+ expect(resume_builder.bullets.values.length).to be > check_headers_length
104
+ expect(resume_builder.all_types.values.length).to be > check_all_types_length
105
+ expect(resume_builder.all_types[resume_builder.section_number?].length).to be > check_all_types_parent_length
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ end
112
+
113
+ it "should build bullet" do
114
+ resume_builder.first_pass
115
+ resume_builder.second_pass
116
+ resume_builder.instance_variable_get("@length").times do |n|
117
+ resume_builder.set_classifide(n)
118
+ @classifide = resume_builder.instance_variable_get("@classifide")
119
+
120
+ if resume_builder.all_types.values.nil?
121
+ check_all_types_length = 0
122
+ else
123
+ check_all_types_length = resume_builder.all_types.values.length
124
+ end
125
+
126
+ if (parent_types =resume_builder.all_types[resume_builder.header_number?]).nil?
127
+ check_all_types_parent_length = 0
128
+ else
129
+ check_all_types_parent_length = parent_types.length
130
+ end
131
+
132
+ if (bullets = resume_builder.bullets.values).nil?
133
+ check_bullets_length = 0
134
+ else
135
+ check_bullets_length = bullets.length
136
+ end
137
+
138
+ unless @classifide.type?
139
+ unless @classifide.type == "name" or @classifide.type == "email" or @classifide.type == "phone" or @classifide.type == "address"
140
+ if @classifide.type == "bullet"
141
+ resume_builder.send(@classifide.type + "_build")
142
+ expect(resume_builder.instance_variable_get("@header_x_start")).to be_truthy
143
+ expect(resume_builder.bullets.values.length).to be > check_bullets_length
144
+ expect(resume_builder.all_types.values.length).to be > check_all_types_length
145
+ expect(resume_builder.all_types[resume_builder.header_number?].length).to be > check_all_types_parent_length
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ end
152
+
153
+ it "should build header_x" do
154
+ resume_builder.first_pass
155
+ resume_builder.second_pass
156
+ resume_builder.instance_variable_get("@length").times do |n|
157
+ resume_builder.set_classifide(n)
158
+ @classifide = resume_builder.instance_variable_get("@classifide")
159
+
160
+ if resume_builder.all_types.values.nil?
161
+ check_all_types_length = 0
162
+ else
163
+ check_all_types_length = resume_builder.all_types.values.length
164
+ end
165
+
166
+ if (parent_types =resume_builder.all_types[resume_builder.section_number?]).nil?
167
+ check_all_types_parent_length = 0
168
+ else
169
+ check_all_types_parent_length = parent_types.length
170
+ end
171
+
172
+ if (headers = resume_builder.headers.values).nil?
173
+ check_headers_length = 0
174
+ else
175
+ check_headers_length = headers.length
176
+ end
177
+
178
+ unless @classifide.type?
179
+ unless @classifide.type == "name" or @classifide.type == "email" or @classifide.type == "phone" or @classifide.type == "address"
180
+ if @classifide.type == "header_x"
181
+ resume_builder.send(@classifide.type + "_build")
182
+
183
+ if resume_builder.classifide_after == "header_x"
184
+ if resume_builder.classifide_after == "header_x" and resume_builder.instance_variable_get("@header_x_start") == "almost"
185
+ else
186
+ expect(resume_builder.instance_variable_get("@header_x_start")).to be_falsy
187
+ end
188
+
189
+ expect(resume_builder.bullets.values.length).to be > check_headers_length
190
+ expect(resume_builder.all_types.values.length).to be > check_all_types_length
191
+ expect(resume_builder.all_types[resume_builder.section_number?].length).to be > check_all_types_parent_length
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ it "should add to all_types" do
201
+ allow(resume_builder).to receive(:classifide) {"This is a fake classifide"}
202
+ resume_builder.all_types
203
+ expect(resume_builder.all_types.values.length).to eq(0)
204
+ resume_builder.add_to_all_types(1)
205
+ expect(resume_builder.all_types.values.length).to eq(1)
206
+ resume_builder.add_to_all_types(1)
207
+ expect(resume_builder.all_types.values.length).to eq(1)
208
+ expect(resume_builder.all_types[1].length).to eq(2)
209
+ end
210
+
211
+
212
+
213
+ end
@@ -0,0 +1,140 @@
1
+ require "spec_helper"
2
+ require "benchmark"
3
+
4
+ describe ResumeClassifier do
5
+
6
+
7
+ doc = Docx::Document.open('sample_resume.docx').text
8
+
9
+
10
+
11
+ let(:resume_classifier){ResumeClassifier.new(doc, "Sample Person", "fake_presume_object")}
12
+
13
+ it "should return resume text!" do
14
+ expect(resume_classifier.text).to_not be_nil
15
+ end
16
+
17
+ it "separates tabbed words" do
18
+ resume_classifier.instance_variable_set(:@text, "University of ChicagoJune 2008")
19
+ resume_classifier.separate_tabbed_words
20
+ expect(resume_classifier.text).to eq("University of Chicago,June 2008")
21
+ end
22
+
23
+ it "removes extra spaces" do
24
+ resume_classifier.instance_variable_set(:@text, "University of Chicago June 2008")
25
+ resume_classifier.remove_extra_spaces
26
+ expect(resume_classifier.text).to eq("University of Chicago ,,,,June 2008")
27
+ end
28
+
29
+
30
+ it "removes blank lines" do
31
+
32
+ resume_classifier.instance_variable_set("@lines", ["line with code", " "])
33
+
34
+ time = Benchmark.measure do
35
+ resume_classifier.remove_blanks
36
+ end
37
+ puts time
38
+
39
+ expect(resume_classifier.lines).to eq(["line with code"])
40
+
41
+ end
42
+
43
+ it "checks number of lines" do
44
+ resume_classifier.instance_variable_set("@lines", ["line with code", " "])
45
+
46
+ time = Benchmark.measure do
47
+ resume_classifier.number_of_lines
48
+ end
49
+ puts time
50
+
51
+ expect(resume_classifier.number_of_lines).to eq(2)
52
+ end
53
+
54
+
55
+ it "splits text by new lines" do
56
+ time = Benchmark.measure do
57
+ resume_classifier.split_text
58
+ end
59
+ puts time
60
+
61
+ expect(resume_classifier.lines).to_not be_nil
62
+ end
63
+
64
+ it "removes cities and dates from line" do
65
+ resume_classifier.instance_variable_set("@line", "line with, Toronto, Ontario Sep 2009")
66
+ expect(resume_classifier.remove_dates_and_cities).to eq("line with, ")
67
+ end
68
+
69
+ it "counts words without date and city" do
70
+ resume_classifier.instance_variable_set("@line", "line with, Toronto, Ontario Sep 2009")
71
+ expect(resume_classifier.number_of_words).to eq(2)
72
+ end
73
+
74
+ it "sets number of lines" do
75
+ resume_classifier.set_line_number(0)
76
+ expect(resume_classifier.instance_variable_get(:@line_number)).to eq(0)
77
+ end
78
+
79
+ it "sets number of lines" do
80
+ resume_classifier.set_line(0)
81
+ puts resume_classifier.instance_variable_get(:@lines)
82
+ expect(resume_classifier.instance_variable_get(:@line)).to eq("Professional Summary")
83
+ end
84
+
85
+ it "checks classifications" do
86
+ resume_classifier.split_text
87
+ expect(resume_classifier.number_of_lines).to be > 10
88
+
89
+ resume_classifier.number_of_lines.times do |n|
90
+
91
+ resume_classifier.set_line_number(n)
92
+ expect(resume_classifier.instance_variable_get(:@line_number)).to eq(n)
93
+ resume_classifier.set_line(n)
94
+ time = Benchmark.measure do
95
+ resume_classifier.check_classifications
96
+ end
97
+
98
+ puts time
99
+
100
+ end
101
+ end
102
+
103
+ it "merges to classifide lines" do
104
+ resume_classifier.split_text
105
+ expect(resume_classifier.number_of_lines).to be > 10
106
+
107
+ resume_classifier.number_of_lines.times do |n|
108
+
109
+ resume_classifier.set_line_number(n)
110
+ expect(resume_classifier.instance_variable_get(:@line_number)).to eq(n)
111
+ resume_classifier.set_line(n)
112
+
113
+ resume_classifier.check_classifications
114
+ time = Benchmark.measure do
115
+ resume_classifier.merge_to_classifide_lines
116
+ expect(resume_classifier.classifide_lines.length).to eq(n + 1)
117
+ end
118
+ puts time
119
+ end
120
+ end
121
+
122
+ =begin
123
+
124
+ it "classifies lines by resume components" do
125
+
126
+ time = Benchmark.measure do
127
+ resume_classifier.classify
128
+ end
129
+ puts time
130
+
131
+ expect(resume_classifier.classifide_lines[0].section).to eq("Professional Summary")
132
+ expect(resume_classifier.classifide_lines[1].phone).to be_nil
133
+ end
134
+
135
+ it "sorts classified lines into sections, headers, and bullets" do
136
+
137
+ end
138
+ =end
139
+
140
+ end