-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdatedResume.java
More file actions
180 lines (167 loc) · 7.6 KB
/
UpdatedResume.java
File metadata and controls
180 lines (167 loc) · 7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//Duaa Zaheer, Davin Kyi, Allison Li
//11/20/2020
//Resume Reader
//Method description
/*
This is a program that will be able to give you a short anaylsis of a resume in
which you will be looking at. This will give a company a quick anaylsis on which
resume in which they looked at is most highly ranked, in other words, which one has
more points when compared to the other resumes given. Also, the program can also
give you the amount of experience you've had with a certain keyword, such as java.
This program will also allow you to see if the basic skills, such as Java are given
in the resume, and this is done by checking to see if it is contained within the
resume given. Last and not least, it will give you all the words that are contained
within the resume you are looking at.
*/
import java.util.*;
import java.io.*;
public class UpdatedResume {
/*
//imagine if a person say present
private static final String present = "present";
*/
//name of the person who wrote the resume
private String name;
//this most likely will just tell you all the words it contains
private Set<String> keyWords;
//<Keyword, Experience>
private Map<String, Integer> experience;
//these are the months in the years, and they are abbreviated
private ArrayList<String> months;
//this is the scanner we will need
private Scanner scanner;
//this is the file of the resume
private File resumeData;
private String[] formats = {"%m/%d/%y", "%M %d, %y", "%d/%m/%y"};
//i think we are going to pass in a file instead perhaps
public Resume(File file) throws FileNotFoundException {
scanner = new Scanner(file);
this.name = "";
String firstName = scanner.next();
String lastName = scanner.next();
this.name = firstName + " " + lastName;
this.resumeData = file;
//initalizing the Set of keywords in which we will be returning later
this.keyWords = new TreeSet<String>();
while(scanner.hasNext()) {
String word = scanner.next();
this.keyWords.add(word);
}
this.experience = new TreeMap<String, Integer>();
this.months = new ArrayList<String>();
//first one is 11/30/2015, Nov 27, 2002
String [] month = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
for (int i = 0; i < month.length; i++) {
months.add(month[i]);
}
}
//maybe we will assume that the person's name is the first two words in the resume
//this will return the name of the person wo wrote the resume
public String getName() {
//we have to determine how to get the name from the resume
//THIS WILL BE THE FIRST LINE OF THE METHOD, OR THE EMPLOYER WILL PUT IN THE NAME IN HERE
return this.name;
}
public Set<String> getKeyWords() {
return keyWords;
}
//this will check to see if all of the words are contained within your keyWords needed map
//might want to remove this later
public boolean qualify(Set<String> neededWords) {
return keyWords.containsAll(neededWords);
}
//this will allow you to get all of the individual keywords amount of experience
//by giving you the total time in which has shown up with the word
//THIS IS THE MAIN THING WE NEED TO GET TO WORK, SO FAR THE BASE STRUCTURE GIVEN SO FAR
//SHOULD WORK, WE MIGHT NEED TO DEBUG IF THIS DOSEN'T WORK,
public Map<String, Integer> getExperience() throws FileNotFoundException {
scanner = new Scanner(this.resumeData);
//this will work if we are assuming that the first 2 words are going to be the
//name of the person in which we are talking about
while(scanner.hasNextLine()) {
int totalMonths = 0;
String line = scanner.nextLine();
Scanner newScan = new Scanner(line);
//we only want to put the keyword once into the map
//and then from that one line, give that one keyword a time
//this will allow me to only change the times on the keywords found on
//the one line
Set<String> foundWords = new TreeSet<String>();
while (newScan.hasNext()) {
//this is a starter for the reading in of the time, but
//this is going to be trickier than i thought
String word = normalize(newScan.next());
//this is how we are going to find the time
//associated with each word on one line of the code
if (months.contains(word)) {
String startMonth = word;
int startYear = newScan.nextInt();
//we will think about what to do with a to or a - (always a -, or can it be a to/from, and etc.)
newScan.next(); //throws away the dash in the text
String endMonth = newScan.next();
int endYear = 0;
if (endMonth.equalsIgnoreCase("present")){
//endMonth = String.format("%d", Calendar.MONTH);
//Date date = new Date();
Calendar calendar = new GregorianCalendar();
endMonth = months.get(calendar.get(calendar.MONTH));
endYear = calendar.get(calendar.YEAR);
} else {
endMonth = endMonth.substring(0, 3);
endYear = newScan.nextInt();
}
totalMonths += (endYear - startYear) * 12;
//approx 30 days for each month, we can figure this out later as well
totalMonths += months.indexOf(endMonth) - months.indexOf(startMonth);
} else {
foundWords.add(word);
}
}
for (String keyWord : foundWords) {
if (!experience.containsKey(keyWord)) {
experience.put(keyWord, 0);
}
//for each of the words that were in that one line
//we will add the additional time
//but, we do not want to add the time to every word found,
//unless if it was on the line
experience.put(keyWord, experience.get(keyWord) + totalMonths);
}
}
//this is to remove all the cases where the experience is just 0
Set<String> remove = new HashSet<String>();
for (String keyWords : experience.keySet()) {
int time = experience.get(keyWords);
if (time == 0) {
remove.add(keyWords);
}
}
experience.keySet().removeAll(remove);
return experience;
}
public String normalize(String word) {
word = word.toLowerCase();
word = word.trim();
char end = word.charAt(word.length() - 1);
if (!Character.isLetterOrDigit(end)) {
word = word.substring(0, word.length() - 1);
}
return word;
}
// we want to figure out, are we going to be returning how many sets...
public Map<String, Set<String>> containsWanted(Map<String, Set<String>> keyWord) {
Map<String, Set<String>> foundKeyWords = new TreeMap<String, Set<String>>();
for (String type : keyWord.keySet()) {
Set<String> possibleKeyWords = keyWord.get(type);
for (String possibleKeyWord : possibleKeyWords) {
if (keyWords.contains(possibleKeyWord)) {
if (!foundKeyWords.containsKey(type)) {
foundKeyWords.put(type, new HashSet<String>());
}
foundKeyWords.get(type).add(possibleKeyWord);
}
}
}
return foundKeyWords;
}
}