Skip to content

Commit b4ea1d2

Browse files
committed
OpenConceptLab/ocl_online#36 | Scispacy LOINC in mapper
1 parent 940abff commit b4ea1d2

7 files changed

Lines changed: 231 additions & 45 deletions

File tree

src/components/map-projects/Candidates.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const Sort = ({ selected, onSort, reranker }) => {
7676
)
7777
}
7878

79-
const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, bgColor, bucketId, display, onDisplayChange, noToolbar, toolbarControl, repoVersion, alignToolbarLeft, rightControl, analysis, showAnalysis, openAnalysis, onCloseAnalysis, AIRecommendedCandidateId, locales, bridge}) => {
79+
const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, bgColor, bucketId, display, onDisplayChange, noToolbar, toolbarControl, repoVersion, alignToolbarLeft, rightControl, analysis, showAnalysis, openAnalysis, onCloseAnalysis, AIRecommendedCandidateId, locales, bridge, scispacy}) => {
8080
const results = {total: onFetchMore ? candidates?.length : 1, results: candidates || []}
8181

8282
const getExtraColumns = () => {
@@ -149,14 +149,14 @@ const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderCha
149149
) :
150150
(
151151
showHeader &&
152-
<ListSubheader sx={{lineHeight: '28px', padding: '2px 8px', background: bgColor || 'rgb(229, 229, 229)', display: 'inline-flex', justifyContent: 'space-between', width: '100%', color: '#000', fontSize: '12px', borderBottom: bridge ? `1px solid ${PRIMARY_COLORS.main}` : undefined}}>
152+
<ListSubheader sx={{lineHeight: '28px', padding: '2px 8px', background: bgColor || 'rgb(229, 229, 229)', display: 'inline-flex', justifyContent: 'space-between', width: '100%', color: '#000', fontSize: '12px', borderBottom: (bridge || scispacy) ? `1px solid ${PRIMARY_COLORS.main}` : undefined}}>
153153
<b>{header}</b>
154154
<b>{count.toLocaleString()}</b>
155155
</ListSubheader>
156156
)
157157
}
158158
title=' '
159-
renderer={props => <Concept {...props} key={`${bucketId}-${props?.concept?.uuid}`} onMap={onMap} isSelectedForMap={isSelectedForMap} setShowHighlights={setShowHighlights} repoVersion={repoVersion} isAIRecommended={AIRecommendedCandidateId === props?.concept?.id} AIRecommendedCandidateId={AIRecommendedCandidateId} locales={locales} bridge={bridge} />}
159+
renderer={props => <Concept {...props} key={`${bucketId}-${props?.concept?.uuid}`} onMap={onMap} isSelectedForMap={isSelectedForMap} setShowHighlights={setShowHighlights} repoVersion={repoVersion} isAIRecommended={AIRecommendedCandidateId === props?.concept?.id} AIRecommendedCandidateId={AIRecommendedCandidateId} locales={locales} bridge={bridge} scispacy={scispacy} notClickable={Boolean(scispacy)} />}
160160
display={display}
161161
onDisplayChange={onDisplayChange}
162162
nested
@@ -189,7 +189,7 @@ const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderCha
189189
)
190190
}
191191

