From ca5ada3b9b9e1bc29ed52bdaf4065fa0d5fde4fa Mon Sep 17 00:00:00 2001 From: frostyfan109 Date: Thu, 10 Oct 2024 14:11:10 -0400 Subject: [PATCH 1/2] fix simple search explanation, fix typos --- .../search/concept-modal/tabs/explanation.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/search/concept-modal/tabs/explanation.js b/src/components/search/concept-modal/tabs/explanation.js index 65274951..ff9a4108 100644 --- a/src/components/search/concept-modal/tabs/explanation.js +++ b/src/components/search/concept-modal/tabs/explanation.js @@ -25,9 +25,19 @@ const palette = [ const parseScoreDetail = ({ value, description, details }) => { if (value === 0) return null + // For "sum of:", relevant details contribute their own scores to a final aggregate value. + // (e.g., in a relevance scoring for a term over two search fields, perhaps name and description, maybe the name detail + // has score 5.2 and the description detail has score 3.3, then the aggregate score 8.5 will be used.) if (description === "sum of:") { return details.flatMap((detail) => parseScoreDetail(detail)) } + // For "max of:", only the detail with maximum score is used to compute the score. + // (e.g., in a relevance scoring for a term over two search fields, perhaps name and description, maybe the name detail + // has score 5.2 and the description detail has score 3.3, then the score of 5.2 will be used.) + if (description === "max of:") { + const maximalDetail = details.reduce((acc, cur) => cur.value > acc.value ? cur : acc, details[0]) + return [parseScoreDetail(maximalDetail)] + } const explainPattern = /^weight\((?.+):(?.+) in (?\d+)\) \[(?.+)\], result of:$/ const match = description.match(explainPattern) @@ -92,7 +102,7 @@ export const ExplanationTab = ({ result }) => { const { fieldMatch, termMatch, source, value } = cur const [fieldMatchName, fieldMatchDescription] = ( fieldMatch === "name" ? ["Concept Name", "Contribution to the score because the search query matched this concept's name"] - : fieldMatch === "description" ? ["Description", "Contribution to the score because we found the search query in this concept description"] + : fieldMatch === "description" ? ["Description", "Contribution to the score because we found the search query in this concept's description"] : fieldMatch === "search_terms" ? ["Synonyms", "Contribution to the score because we found the search query in this concept's synonymns"] : fieldMatch === "optional_terms" ? ["Related terms", "Contribution to the score because we found the search query among this concept's semantically related terms"] : ["", ""] @@ -175,7 +185,7 @@ export const ExplanationTab = ({ result }) => { Explanation for this concept's relation to search term
- What does the total score returned by the search mean?? + What does the total score returned by the search mean?
@@ -204,6 +214,8 @@ export const ExplanationTab = ({ result }) => { className="explanation-score-progress" strokeColor={ colorMap[i] } percent={ ((detail.value / totalScore) * 100).toFixed(0) } + // Get rid of annoying style rules at 100% + success={{ percent: 0 }} title={ detail.value.toFixed(2) } style={{ marginLeft: 8 }} /> From f70ec5d1f2b83f72a998609da49d3f13a2549ddc Mon Sep 17 00:00:00 2001 From: Hina Shah Date: Fri, 11 Oct 2024 10:57:13 -0400 Subject: [PATCH 2/2] fix a typo --- src/components/search/concept-modal/tabs/explanation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/search/concept-modal/tabs/explanation.js b/src/components/search/concept-modal/tabs/explanation.js index ff9a4108..81c85c15 100644 --- a/src/components/search/concept-modal/tabs/explanation.js +++ b/src/components/search/concept-modal/tabs/explanation.js @@ -103,7 +103,7 @@ export const ExplanationTab = ({ result }) => { const [fieldMatchName, fieldMatchDescription] = ( fieldMatch === "name" ? ["Concept Name", "Contribution to the score because the search query matched this concept's name"] : fieldMatch === "description" ? ["Description", "Contribution to the score because we found the search query in this concept's description"] - : fieldMatch === "search_terms" ? ["Synonyms", "Contribution to the score because we found the search query in this concept's synonymns"] + : fieldMatch === "search_terms" ? ["Synonyms", "Contribution to the score because we found the search query in this concept's synonyms"] : fieldMatch === "optional_terms" ? ["Related terms", "Contribution to the score because we found the search query among this concept's semantically related terms"] : ["", ""] )