Skip to content

Commit 26aa629

Browse files
author
JW Wesson
committed
updates for CompareSkillsToProfession
1 parent 355b320 commit 26aa629

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

src/main/java/com/sovren/SovrenClient.java

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.sovren.models.api.dataenrichment.ontology.response.CompareSkillsToProfessionResponse;
2626
import com.sovren.models.api.dataenrichment.ontology.response.SuggestProfessionsResponse;
2727
import com.sovren.models.api.dataenrichment.ontology.response.SuggestSkillsResponse;
28+
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
2829
import com.sovren.models.api.dataenrichment.professions.request.LookupProfessionCodesRequest;
2930
import com.sovren.models.api.dataenrichment.professions.request.NormalizeProfessionsRequest;
3031
import com.sovren.models.api.dataenrichment.professions.response.GetProfessionsTaxonomyResponse;
@@ -73,7 +74,10 @@
7374
import java.time.Instant;
7475
import java.util.ArrayList;
7576
import java.util.Arrays;
77+
import java.util.Collections;
78+
import java.util.Comparator;
7679
import java.util.List;
80+
import java.util.Optional;
7781

7882
/**
7983
* The SDK client to perform Sovren API calls.
@@ -1584,7 +1588,7 @@ public LookupProfessionCodesResponse lookupProfessions(List<Integer> codeIds) th
15841588
* Compare two professions based on the skills associated with each.
15851589
* @param profession1 A profession code ID from the <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#professions-taxonomies">Professions Taxonomy</a> to compare.
15861590
* @param profession2 A profession code ID from the <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#professions-taxonomies">Professions Taxonomy</a> to compare.
1587-
* @param outputLanguage The language to use for the returned descriptions.
1591+
* @param outputLanguage The language to use for the returned descriptions. If not provided, no descriptions are returned. Must be one of the supported <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#skills-languages">ISO code</a>
15881592
* @return The API response body
15891593
* @throws SovrenException Thrown when an API error occurs
15901594
*/
@@ -1607,20 +1611,22 @@ public CompareProfessionsResponse compareProfessions(int profession1, int profes
16071611
/**
16081612
* Compare a given set of skills to the skills related to a given profession.
16091613
* @param professionCodeId The profession code ID from the <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#professions-taxonomies">Professions Taxonomy</a> to compare the skill set to.
1610-
* @param skillIds The skill IDs which should be compared against the given profession. The list can contain up to 50 skills.
1614+
* @param outputLanguage The language to use for the returned descriptions. If not provided, no descriptions are returned. Must be one of the supported <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#skills-languages">ISO code</a>
1615+
* @param skills The skills which should be compared against the given profession. The list can contain up to 50 skills.
16111616
* @return The API response body
16121617
* @throws SovrenException Thrown when an API error occurs
16131618
*/
1614-
public CompareSkillsToProfessionResponse compareSkillsToProfessions(int professionCodeId, String... skillIds) throws SovrenException {
1619+
public CompareSkillsToProfessionResponse compareSkillsToProfessions(int professionCodeId, String outputLanguage, SkillScore... skills) throws SovrenException {
16151620
CompareSkillsToProfessionRequest request = new CompareSkillsToProfessionRequest();
1616-
request.SkillIds = new ArrayList<String>();
1617-
List<String> newList = Arrays.asList(skillIds);
1621+
request.Skills = new ArrayList<SkillScore>();
1622+
List<SkillScore> newList = Arrays.asList(skills);
16181623
int amountOfSkills = newList.size() > 50 ? 50 : newList.size();
16191624

16201625
for(int i = 0; i < amountOfSkills; i++) {
1621-
request.SkillIds.add(newList.get(i));
1626+
request.Skills.add(newList.get(i));
16221627
};
16231628
request.ProfessionCodeId = professionCodeId;
1629+
request.OutputLanguage = outputLanguage;
16241630

16251631
RequestBody body = createJsonBody(request);
16261632
Request apiRequest = new Request.Builder()
@@ -1636,17 +1642,34 @@ public CompareSkillsToProfessionResponse compareSkillsToProfessions(int professi
16361642
* Compare the skills of a candidate to the skills related to a job using the Ontology API.
16371643
* @param resume The resume containing the skills of the candidate
16381644
* @param professionCodeId The profession code ID from the <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#professions-taxonomies">Professions Taxonomy</a> to compare the skill set to.
1645+
* @param outputLanguage The language to use for the returned descriptions. If not provided, no descriptions are returned. Must be one of the supported <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#skills-languages">ISO code</a>
1646+
* @param weightSkillsByExperience The language to use for the returned descriptions.
16391647
* @return The API response body
16401648
* @throws SovrenException Thrown when an API error occurs
16411649
*/
1642-
public CompareSkillsToProfessionResponse compareSkillsToProfessions(ParsedResume resume, int professionCodeId) throws SovrenException {
1650+
public CompareSkillsToProfessionResponse compareSkillsToProfessions(
1651+
ParsedResume resume,
1652+
int professionCodeId,
1653+
String outputLanguage,
1654+
boolean weightSkillsByExperience) throws SovrenException {
16431655
if(resume != null && resume.Skills != null && resume.Skills.Normalized != null && resume.Skills.Normalized.size() > 0){
1644-
String[] skillIds = new String[resume.Skills.Normalized.size()];
1656+
SkillScore[] skills = new SkillScore[resume.Skills.Normalized.size()];
1657+
1658+
ResumeNormalizedSkill maxExperienceSkill = Collections.max(resume.Skills.Normalized, Comparator.comparing(s -> s.MonthsExperience != null ? s.MonthsExperience.Value : 0));
1659+
Integer maxExperience = Optional.ofNullable(maxExperienceSkill).map(s -> s.MonthsExperience).map(e -> e.Value).orElse(0);
1660+
16451661
for(int i = 0; i < resume.Skills.Normalized.size(); i++) {
1646-
skillIds[i] = resume.Skills.Normalized.get(i).Id;
1662+
SkillScore curSkill = new SkillScore();
1663+
ResumeNormalizedSkill curSkillOrig = resume.Skills.Normalized.get(i);
1664+
curSkill.Id = curSkillOrig.Id;
1665+
1666+
int curMonthsExperience = Optional.ofNullable(curSkillOrig.MonthsExperience).map(e -> e.Value).orElse(0);
1667+
curSkill.Score = (weightSkillsByExperience && maxExperience > 0) ? curMonthsExperience / (float)maxExperience : 1;
1668+
1669+
skills[i] = curSkill;
16471670
}
16481671

1649-
return compareSkillsToProfessions(professionCodeId,skillIds);
1672+
return compareSkillsToProfessions(professionCodeId, outputLanguage, skills);
16501673
}
16511674
throw new IllegalArgumentException("The resume must be parsed with V2 skills selected, and with skills normalization enabled");
16521675
}

src/main/java/com/sovren/models/api/dataenrichment/ontology/request/CompareSkillsToProfessionRequest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
package com.sovren.models.api.dataenrichment.ontology.request;
77

88
import java.util.List;
9+
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
910

1011
/** Request body for a 'CompareSkillsToProfession' request */
1112
public class CompareSkillsToProfessionRequest {
12-
/** The skill IDs which should be compared against the given profession. The list can contain up to 50 skills. */
13-
public List<String> SkillIds;
13+
/** The skills which should be compared against the given profession. The list can contain up to 50 skills. */
14+
public List<SkillScore> Skills;
1415
/** The profession code ID from the <a href="https://sovren.com/technical-specs/latest/rest-api/data-enrichment/overview/#professions-taxonomies">Professions Taxonomy</a> to compare the skill set to. */
1516
public int ProfessionCodeId;
17+
/** The language to use for the returned descriptions. */
18+
public String OutputLanguage;
1619
}

src/test/java/com/sovren/integration/DataEnrichmentServiceTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.sovren.TestBase;
99
import com.sovren.models.api.dataenrichment.TaxonomyFormat;
10+
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
1011

1112
import org.junit.jupiter.api.Test;
1213

@@ -116,7 +117,13 @@ public void testCompareProfessions() {
116117
@Test
117118
public void testCompareSkillsToProfessions() {
118119
assertDoesNotThrow(() -> {
119-
Client.compareSkillsToProfessions(696, "KS120076FGP5WGWYMP0F", "KS04UWLJBN9X1M3N0PZ4");
120+
SkillScore s1 = new SkillScore();
121+
SkillScore s2 = new SkillScore();
122+
123+
s1.Id = "KS120076FGP5WGWYMP0F";
124+
s2.Id = "KS04UWLJBN9X1M3N0PZ4";
125+
126+
Client.compareSkillsToProfessions(696, "en", s1, s2);
120127
});
121128
}
122129

0 commit comments

Comments
 (0)