Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

fix: add fallback to use entityType when builtinTupe is not available #613

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/components/ExtractorResponseEditor/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,19 +502,12 @@ export const getEntitiesFromValueUsingTokenData = (change: any): models.IGeneric
.filter(x => x)
}

export const getPreBuiltEntityDisplayName = (pe: PredictedEntity): string => {
const names = pe.builtinType.split('.')
// If builtinType is only copy of entityType
if (names.length === 1) {
return pe.builtinType
}

// If builtinType is just basic value 'builtin.number' -> 'number'
if (names.length === 2) {
return names[1]
export const getPreBuiltEntityDisplayName = (entity: EntityBase, pe: PredictedEntity): string => {
if (typeof pe.builtinType !== 'string' || pe.builtinType.length === 0) {
return entity.entityType
}

// If builtinType is complex value 'builtin.encyclopedia.people.person' -> 'person'
const names = pe.builtinType.split('.')
return names[names.length - 1]
}

Expand Down Expand Up @@ -595,7 +588,7 @@ export const convertExtractorResponseToEditorModels = (extractResponse: ExtractR

const preBuiltEntities = internalPredictedEntities
.filter(({ entity }) => entity && entity.entityType !== EntityType.LUIS && entity.entityType !== EntityType.LOCAL)
.map(({ entity, predictedEntity }) => convertPredictedEntityToGenericEntity(predictedEntity, entity.entityName, getPreBuiltEntityDisplayName(predictedEntity)))
.map(({ entity, predictedEntity }) => convertPredictedEntityToGenericEntity(predictedEntity, entity.entityName, getPreBuiltEntityDisplayName(entity, predictedEntity)))

return {
options,
Expand Down