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.
@@ -0,0 +1,137 @@
1
+ class ResumeClassifier
2
+
3
+ attr_accessor :text, :lines, :classifide_lines
4
+
5
+ def initialize(resume_text, name, presume)
6
+ @text = resume_text
7
+ @classifide_lines = {}
8
+ @lines = []
9
+ @user_name = name
10
+ @presume = presume
11
+ clean_text
12
+ split_text
13
+ end
14
+
15
+ def lines_together
16
+ @lines_together ||= @lines.join("\n")
17
+ end
18
+
19
+ def tagged_lines_together
20
+ @tagged_lines_together ||= tgr.add_tags(lines_together)
21
+ end
22
+
23
+ def tagged_lines
24
+ @tagged_lines ||= tagged_lines_together.split("\n")
25
+ end
26
+
27
+ def regex_name
28
+ Regexp.new(@user_name, "i")
29
+ end
30
+
31
+ def clean_text
32
+ separate_tabbed_words
33
+ remove_extra_spaces
34
+ end
35
+
36
+ def remove_extra_spaces
37
+ @text = @text.gsub(regex_remove_extra_spaces, ",")
38
+ end
39
+
40
+
41
+ def separate_tabbed_words
42
+ @text = @text.gsub(regex_separate_tabbed_words, ",")
43
+ end
44
+
45
+ def split_text
46
+ @lines = @text.split("\n")
47
+ remove_blanks
48
+ end
49
+
50
+ def remove_all_lines
51
+ @lines = []
52
+ end
53
+
54
+ def remove_blanks
55
+ @lines = @lines.reject{|line| blank?(line)}
56
+ end
57
+
58
+ def number_of_lines
59
+ @lines.length
60
+ end
61
+
62
+ def blank?(line)
63
+ line[regex_characters_and_digits].nil?
64
+ end
65
+
66
+ def classify
67
+ number_of_lines.times do |n|
68
+ set_line_number(n)
69
+ set_line(n)
70
+ check_classifications
71
+ merge_to_classifide_lines
72
+ end
73
+ end
74
+
75
+ def line_text(n)
76
+ @lines[n]
77
+ end
78
+
79
+ def set_line(number)
80
+ @line = @lines[number]
81
+ end
82
+
83
+ def set_line_number(number)
84
+ @line_number = number
85
+ end
86
+
87
+ def check_classifications
88
+ classifications.each do |classification|
89
+ set_classification_instance(classification)
90
+ end
91
+ end
92
+
93
+ def set_classification_instance(classification)
94
+ instance_variable_set(("@" + classification).to_sym, classification?(classification))
95
+ end
96
+
97
+ def classification?(classification)
98
+ @line[regex_(classification)]
99
+ end
100
+
101
+ def regex_(classification)
102
+ send("regex_#{classification}")
103
+ end
104
+
105
+ def merge_to_classifide_lines
106
+ pass_classification_instances_to_hash
107
+ @classifide_lines.merge!({@line_number => Classifide.new(@line_classifications.merge(line_non_regex_classifications))})
108
+ end
109
+
110
+ def line_non_regex_classifications
111
+ @non_regex_classications = {number_of_words: number_of_words, many_words: many_words, verbs: verbs?, text: @line, type: nil, id: @line_number, presume: @presume}
112
+ end
113
+
114
+ def remove_dates_and_cities
115
+ @date_and_city_less_line = @line.gsub(Regexp.union(regex_dates,regex_dates_2,regex_cities),"")
116
+ end
117
+ def number_of_words
118
+ @number_of_words = remove_dates_and_cities.split.size
119
+ end
120
+
121
+ def many_words
122
+ @number_of_words >= 5
123
+ end
124
+
125
+ def verbs?
126
+ if tagged_lines[@line_number].nil?
127
+ @verbs = nil
128
+ else
129
+ @verbs = tagged_lines[@line_number][regex_engtagger_verbs]
130
+ end
131
+ end
132
+
133
+ def pass_classification_instances_to_hash
134
+ @line_classifications = Hash[classifications.map{|classification| [classification.to_sym, instance_variable_get("@#{classification}")]}]
135
+ end
136
+
137
+ end
@@ -0,0 +1,4 @@
1
+ class ResumeSearcher
2
+
3
+
4
+ end
@@ -0,0 +1,40 @@
1
+ class Searchable
2
+
3
+ attr_accessor :raw_name, :duration
4
+
5
+ def initialize(hash)
6
+ @raw_name = hash[:raw_name]
7
+ @duration = hash[:duration]
8
+ end
9
+
10
+ def names
11
+ if @names.nil?
12
+ @names = []
13
+ @searchable_words = @raw_name.downcase.split
14
+ @searchable_words.each do |word|
15
+ @names += [stemmed(word)]
16
+ end
17
+ @names
18
+ else
19
+ @names
20
+ end
21
+ end
22
+
23
+ def regex
24
+ if @regex.nil?
25
+ @regexes = ""
26
+ names.each do |name|
27
+ @regexes += '(?=.*' + name + ')'
28
+ end
29
+ @regexes += ".*"
30
+ @regex = Regexp.new(@regexes, "i")
31
+ else
32
+ @regex
33
+ end
34
+ end
35
+
36
+ def check_regex(searchable_title)
37
+ !searchable_title.downcase[regex].nil?
38
+ end
39
+
40
+ end
@@ -0,0 +1,24 @@
1
+ class Searchables
2
+
3
+ attr_accessor :raw
4
+
5
+ def initialize(hash)
6
+ @raw = hash
7
+ @all = {}
8
+ end
9
+
10
+ def duration(name)
11
+ @raw[name]
12
+ end
13
+
14
+ def all
15
+ if @all.empty?
16
+ @raw.keys.each do |name|
17
+ @all.merge!(name => Searchable.new({raw_name: name, duration: duration(name)}))
18
+ end
19
+ @all
20
+ else
21
+ @all
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+
2
+ def classifications
3
+ @classifications ||= ["name", "phone", "email", "address", "section", "professions", "companies", "schools", "dates", "cities"]
4
+ end
5
+
6
+ def non_regex_classifications
7
+ non_regex_classifications ||= ["number_of_words", "many_words", "verbs", "text", "type", "id", "presume"]
8
+ end
9
+
10
+ def both_classifications
11
+ @both_classifications ||= classifications + non_regex_classifications
12
+ end
13
+
14
+ def both_classifications_symboled
15
+ both_classifications_symboled ||= both_classifications.map {|x| x.to_sym}
16
+ end
17
+
18
+ def header_classifications
19
+ @header_classifications ||= ["professions", "companies", "schools", "dates", "cities"]
20
+ end
21
+
22
+ def set_time_at_inception(time, presume)
23
+ instance_variable_set("@#{time}", presume)
24
+ end
@@ -0,0 +1,11 @@
1
+ def tgr
2
+ @tgr ||= EngTagger.new
3
+ end
4
+
5
+ def stemmer
6
+ @stemmer ||= Lingua::Stemmer.new(:language => "en")
7
+ end
8
+
9
+ def stemmed(word)
10
+ stemmer.stem(word)
11
+ end
@@ -0,0 +1,79 @@
1
+ def regex_cities
2
+ @regex_cities ||= Regexp.new("([a-z]{2,} ){0,3}[a-z]{2,}\\, " + "\\b(AK|Alaska|AL|Alabama|AR|Arkansas|AZ|Arizona|CA|California|CO|Colorado|CT|Connecticut|DE|Delaware|FL|Florida|GA|Georgia|HI|Hawaii|IA|Iowa|ID|Idaho|IL|Illinois|IN|Indiana|KS|Kansas|KY|Kentucky|LA|Louisiana|MA|Massachusetts|MD|Maryland|ME|Maine|MI|Michigan|MN|Minnesota|MO|Missouri|MS|Mississippi|MT|Montana|NC|North Carolina|ND|North Dakota|NE|Nebraska|NH|New Hampshire|NJ|New Jersey|NM|New Mexico|NV|Nevada|NY|New York|OH|Ohio|OK|Oklahoma|OR|Oregon|PA|Pennsylvania|RI|Rhode Island|SC|South Carolina|SD|South Dakota|TN|Tennessee|TX|Texas|UT|Utah|VA|Virginia|VT|Vermont|WA|Washington|WI|Wisconsin|WV|West Virginia|WY|Wyoming|AB|Alberta|BC|British Columbia|MB|Manitoba|NB|New Brunswick|NL|Newfoundland and Labrador|NS|Nova Scotia|ON|Ontario|PE|Prince Edward Island|QC|Quebec|SK|Saskatchewan)" + "\\b", "i")
3
+ end
4
+
5
+ def regex_professions
6
+ @regex_professions ||= Regexp.new('([A-Z][a-z]* ){0,5}(coordinator|assistant|asst|manager|director|technician|analyst|associate|developer|programmer|nurse|consutlant|worker|clerk|receptionist|secretary|teacher|engineer|administrator|researcher|head of|admin|intern|database|leader|server|waitress|waiter|busboy)\b(\.|)( [A-Z][a-z]*){0,5}', 'i')
7
+ end
8
+
9
+ def regex_schools
10
+ @regex_schools ||= Regexp.new("([a-z]{1,} ){0,5}(university|college)\\b(( [a-z]{1,}){0,5}|)", "i")
11
+ end
12
+
13
+ def regex_companies
14
+ @regex_companies ||= Regexp.new(/(([A-Z][a-z]* )*and ([A-Z][a-z]* )*|([A-Z][a-z]* )*)(Inc|INC|Corp|CORP|CO|Co|LTD|Ltd)\b(\.|)/)
15
+ end
16
+
17
+ def regex_address
18
+ @regex_address ||= Regexp.new("\\d (\\w{2,} ){1,2}(Alley|ALY|Annex|ANX|Arcade|ARC|Avenue|AVE|Bayou|YU|Beach|BCH|Bend|BND|Bluff|BLF|Bottom|BTM|Boulevard|BLVD|Branch|BR|Bridge|BRG|Brook|BRK|Burg|BG|Bypass|BYP|Camp|CP|Canyon|CYN|Cape|CPE|Causeway|CSWY|Center|CTR|Circle|CIR|Cliffs|CLFS|Club|CLB|Corner|COR|Corners|CORS|Course|CRSE|Court|CT|Courts|CTS|Cove|CV|Creek|CRK|Crescent|CRES|Crossing|XING|Dale|DL|Dam|DM|Divide|DV|Drive|DR|Estates|EST|Expressway|EXPY|Extension|EXT|Fall|FALL|Falls|FLS|Ferry|FRY|Field|FLD|Fields|FLDS|Flats|FLT|Ford|FOR|Forest|FRST|Forge|FGR|Fork|FORK|Forks|FRKS|Fort|FT|Freeway|FWY|Gardens|GDNS|Gateway|GTWY|Glen|GLN|Green|GN|Grove|GRV|Harbor|HBR|Haven|HVN|Heights|HTS|Highway|HWY|Hill|HL|Hills|HLS|Hollow|HOLW|Inlet|INLT|Island|IS|Islands|ISS|Isle|ISLE|Junction|JCT|Key|CY|Knolls|KNLS|Lake|LK|Lakes|LKS|Landing|LNDG|Lane|LN|Light|LGT|Loaf|LF|Locks|LCKS|Lodge|LDG|Loop|LOOP|Mall|MALL|Manor|MNR|Meadows|MDWS|Mill|ML|Mills|MLS|Mission|MSN|Mount|MT|Mountain|MTN|Neck|NCK|Orchard|ORCH|Oval|OVAL|Park|PARK|Parkway|PKY|Pass|PASS|Path|PATH|Pike|PIKE|Pines|PNES|Place|PL|Plain|PLN|Plains|PLNS|Plaza|PLZ|Point|PT|Port|PRT|Prairie|PR|Radial|RADL|Ranch|RNCH|Rapids|RPDS|Rest|RST|Ridge|RDG|River|RIV|Road|RD|Row|ROW|Run|RUN|Shoal|SHL|Shoals|SHLS|Shore|SHR|Shores|SHRS|Spring|SPG|Springs|SPGS|Spur|SPUR|Square|SQ|Station|STA|Stravenues|STRA|Stream|STRM|Street|ST|Summit|SMT|Terrace|TER|Trace|TRCE|Track|TRAK|Trail|TRL|Trailer|TRLR|Tunnel|TUNL|Turnpike|TPKE|Union|UN|Valley|VLY|Viaduct|VIA|View|VW|Village|VLG|Ville|VL|Vista|VIS|Walk|WALK|Way|WAY|Wells|WLS)(\\b|\\.\\b)", "i")
19
+ end
20
+
21
+ def regex_phone
22
+ @regex_phone ||= Regexp.new("\\d\\d\\d(|\\))(| |-)(\\(|)\\d\\d\\d(|\\))(| |-)\\d\\d\\d\\d", "i")
23
+ end
24
+
25
+ def regex_email
26
+ @regex_email ||= Regexp.new("\\b(\\w){1,}@(\\w){1,}\\.(\\w){1,5}\\b", "i")
27
+ end
28
+
29
+ def regex_dates
30
+ @regex_dates ||= Regexp.union(regex_dates_1, regex_dates_2)
31
+ end
32
+
33
+ def regex_dates_1
34
+ @regex_dates_1 ||= Regexp.new("((January|Jan|March|Mar|May|May|July|Jul|September|Sep|Sept|November|Nov|February|Feb|April|Apr|June|Jun|August|Aug|October|Oct|December|Dec|Winter|Fall|Summer|Spring)( |)(\\d{2}\\b|\\d{4}\\b)( |)(–|-|to)( |)((January|Jan|March|Mar|May|May|July|Jul|September|Sep|Sept|November|Nov|February|Feb|April|Apr|June|Jun|August|Aug|October|Oct|December|Dec|Winter|Fall|Summer|Spring)( |)(\\d{2}\\b|\\d{4}\\b)|present|current|today)|(January|Jan|March|Mar|May|May|July|Jul|September|Sep|Sept|November|Nov|February|Feb|April|Apr|June|Jun|August|Aug|October|Oct|December|Dec|Winter|Fall|Summer|Spring)( |)(\\d{2}\\b|\\d{4}\\b))", "i")
35
+ end
36
+
37
+ def regex_dates_2
38
+ @regex_dates_2 ||= Regexp.new("((\\d{2}\\b)(| )(–|-|to)(| )(\\d{2}\\b|present\\b)|(\\d{4}\\b)(| )(–|-|to)(| )(\\d{4}\\b|present\\b))", "i")
39
+ end
40
+
41
+ def regex_month
42
+ @regex_month ||= Regexp.new('January|Jan|March|Mar|May|May|July|Jul|September|Sep|Sept|November|Nov|February|Feb|April|Apr|June|Jun|August|Aug|October|Oct|December|Dec', 'i')
43
+ end
44
+
45
+ def regex_season
46
+ @regex_season ||= Regexp.new('Winter|Fall|Summer|Spring', 'i')
47
+ end
48
+
49
+ def regex_year
50
+ @regex_year ||= Regexp.new('\b\d\d\d\d\b|\b\d\d\b', 'i')
51
+ end
52
+
53
+ def regex_section
54
+ @regex_section ||= Regexp.new("([a-z]* ){0,5}(highlight|professional development|summary|experience|skills|education|qualifications|interests|profile)( [a-z]*){0,5}", "i")
55
+ end
56
+
57
+ def regex_new_lines_and_blanks
58
+ @regex_new_lines ||= Regexp.new(/\n\n\n\n|\n\n\n|\n\n|\n| /)
59
+ end
60
+
61
+ def regex_engtagger_verbs
62
+ @regex_engtagger_verbs ||= Regexp.new(/<vb[a-z]{0,1}>/)
63
+ end
64
+
65
+ def regex_separate_tabbed_words
66
+ @regex_separate_tabbed_words ||= Regexp.new('(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])|(?<=\d)(?=[A-Za-z])')
67
+ end
68
+
69
+ def regex_remove_extra_spaces
70
+ @regex_remove_extra_spaces ||= Regexp.new('(?<= ) ')
71
+ end
72
+
73
+ def regex_characters_and_digits
74
+ Regexp.new(/[A-Za-z]|\d/)
75
+ end
76
+
77
+ def regex_current
78
+ @regex_current ||= Regexp.new('current|present|today', 'i')
79
+ end
@@ -0,0 +1,123 @@
1
+ require "engtagger"
2
+ require 'docx'
3
+ require 'lingua/stemmer'
4
+ require 'date'
5
+ require "definitions/regex.rb"
6
+ require "definitions/classifications.rb"
7
+ require "definitions/machines.rb"
8
+ require "sort/resume_builder.rb"
9
+ require "sort/resume_classifier.rb"
10
+ require "sort/classifide.rb"
11
+ require "sort/header.rb"
12
+ require "sort/bullet.rb"
13
+ require "sort/searchable.rb"
14
+ require "sort/searchables.rb"
15
+
16
+ class Presume
17
+
18
+ attr_accessor :sections, :headers, :bullets, :all_types, :classifides
19
+
20
+ def initialize(doc, name)
21
+ @resume_classifier = ResumeClassifier.new(doc, name, self)
22
+ @resume_classifier.classify
23
+ @resume_builder = ResumeBuilder.new(@resume_classifier.classifide_lines)
24
+ @resume_builder.first_pass
25
+ @resume_builder.second_pass
26
+ @resume_builder.build_resume
27
+ @sections = @resume_builder.resume[:sections]
28
+ @headers = @resume_builder.resume[:headers]
29
+ @bullets = @resume_builder.resume[:bullets]
30
+ @all_types = @resume_builder.resume[:all_types]
31
+ end
32
+
33
+ def get_sections_info
34
+ @sections.values
35
+ end
36
+
37
+ def get_sections_id
38
+ @sections.keys
39
+ end
40
+
41
+ def get_headers_info
42
+ @headers.values
43
+ end
44
+
45
+ def get_headers_id
46
+ @headers.keys
47
+ end
48
+
49
+ def get_bullets_info
50
+ @bullets.values
51
+ end
52
+
53
+ def get_bullets_ids
54
+ @bullets.keys
55
+ end
56
+
57
+ def get_id(id)
58
+ @all_types[id][0]
59
+ end
60
+
61
+ def searchables?(hash) #word phrase => duration
62
+ match_searchables_to_classifides(hash, @headers)
63
+ end
64
+
65
+ def skills?(hash) #word phrase => duration
66
+ match_searchables_to_classifides(hash, @bullets)
67
+ end
68
+
69
+ def match_searchables_to_classifides(hash, classifides)
70
+ setup_match_searchables(hash, classifides)
71
+ check_for_searchable_match
72
+ return @matched_searchables
73
+ end
74
+
75
+ def setup_match_searchables(hash, classifides)
76
+ set_classifides(classifides)
77
+ set_searchables(hash)
78
+ reset_matched_searchables
79
+ end
80
+
81
+ def set_classifides(classifides)
82
+ @classifides = classifides
83
+ end
84
+
85
+ def set_searchables(hash)
86
+ @searchables = Searchables.new(hash)
87
+ end
88
+
89
+ def reset_matched_searchables
90
+ @matched_searchables = []
91
+ end
92
+
93
+ def check_for_searchable_match
94
+ classifide_objects.each do |classifide|
95
+ searchable_objects.each do |searchable|
96
+ if matched_text?(classifide, searchable) and matched_duration?(classifide, searchable)
97
+ add_to_matched_searchables(classifide, searchable)
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def classifide_objects
104
+ @classifides.values
105
+ end
106
+
107
+ def searchable_objects
108
+ @searchables.all.values
109
+ end
110
+
111
+ def matched_text?(classifide, searchable)
112
+ !classifide.text[searchable.regex].nil?
113
+ end
114
+
115
+ def matched_duration?(classifide, searchable)
116
+ classifide.duration >= searchable.duration
117
+ end
118
+
119
+ def add_to_matched_searchables(classifide, searchable)
120
+ @matched_searchables += [[searchable,classifide]]
121
+ end
122
+ end
123
+