Skip to content

Commit 92d75c9

Browse files
author
JW Wesson
committed
add new endpoints
1 parent af0c741 commit 92d75c9

File tree

6 files changed

+226
-1
lines changed

6 files changed

+226
-1
lines changed

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

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
import com.sovren.models.api.dataenrichment.professions.response.GetProfessionsTaxonomyResponseValue;
2020
import com.sovren.models.api.dataenrichment.ontology.request.CompareProfessionsRequest;
2121
import com.sovren.models.api.dataenrichment.ontology.request.CompareSkillsToProfessionRequest;
22+
import com.sovren.models.api.dataenrichment.ontology.request.SkillsSimilarityScoreRequest;
2223
import com.sovren.models.api.dataenrichment.ontology.request.SuggestProfessionsRequest;
2324
import com.sovren.models.api.dataenrichment.ontology.request.SuggestSkillsFromProfessionsRequest;
25+
import com.sovren.models.api.dataenrichment.ontology.request.SuggestSkillsFromSkillsRequest;
2426
import com.sovren.models.api.dataenrichment.ontology.response.CompareProfessionsResponse;
2527
import com.sovren.models.api.dataenrichment.ontology.response.CompareSkillsToProfessionResponse;
2628
import com.sovren.models.api.dataenrichment.ontology.response.SuggestProfessionsResponse;
2729
import com.sovren.models.api.dataenrichment.ontology.response.SuggestSkillsResponse;
2830
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
31+
import com.sovren.models.api.dataenrichment.ontology.response.SkillsSimilarityScoreResponse;
2932
import com.sovren.models.api.dataenrichment.professions.request.LookupProfessionCodesRequest;
3033
import com.sovren.models.api.dataenrichment.professions.request.NormalizeProfessionsRequest;
3134
import com.sovren.models.api.dataenrichment.professions.response.GetProfessionsTaxonomyResponse;
@@ -1861,7 +1864,7 @@ public SuggestProfessionsResponse suggestProfessionsFromSkills(ParsedJob job) th
18611864

