-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscoreCalculator.java
More file actions
70 lines (41 loc) · 1.94 KB
/
scoreCalculator.java
File metadata and controls
70 lines (41 loc) · 1.94 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
public class scoreCalculator {
public static float skillScoreCalculator(String keyValuePairs, String candidateSkills) {
float result = 0;
//the number of things the candidate has that are matching the recruioterss needs
//I am assuming the data comes in a format such that {'key:value','.....'}
//It should use the , term as the separator
String[] pair=keyValuePairs.split(",");
for(String data : pair) {
String[] keyValue=data.split(":");
String candidateSkillslowerFormat=candidateSkills.toLowerCase();
if(candidateSkillslowerFormat.contains(","+keyValue[0].toLowerCase())||candidateSkillslowerFormat.contains(keyValue[0].toLowerCase()+",")||candidateSkillslowerFormat.contains(","+keyValue[0].toLowerCase()+",")) {
result= result + Integer.parseInt(keyValue[1]);
}
}
System.out.println(result+" is skillScore matching");
return result;
}
public static int scoreOfRequiredSkills(String keyValuePairs) {
//calculate the number of matching skills, for our algorithm to calculate avg
int score=0; //the number of things the candidate has that are matching the recruioterss needs
//I am assuming the data comes in a format such that {'key:value','.....'}
//It should use the , term as the separator
String[] pair=keyValuePairs.split(",");
for(String data : pair) {
String[] keyValue=data.split(":");
score=score + Integer.parseInt(keyValue[1]);
}
System.out.println(score+" is the max possible skillScore");
return score;
}
public static float ultimateAlgorithm(String keyValuePairs, String candidateSkills) {
float finalScore=0;
int parameterCount=1;
finalScore=skillScoreCalculator(keyValuePairs,candidateSkills)/scoreOfRequiredSkills(keyValuePairs);
finalScore/=parameterCount;
return finalScore*100;
}
public static void main(String args[]) {
System.out.println(ultimateAlgorithm("java:10,CPP:7,Python:4","java,Cpp"));
}
}