192-
const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, isLoading, candidatesScore, repoVersion, analysis, onFetchRecommendation, appliedFacets, setAppliedFacets, filters, facets, columns, defaultFilters, locales, bridgeCandidates, models, selectedModel, onModelChange, reranker, onRefreshClick}) => {
192+
const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, isLoading, candidatesScore, repoVersion, analysis, onFetchRecommendation, appliedFacets, setAppliedFacets, filters, facets, columns, defaultFilters, locales, bridgeCandidates, scispacyCandidates, models, selectedModel, onModelChange, reranker, onRefreshClick}) => {
193193
const { t } = useTranslation();
194194
const [sortBy, setSortBy] = React.useState(false)
195195
/*eslint no-undef: 0*/
@@ -202,6 +202,7 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOr
202202
const availableScore = candidatesScore?.available
203203
const results = find(candidates, c => c.row?.__index === rowIndex )?.results
204204
const bridgeResults = find(bridgeCandidates, c => c.row?.__index === rowIndex )?.results || []
205+
const scispacyResults = find(scispacyCandidates, c => c.row?.__index === rowIndex )?.results || []
205206
const isNoneLoaded = results === null || results === undefined
206207
const concepts = results || []
207208
const canFetchMore = concepts?.length > 0
@@ -411,6 +412,13 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOr
411412
<CandidateList {...props} candidates={bridgeResults} header={t('map_project.ciel_bridge_terminology_candidates')} onFetchMore={onFetchMore} bucketId={`${rowIndex}-bridge`} noToolbar bridge />
412413
}
413414
</li>
415+
<li>
416+
{
417+
(isLoading && isNoneLoaded) ?
418+
<Skeleton height={60} /> :
419+
<CandidateList {...props} candidates={scispacyResults} header={t('map_project.scispacy_candidates')} onFetchMore={onFetchMore} bucketId={`${rowIndex}-scispacy`} noToolbar scispacy />
420+
}
421+
</li>
414422
</List>
415423
{
416424
onFetchMore && canFetchMore &&

src/components/map-projects/Concept.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const getBestSynonym = synonyms => {
2626
}
2727

2828

29-
const Item = ({concept, setShowHighlights, onMap, isSelectedForMap, noScore, repoVersion, synonymPrefix, isAIRecommended, bridge, mapping}) => {
29+
const Item = ({concept, setShowHighlights, onMap, isSelectedForMap, noScore, repoVersion, synonymPrefix, isAIRecommended, bridge, mapping, scispacy}) => {
3030
const isValidBridge = Boolean(bridge && mapping.cascade_target_concept_url)
3131
let bridgeMappingPrefix = bridge && mapping.cascade_target_concept_code ? `${mapping.cascade_target_source_name}:${mapping.cascade_target_concept_code} ${mapping.cascade_target_concept_name || ''}` : false
3232
const conceptToMap = isValidBridge ?
@@ -86,7 +86,7 @@ const Item = ({concept, setShowHighlights, onMap, isSelectedForMap, noScore, rep
8686
isSelectedForMap &&
8787
<MapButton
8888
simple
89-
disabled={bridge && !mapping.cascade_target_concept_url}
89+
disabled={scispacy || (bridge && !mapping.cascade_target_concept_url)}
9090
selected={mapTypeToApply}
9191
onClick={(event, applied, mapType) => onMap(event, conceptToMap, !applied, mapping?.map_type || mapType)}
9292
isMapped={isSelectedForMap(conceptToMap)}
@@ -99,7 +99,7 @@ const Item = ({concept, setShowHighlights, onMap, isSelectedForMap, noScore, rep
9999
}
100100

101101

102-
const Concept = ({firstChild, concept, setShowHighlights, isShown, onCardClick, onMap, isSelectedForMap, noScore, repoVersion, isAIRecommended, AIRecommendedCandidateId, sx, notClickable, noSynonymPrefix, locales, bridge}) => {
102+
const Concept = ({firstChild, concept, setShowHighlights, isShown, onCardClick, onMap, isSelectedForMap, noScore, repoVersion, isAIRecommended, AIRecommendedCandidateId, sx, notClickable, noSynonymPrefix, locales, bridge, scispacy}) => {
103103
const id = concept?.version_url || concept?.url || concept?.id
104104
const isSelectedToShow = isShown ? isShown(id) : false
105105

@@ -140,11 +140,11 @@ const Concept = ({firstChild, concept, setShowHighlights, isShown, onCardClick,
140140

141141
return notClickable ? (
142142
<ListItem {...props}>
143-
<Item concept={concept} repoVersion={repoVersion} synonymPrefix={synonymPrefix} setShowHighlights={setShowHighlights} isAIRecommended={isAIRecommended} isSelectedForMap={isSelectedForMap} onMap={onMap} noScore={noScore} bridge={bridge} />
143+
<Item concept={concept} repoVersion={repoVersion} synonymPrefix={synonymPrefix} setShowHighlights={setShowHighlights} isAIRecommended={isAIRecommended} isSelectedForMap={isSelectedForMap} onMap={onMap} noScore={noScore} bridge={bridge} scispacy={scispacy} />
144144
</ListItem>
145145
) : (
146146
<ListItemButton {...props} onClick={onCardClick ? event => onCardClick(event, id) : undefined}>
147-
<Item concept={concept} repoVersion={repoVersion} synonymPrefix={synonymPrefix} setShowHighlights={setShowHighlights} isAIRecommended={isAIRecommended} isSelectedForMap={isSelectedForMap} onMap={onMap} noScore={noScore} bridge={bridge} />
147+
<Item concept={concept} repoVersion={repoVersion} synonymPrefix={synonymPrefix} setShowHighlights={setShowHighlights} isAIRecommended={isAIRecommended} isSelectedForMap={isSelectedForMap} onMap={onMap} noScore={noScore} bridge={bridge} scispacy={scispacy} />
148148
</ListItemButton>
149149
)
150150
}

src/components/map-projects/ConfigurationForm.jsx

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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, canBridge, bridgeEnabled, setBridgeEnabled }) => {
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, canScispacy, scispacyEnabled, setScispacyEnabled }) => {
5454
const { t } = useTranslation();
5555
const [algoMenuAnchorEl, setAlgoMenuAnchorEl] = React.useState(null)
5656
const canApplyReranking = hasAuthGroup(getCurrentUser(), MAPPER_CROSS_ENCODER_GROUP)
@@ -308,38 +308,57 @@ const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, n
308308
{
309309
algo != 'es' &&
310310
<>
311-
<FormControlLabel
312-
sx={{width: '100%', marginLeft: '-4px', marginTop: '6px', alignItems: 'flex-start', '.MuiCheckbox-root': {paddingTop: '2px'}}}
313-
size='small'
314-
control={
315-
<Checkbox
316-
size='small'
317-
disabled={!canBridge}
318-
checked={bridgeEnabled}
319-
sx={{padding: '8px 4px'}}
320-
onChange={() => setBridgeEnabled(!bridgeEnabled)}
321-
/>
322-
}
323-
label={
324-
<Trans
325-
i18nKey='map_project.bridge_terminology_search'
326-
components={[
327-
<sup key="1"/>
328-
]}
329-
/>
330-
}
331-
/>
311+
<FormControlLabel
312+
sx={{width: '100%', marginLeft: '-4px', marginTop: '6px', alignItems: 'flex-start', '.MuiCheckbox-root': {paddingTop: '2px'}}}
313+
size='small'
314+
control={
315+
<Checkbox
316+
size='small'
317+
disabled={!canBridge}
318+
checked={bridgeEnabled}
319+
sx={{padding: '8px 4px'}}
320+
onChange={() => setBridgeEnabled(!bridgeEnabled)}
321+
/>
322+
}
323+
label={
324+
<Trans
325+
i18nKey='map_project.bridge_terminology_search'
326+
components={[
327+
<sup key="1"/>
328+
]}
329+
/>
330+
}
331+
/>
332332
<FormHelperText sx={{marginTop: 0}}>
333333
<Trans
334334
i18nKey='map_project.bridge_terminology_search_description'
335335
components={[
336336
<a key="0" href={`${toV3URL('/orgs/CIEL/sources/CIEL/')}`} target="_blank" rel="noreferrer noopener"/>
337337
]}
338338
/>
339-
</FormHelperText>
340-
</>
341-
342-
339+
</FormHelperText>
340+
<FormControlLabel
341+
sx={{width: '100%', marginLeft: '-4px', marginTop: '6px', alignItems: 'flex-start', '.MuiCheckbox-root': {paddingTop: '2px'}}}
342+
size='small'
343+
control={
344+
<Checkbox
345+
size='small'
346+
disabled={!canScispacy}
347+
checked={scispacyEnabled}
348+
sx={{padding: '8px 4px'}}
349+
onChange={() => setScispacyEnabled(!scispacyEnabled)}
350+
/>
351+
}
352+
label={
353+
<Trans
354+
i18nKey='map_project.scispacy_loinc_search'
355+
components={[
356+
<sup key="1"/>
357+
]}
358+
/>
359+
}
360+
/>
361+
</>
343362
}
344363
<>
345364
<Typography component="div" sx={{fontSize: '16px', fontWeight: 'bold', marginTop: '20px'}}>

0 commit comments

Comments
 (0)