41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/resumr.rb', line 41
def self.subsection_title_list(str, with_first_block_sepparate = false)
possible_titles = [
["Top Skills", "Principais competências"],
["Certifications"],
["Contact", "Contato", "Contatar"],
["Experience","Experiência"],
["Education", "Formação Acadêmica"],
["Summary","Resumo"],
["Languages"],
["Publications"]
]
indexes = {}
possible_titles.each do |tit|
new_keyvalue = {}
title = tit[0]
index = nil
tit.each do |synonym|
index = str.index(synonym) if index.nil?
end
if ! index.nil?
new_keyvalue.store(
index,
title.gsub(" ","_").downcase.to_sym
)
indexes.merge!(new_keyvalue)
end
end
retorn = {}
sorted_indexes = indexes.keys.sort
if with_first_block_sepparate
first_block_index = sorted_indexes[0]
retorn.merge!(
{beginning:
str[0..(first_block_index-1)]
}
)
end
sorted_indexes.each.with_index do |current_block_index, k|
new_keyvalue = {}
next_block_index = 0
if k == (sorted_indexes.length - 1)
next_block_index = str.length
else
next_block_index = sorted_indexes[k+1]
end
new_keyvalue.store(
indexes[current_block_index],
str[current_block_index..next_block_index].lines[1..-1].join
)
retorn.merge!(new_keyvalue)
end
return retorn
end
|