From a08cd7b3c7ac0728a049b7b15c2e4fac5b997e19 Mon Sep 17 00:00:00 2001 From: leiyre Date: Tue, 19 Apr 2022 16:16:38 +0200 Subject: [PATCH] fix(TokenClassification): Display characters between tokens words (#1418) This PR fixes the display of characters between duplicate words or when the suffix matches the following word in the Token Classifier Closes #1414 Closes #1383 (cherry picked from commit 97ffc64545e87cd114e623d1e1f14ad0f7eda8c5) --- .../results/RecordTokenClassification.vue | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/frontend/components/token-classifier/results/RecordTokenClassification.vue b/frontend/components/token-classifier/results/RecordTokenClassification.vue index 1cb903706d..4077429f4b 100755 --- a/frontend/components/token-classifier/results/RecordTokenClassification.vue +++ b/frontend/components/token-classifier/results/RecordTokenClassification.vue @@ -65,17 +65,10 @@ export default { const start = recordHasEmoji ? indexOf(this.record.text, token, startPosition) : this.record.text.indexOf(token, startPosition); - const nextStart = recordHasEmoji - ? indexOf( - this.record.text, - this.record.tokens[index + 1], - startPosition - ) - : this.record.text.indexOf( - this.record.tokens[index + 1], - startPosition - ); const end = start + (recordHasEmoji ? length(token) : token.length); + const nextStart = recordHasEmoji + ? indexOf(this.record.text, this.record.tokens[index + 1], end) + : this.record.text.indexOf(this.record.tokens[index + 1], end); const charsBetweenTokens = this.record.text.slice(end, nextStart); let highlighted = false; for (let highlight of searchKeywordsSpans) {