Navigation Menu

Skip to content

Commit

Permalink
fix(nlu): warn of duplication on synonym removal (#4387)
Browse files Browse the repository at this point in the history
  • Loading branch information
spg committed Jan 20, 2021
1 parent a4677ec commit 09da1ec
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/nlu/src/views/full/entities/ListEntity.tsx
Expand Up @@ -90,9 +90,16 @@ export const ListEntityEditor: React.FC<Props> = props => {
}

const editOccurrence = (idx: number, occurrence: NLU.EntityDefOccurrence) => {
const newSynonym = _.last(occurrence.synonyms)
if (!isUnique(newSynonym)) {
return toastFailure('Synonyms duplication is not allowed')
const synonymAdded = () => {
const oldOccurence = state.occurrences[idx]
return oldOccurence.synonyms.length < occurrence.synonyms.length
}

if (synonymAdded()) {
const newSynonym = _.last(occurrence.synonyms)
if (!isUnique(newSynonym)) {
return toastFailure('Synonyms duplication is not allowed')
}
}

const occurrences = [...state.occurrences.slice(0, idx), occurrence, ...state.occurrences.slice(idx + 1)]
Expand Down

0 comments on commit 09da1ec

Please sign in to comment.