Skip to content

Commit b21805a

Browse files
committed
OpenConceptLab/ocl_online#5 | bridge enabled config
1 parent cf9072c commit b21805a

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

src/components/map-projects/ConfigurationForm.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { useTranslation } from 'react-i18next';
2+
import { Trans, useTranslation } from 'react-i18next';
33
import Typography from '@mui/material/Typography'
44
import Autocomplete from '@mui/material/Autocomplete'
55
import TextField from '@mui/material/TextField'
@@ -50,7 +50,7 @@ const VisuallyHiddenInput = styled('input')({
5050
});
5151

5252

53-
const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, name, setName, description, setDescription, repo, onRepoChange, repoVersion, setRepoVersion, versions, mappedSources, targetSourcesFromRows, algo, onAlgoSelect, sx, algos, validColumns, columns, isValidColumnValue, updateColumn, configure, setConfigure, columnVisibilityModel, setColumnVisibilityModel, onSave, isSaving, matchAPI, setMatchAPI, matchAPIToken, setMatchAPIToken, candidatesScore, onScoreChange, semanticBatchSize, setSemanticBatchSize, includeDefaultFilter, setIncludeDefaultFilter, filters, setFilters, locales, isLoadingLocales, reranker, setReranker }) => {
53+
const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, name, setName, description, setDescription, repo, onRepoChange, repoVersion, setRepoVersion, versions, mappedSources, targetSourcesFromRows, algo, onAlgoSelect, sx, algos, validColumns, columns, isValidColumnValue, updateColumn, configure, setConfigure, columnVisibilityModel, setColumnVisibilityModel, onSave, isSaving, matchAPI, setMatchAPI, matchAPIToken, setMatchAPIToken, candidatesScore, onScoreChange, semanticBatchSize, setSemanticBatchSize, includeDefaultFilter, setIncludeDefaultFilter, filters, setFilters, locales, isLoadingLocales, reranker, setReranker, canBridge, bridgeEnabled, setBridgeEnabled }) => {
5454
const { t } = useTranslation();
5555
const [algoMenuAnchorEl, setAlgoMenuAnchorEl] = React.useState(null)
5656
const canApplyReranking = hasAuthGroup(getCurrentUser(), MAPPER_CROSS_ENCODER_GROUP)
@@ -304,6 +304,31 @@ const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, n
304304
label={t('map_project.enable_reranker')}
305305
/>
306306

307+
}
308+
{
309+
algo != 'es' &&
310+
<FormControlLabel
311+
sx={{marginLeft: '-4px', marginTop: '6px', alignItems: 'flex-start', '.MuiCheckbox-root': {paddingTop: '2px'}}}
312+
size='small'
313+
control={
314+
<Checkbox
315+
size='small'
316+
disabled={!canBridge}
317+
checked={bridgeEnabled}
318+
sx={{padding: '8px 4px'}}
319+
onChange={() => setBridgeEnabled(!bridgeEnabled)}
320+
/>
321+
}
322+
label={
323+
<Trans
324+
i18nKey='map_project.bridge_terminology_search'
325+
components={[
326+
<sup key="1"/>
327+
]}
328+
/>
329+
}
330+
/>
331+
307332
}
308333
<>
309334
<Typography component="div" sx={{fontSize: '16px', fontWeight: 'bold', marginTop: '20px'}}>