18621865
/**
18631866
* Suggest professions based on a given set of skills.
1864-
* @param skillIds The skills used to return the most relevant professions. The list can contain up to 50 skills.
1867+
* @param skills The skills used to return the most relevant professions. The list can contain up to 50 skills.
18651868
* @param limit The maximum amount of professions returned. If not sure what value should be, provide 10 as default limit.
18661869
* @param returnMissingSkills Flag to enable returning a list of missing skills per suggested profession.
18671870
* @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/#professions-languages">ISO code</a>
@@ -1902,4 +1905,141 @@ public SuggestProfessionsResponse suggestProfessionsFromSkills(List<String> skil
19021905
.collect(Collectors.toList());
19031906
return suggestProfessionsFromSkills(skills, 10, false, outputLanguage);
19041907
}
1908+
1909+
/**
1910+
* Returns skills related to a given skill or set of skills. The service returns closely related skills in a sense that
1911+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
1912+
* easier to acquire knowledge about them.
1913+
* @param skills The skills (and optionally, scores) for which the service should return related skills. The list can contain up to 50 skills.
1914+
* @param limit The maximum amount of suggested skills returned. The maximum is 25.
1915+
* @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>
1916+
* @return The API response body
1917+
* @throws SovrenException Thrown when an API error occurs
1918+
*/
1919+
public SuggestSkillsResponse suggestSkillsFromSkills(
1920+
List<SkillScore> skills,
1921+
int limit,
1922+
String outputLanguage) throws SovrenException {
1923+
SuggestSkillsFromSkillsRequest request = new SuggestSkillsFromSkillsRequest();
1924+
request.Skills = skills;
1925+
request.Limit = limit;
1926+
request.OutputLanguage = outputLanguage;
1927+
1928+
RequestBody body = createJsonBody(request);
1929+
Request apiRequest = new Request.Builder()
1930+
.url(_endpoints.desOntologySuggestSkillsFromSkills())
1931+
.post(body)
1932+
.build();
1933+
1934+
HttpResponse<SuggestSkillsResponse> response = executeRequest(apiRequest, SuggestSkillsResponse.class, getBodyIfDebug(apiRequest));
1935+
return response.getData();
1936+
}
1937+
1938+
/**
1939+
* Returns skills related to a given skill or set of skills. The service returns closely related skills in a sense that
1940+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
1941+
* easier to acquire knowledge about them.
1942+
* @param skillIds The skill IDs for which the service should return related skills. The list can contain up to 50 skills.
1943+
* @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>
1944+
* @return The API response body
1945+
* @throws SovrenException Thrown when an API error occurs
1946+
*/
1947+
public SuggestSkillsResponse suggestSkillsFromSkills(List<String> skillIds, String outputLanguage) throws SovrenException {
1948+
return suggestSkillsFromSkills(skillIds.stream().map(s -> new SkillScore(s)).collect(Collectors.toList()), 25, outputLanguage);
1949+
}
1950+
1951+
/**
1952+
* Suggests skills related to a job (but not in the job) based on the skills in the job. The service returns closely related skills in a sense that
1953+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
1954+
* easier to acquire knowledge about them.
1955+
* @param job The job to suggest skills for (based on the skills in the job).
1956+
* @param limit The maximum amount of suggested skills returned. The maximum is 25.
1957+
* @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>
1958+
* @return The API response body
1959+
* @throws SovrenException Thrown when an API error occurs
1960+
*/
1961+
public SuggestSkillsResponse suggestSkillsFromSkills(
1962+
ParsedJob job,
1963+
int limit,
1964+
String outputLanguage) throws SovrenException {
1965+
if(job != null && job.Skills != null && job.Skills.Normalized != null && job.Skills.Normalized.size() > 0){
1966+
List<SkillScore> skills = new ArrayList<SkillScore>();
1967+
int amountOfSkills = job.Skills.Normalized.size() > 50 ? 50 : job.Skills.Normalized.size();
1968+
for(int i = 0; i < amountOfSkills; i++) {
1969+
skills.add(new SkillScore(job.Skills.Normalized.get(i).Id));
1970+
}
1971+
1972+
return suggestSkillsFromSkills(skills, limit, outputLanguage);
1973+
}
1974+
throw new IllegalArgumentException("The job must be parsed with V2 skills selected, and with skills normalization enabled");
1975+
}
1976+
1977+
/**
1978+
* Suggests skills related to a job (but not in the job) based on the skills in the job. The service returns closely related skills in a sense that
1979+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
1980+
* easier to acquire knowledge about them.
1981+
* @param job The job to suggest skills for (based on the skills in the job).
1982+
* @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>
1983+
* @return The API response body
1984+
* @throws SovrenException Thrown when an API error occurs
1985+
*/
1986+
public SuggestSkillsResponse suggestSkillsFromSkills(ParsedJob job, String outputLanguage) throws SovrenException {
1987+
return suggestSkillsFromSkills(job, 25, outputLanguage);
1988+
}
1989+
1990+
/**
1991+
* Suggests skills related to a resume (but not in the resume) based on the skills in the resume. The service returns closely related skills in a sense that
1992+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
1993+
* easier to acquire knowledge about them.
1994+
* @param resume The resume to suggest skills for (based on the skills in the resume).
1995+
* @param limit The maximum amount of suggested skills returned. The maximum is 25.
1996+
* @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>
1997+
* @param weightSkillsByExperience Whether or not to give a higher weight to skills that the candidate has more experience with.
1998+
* @return The API response body
1999+
* @throws SovrenException Thrown when an API error occurs
2000+
*/
2001+
public SuggestSkillsResponse suggestSkillsFromSkills(
2002+
ParsedResume resume,
2003+
int limit,
2004+
String outputLanguage,
2005+
boolean weightSkillsByExperience) throws SovrenException {
2006+
return suggestSkillsFromSkills(getNormalizedSkillsFromResume(resume, weightSkillsByExperience), limit, outputLanguage);
2007+
}
2008+
2009+
/**
2010+
* Suggests skills related to a resume (but not in the resume) based on the skills in the resume. The service returns closely related skills in a sense that
2011+
* knowing the provided skills either implies knowledge about the returned related skills, or should make it considerably
2012+
* easier to acquire knowledge about them.
2013+
* @param resume The resume to suggest skills for (based on the skills in the resume).
2014+
* @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>
2015+
* @return The API response body
2016+
* @throws SovrenException Thrown when an API error occurs
2017+
*/
2018+
public SuggestSkillsResponse suggestSkillsFromSkills(ParsedResume resume, String outputLanguage) throws SovrenException {
2019+
return suggestSkillsFromSkills(resume, 25, outputLanguage, true);
2020+
}
2021+
2022+
/**
2023+
* Determines how closely related one set of skills is to another. The service defines closely related skills
2024+
* such that knowing a skill either implies knowledge about another skill, or should make it considerably
2025+
* easier to acquire knowledge about that skill.
2026+
* @param skillSetA A set of skills (and optionally, scores) to score against the other set of skills. The list can contain up to 50 skills.
2027+
* @param skillSetB A set of skills (and optionally, scores) to score against the other set of skills. The list can contain up to 50 skills.
2028+
* @return The API response body
2029+
* @throws SovrenException Thrown when an API error occurs
2030+
*/
2031+
public SkillsSimilarityScoreResponse skillsSimilarityScore(List<SkillScore> skillSetA, List<SkillScore> skillSetB) throws SovrenException {
2032+
SkillsSimilarityScoreRequest request = new SkillsSimilarityScoreRequest();
2033+
request.SkillsA = skillSetA;
2034+
request.SkillsB = skillSetB;
2035+
2036+
RequestBody body = createJsonBody(request);
2037+
Request apiRequest = new Request.Builder()
2038+
.url(_endpoints.desOntologySkillsSimilarityScore())
2039+
.post(body)
2040+
.build();
2041+
2042+
HttpResponse<SkillsSimilarityScoreResponse> response = executeRequest(apiRequest, SkillsSimilarityScoreResponse.class, getBodyIfDebug(apiRequest));
2043+
return response.getData();
2044+
}
19052045
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright © 2020 Sovren Group, Inc. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Sovren licensees
3+
// within the terms of their license of Sovren products or Sovren customers
4+
// within the Terms of Service pertaining to the Sovren SaaS products.
5+
6+
package com.sovren.models.api.dataenrichment.ontology.request;
7+
8+
import java.util.List;
9+
10+
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
11+
12+
/** Request body for a 'SuggestProfessions' request */
13+
public class SkillsSimilarityScoreRequest {
14+
/** A set of skills (and optionally, scores) to score against the other set of skills. The list can contain up to 50 skills. */
15+
public List<SkillScore> SkillsA;
16+
/** A set of skills (and optionally, scores) to score against the other set of skills. The list can contain up to 50 skills. */
17+
public List<SkillScore> SkillsB;
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright © 2020 Sovren Group, Inc. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Sovren licensees
3+
// within the terms of their license of Sovren products or Sovren customers
4+
// within the Terms of Service pertaining to the Sovren SaaS products.
5+
6+
package com.sovren.models.api.dataenrichment.ontology.request;
7+
8+
import java.util.List;
9+
10+
import com.sovren.models.api.dataenrichment.ontology.response.SkillScore;
11+
12+
/** Request body for a 'SuggestProfessions' request */
13+
public class SuggestSkillsFromSkillsRequest {
14+
/** The skills for which the service should return related skills. The list can contain up to 50 skills. */
15+
public List<SkillScore> Skills;
16+
/** The maximum amount of suggested skills returned. If not specified this parameter defaults to 25. */
17+
public int Limit = 25;
18+
/** The language to use for the returned descriptions. */
19+
public String OutputLanguage;
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright © 2020 Sovren Group, Inc. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Sovren licensees
3+
// within the terms of their license of Sovren products or Sovren customers
4+
// within the Terms of Service pertaining to the Sovren SaaS products.
5+
6+
package com.sovren.models.api.dataenrichment.ontology.response;
7+
8+
import com.sovren.models.api.ApiResponse;
9+
10+
/** The response body from a SuggestSkills API call*/
11+
public class SkillsSimilarityScoreResponse extends ApiResponse<SkillsSimilarityScoreResponseValue> {
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright © 2020 Sovren Group, Inc. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Sovren licensees
3+
// within the terms of their license of Sovren products or Sovren customers
4+
// within the Terms of Service pertaining to the Sovren SaaS products.
5+
6+
package com.sovren.models.api.dataenrichment.ontology.response;
7+
import com.sovren.models.api.ApiResponse;
8+
9+
/** One entry in the {@link ApiResponse#Value} from a 'skills Similarity Score' response */
10+
public class SkillsSimilarityScoreResponseValue {
11+
/** A value from [0 - 1] representing how closely related skill set A and skill set B are, based on the relations between skills. */
12+
public float SimilarityScore;
13+
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ public void testSuggestSkillsFromProfessions() {
135135
});
136136
}
137137

138+
@Test
139+
public void testSuggestSkillsFromSkills() {
140+
assertDoesNotThrow(() -> {
141+
ArrayList<String> skillIds = new ArrayList<String>();
142+
skillIds.add("KS120076FGP5WGWYMP0F");
143+
skillIds.add("KS125HH5XDBPZT3RFGZZ");
144+
skillIds.add("KS124PR62MV42B5C9S9F");
145+
Client.suggestSkillsFromSkills(skillIds, null);
146+
});
147+
}
148+
138149
@Test
139150
public void testSuggestProfessions() {
140151
assertDoesNotThrow(() -> {
@@ -145,4 +156,15 @@ public void testSuggestProfessions() {
145156
Client.suggestProfessionsFromSkills(skillIds, null);
146157
});
147158
}
159+
160+
@Test
161+
public void testSkillsSimilarityScore() {
162+
assertDoesNotThrow(() -> {
163+
ArrayList<SkillScore> skillIds = new ArrayList<SkillScore>();
164+
skillIds.add(new SkillScore("KS120076FGP5WGWYMP0F"));
165+
skillIds.add(new SkillScore("KS125HH5XDBPZT3RFGZZ"));
166+
skillIds.add(new SkillScore("KS124PR62MV42B5C9S9F"));
167+
Client.skillsSimilarityScore(skillIds, skillIds);
168+
});
169+
}
148170
}

0 commit comments

Comments
 (0)