Skip to content

Commit

Permalink
Split close_synonyms into exact and narrow
Browse files Browse the repository at this point in the history
Refs #2285
  • Loading branch information
kimrutherford committed Nov 28, 2024
1 parent 3a5e53b commit a83e587
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/complete.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,19 @@ export class CompleteService {

const resultTerms: Array<SolrTermSummary> = terms.map((term: any) => {
let synonymMatch = null;
if (queryText.length >= 2 && term['close_synonyms']) {
if (queryText.length >= 2 && term['exact_synonyms']) {
const nameScore = compareTwoStrings(term.name, queryText);
for (const syn of term['close_synonyms'] as Array<string>) {
for (const syn of term['exact_synonyms'] as Array<string>) {
const synScore = compareTwoStrings(syn, queryText);
if (synScore > nameScore) {
synonymMatch = syn;
break;
}
}
}
if (!synonymMatch && queryText.length >= 2 && term['narrow_synonyms']) {
const nameScore = compareTwoStrings(term.name, queryText);
for (const syn of term['narrow_synonyms'] as Array<string>) {
const synScore = compareTwoStrings(syn, queryText);
if (synScore > nameScore) {
synonymMatch = syn;
Expand Down

0 comments on commit a83e587

Please sign in to comment.