src/components/map-projects/MapProject.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const MapProject = () => {
171171
const [matchAPIToken, setMatchAPIToken] = React.useState('')
172172
const [semanticBatchSize, setSemanticBatchSize] = React.useState(SEMANTIC_BATCH_SIZE)
173173
const [reranker, setReranker] = React.useState(false)
174+
const [bridgeEnabled, setBridgeEnabled] = React.useState(false)
174175
const [candidatesScore, setCandidatesScore] = React.useState({recommended: 99, available: 70})
175176
const [filters, setFilters] = React.useState({})
176177
const [AIModel, setAIModel] = React.useState('')
@@ -231,6 +232,7 @@ const MapProject = () => {
231232
let AI_ASSISTANT_API_URL = window.AI_ASSISTANT_API_URL || process.env.AI_ASSISTANT_API_URL
232233
const inAIAssistantGroup = Boolean(hasAuthGroup(user, 'mapper_ai_assistant') && AI_ASSISTANT_API_URL)
233234
const CANDIDATES_LIMIT = reranker ? 30 : 10
235+
const canBridge = bridgeRef?.current?.canBridge()
234236

235237

236238
// algos - computed based on current language
@@ -351,6 +353,7 @@ const MapProject = () => {
351353
setMatchAPI(response.data?.match_api_url)
352354
setMatchAPIToken(response.data?.match_api_token)
353355
setReranker(Boolean(response.data?.reranker))
356+
setBridgeEnabled(Boolean(response.data?.bridge_enabled))
354357
if(response.data?.match_api_url)
355358
setSemanticBatchSize(response.data?.batch_size || SEMANTIC_BATCH_SIZE)
356359
setCandidatesScore(response.data?.score_configuration)
@@ -746,6 +749,7 @@ const MapProject = () => {
746749
}
747750
formData.append('filters', JSON.stringify(getFilters()))
748751
formData.append('reranker', reranker)
752+
formData.append('bridge_enabled', bridgeEnabled)
749753
const isUpdate = Boolean(project?.id)
750754
let service = APIService.new().overrideURL(owner).appendToUrl('map-projects/')
751755
if(isUpdate)
@@ -993,6 +997,8 @@ const MapProject = () => {
993997
subActions.push('unmatched_only')
994998
if(reranker)
995999
subActions.push('with_reranker')
1000+
if(bridgeEnabled)
1001+
subActions.push('with_bridge_candidates')
9961002

9971003
setRowStatuses(prev => {
9981004
prev.unmapped = []
@@ -1003,7 +1009,7 @@ const MapProject = () => {
10031009
await processWithConcurrency(repo);
10041010

10051011
setTimeout(() => {
1006-
if(bridgeRef?.current?.canBridge()) {
1012+
if(bridgeEnabled) {
10071013
subActions.push('bridge_candidates')
10081014
fetchBulkBridgeCandidates(rows)
10091015
}
@@ -1026,6 +1032,11 @@ const MapProject = () => {
10261032
otherMatchedConceptsRef.current = otherMatchedConcepts;
10271033
}, [otherMatchedConcepts]);
10281034

1035+
React.useEffect(() => {
1036+
if(bridgeEnabled && canBridge === false)
1037+
setBridgeEnabled(false)
1038+
}, [canBridge, bridgeEnabled])
1039+
10291040
React.useEffect(() => {
10301041
bridgeCandidatesRef.current = bridgeCandidates;
10311042
}, [bridgeCandidates]);
@@ -1336,7 +1347,7 @@ const MapProject = () => {
13361347
forEach(getTop10RowCandidates(index), (candidate, i) => {
13371348
if(i < 10)
13381349
_candidatesTop10[`__Candidate_Top_${i + 1}__`] = candidate?.id ? compact([`${candidate.id}:${candidate.display_name}`, `Score: ${candidate?.search_meta?.search_normalized_score}`]).join('\n') : null
1339-
else if(bridgeRef?.current?.canBridge()) {
1350+
else if(bridgeEnabled) {
13401351
_bridgeCandidatesTop10[`__BridgeCandidate_Top_${i - 9}__`] = candidate ? bridgeRef.current?.getCandidateLabelForDownload(candidate) : null
13411352
}
13421353
})
@@ -1634,7 +1645,7 @@ const MapProject = () => {
16341645
setTimeout(() => highlightTexts(existingCandidates, null, false), 100)
16351646
return
16361647
}
1637-
if(!bridgeRef?.current?.canBridge())
1648+
if(!bridgeEnabled)
16381649
return
16391650
setIsLoadingInDecisionView(true)
16401651
const payload = getPayloadForMatching([__row], repo)
@@ -1994,6 +2005,9 @@ const MapProject = () => {
19942005
isLoadingLocales={isLoadingLocales}
19952006
reranker={reranker}
19962007
setReranker={setReranker}
2008+
bridgeEnabled={bridgeEnabled}
2009+
setBridgeEnabled={setBridgeEnabled}
2010+
canBridge={canBridge}
19972011
/>
19982012
</div>
19992013
}
@@ -2440,6 +2454,9 @@ const MapProject = () => {
24402454
isLoadingLocales={isLoadingLocales}
24412455
reranker={reranker}
24422456
setReranker={setReranker}
2457+
bridgeEnabled={bridgeEnabled}
2458+
setBridgeEnabled={setBridgeEnabled}
2459+
canBridge={canBridge}
24432460
/>
24442461
</div> :
24452462
(

src/i18n/locales/en/translations.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@
525525
"sort_by_raw_score": "Sort by Raw Score",
526526
"project_logs": "Project Logs",
527527
"project_logs_tooltip": "View project logs",
528-
"saved_to_collection": "Saved to collection"
528+
"saved_to_collection": "Saved to collection",
529+
"bridge_terminology_search": "Bridge terminology search<0>Premium</0>: Search mappings in the Columbia University International eHealth Laboratory interface terminology to identify additional high quality candidates (only available for compatible target repositories and matching algorithms)"
529530
},
530531
"app": {
531532
"web_version": "Web Version",

0 commit comments

Comments
 (0)